Closed Blacksmoke16 closed 5 years ago
The query_one and others performs a cast without conversions. If the type is not the expected one this kind of errors appear.
You can check rs.read.class to know what type the EXIST is generating and use that type in query_one. From the error it should be an Int64.
I have some thoughts to include some conversions to handle type miss-matches more gracefully. But they are not settled yet.
That makes sense as to why its happening, but it is slightly annoying since it works fine for the PG and Sqlite shards. IMO each DB shard should act in a similar fashion.
Was hoping to use #scalar
here but it doesn't allow arguments to be supplied, without just interloping them in the string, like the other query methods do.
I think I got it. In result_set and text_result_set there is a conversion to mimic boolean types since mysql represent as tinyint. That code asumes Int8 (tinyint) is will be present. That seems to not hold on EXISTS result.
Making other ints available in https://github.com/crystal-lang/crystal-mysql/search?utf8=%E2%9C%93&q=from_mysql&type= should be enough.
Do you want to check and send a PR?
Done @bcardiff.
Where the table looks like: