-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Simple query results differ from parameterized query results (strings vs. true data types) #211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is expected. To get rid of your problem, change your code to use prepared statements. |
Arne, |
Right now, you can use prepared statements; either explicit with Anyway, that's one reason why we can't silently use prepared statements everywhere and have to implement support for both protocols. All of this makes it surprising to get a string result, but we don't have an alternative without downgrading the driver performance or making certain classes of queries impossible. If I'm not seeing something, please drop me another comment. Nearly all of the protocol handling was written by Julien, I'm not treading on the most solid ground here. |
Is this something we should mention in the database/sql tutorial, or is |
I opened an issue ; we can consider explaining this there. Add further |
A "fast track" query (no placeholders / arguments) delivers string values (textRows) while a "normal" query (with arguments) delivers typed results (obv. using Prepare+Query & binaryRows) when using Scan interface function with empty interfaces (untyped!) as the value receivers.
To reproduce simply execute these (quite similar) examples on a table config with an id column (int unsigned) and a val column (double):
You will receive two strings per row holding representations of id and val, whereas
with argument 0
delivers an int64 and a float64 value (as expected, right?).
Complete:
The text was updated successfully, but these errors were encountered: