ByteArray objects cannot be converted to strings error

Posted Oct 04, 2006

I ran into this error yesterday from a query that's been running fine for months now. I don't know why it all of a sudden happened, but I thought I would share it with you in case you run across it.

I was retrieving some records and outputting the fields to the screen. As I outputted certain fields, they were returning this message:
 
 ByteArray objects cannot be converted to strings error
 
 
It wasn't just one field type, and included text and numeric fields. When I ran the query in MySQL query browser, I noticed all the problem fields were being output as a Blob type. When I ran it in the Linux MySQL client, it displayed the fields correctly as text.  

The only thing I could think is because I was using a UNION, it caused it to convert the fields.
 
To fix it I surrounded the variable with Coldfusion's ToString() function every time I outputted.

The only hint I can get is from this change log that says

"If one creates a too long CHAR/VARCHAR it's now automatically changed to TEXT or BLOB; One get a warning in this case."
http://dev.mysql.com/doc/refman/4.1/en/news-4-1-0.html

Then today, I was going over this error with my fellow programmers and we discovered that my columns in the 2 select queries in my UNION were not lining up correctly. I had the same number of columns, it just turned out I had duplicated a column and did not included a column from the other query.

In other words it looked like this:

SELECT col1, col2, col3, col4, col5, col6
FROM test1

UNION

SELECT col1, col2, col2, col3, col4, col5
FROM test 1

So col3 in the first SELECT, wasn't the same type as the second col2 in the second SELECT and so on. MySQL converted this into a BLOB and Coldfusion didn't know how to handle it, unless I converted it using its ToString() function.

Problem Solved

Discussions

Comments are currently turned off

Latest Discussions

  • Carlos: Thank you!
    May 16, 2014 | Replies (0)
  • Jessica: Great info, thanks!
    May 15, 2014 | Replies (1)
  • Walter: Thanks, you totally saved me a bunch of searching around just now. I was setting up a percona xtradb...
    Feb 25, 2014 | Replies (0)
  • Avi: I've found the reason of the problem in my case. It's a bug as described here :http://bugs.mysql.com/bug.php?id=68892Shortly:...
    Dec 12, 2013 | Replies (0)
  • Avi: I've also met that behavior twice on 5.6.12 slaves. However, i didn't find the root cause of that....
    Dec 12, 2013 | Replies (0)