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.
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
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

Comments