Closed
Description
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):
SELECT id, val FROM config;
You will receive two strings per row holding representations of id and val, whereas
SELECT id, val FROM config WHERE id>?;
with argument 0
delivers an int64 and a float64 value (as expected, right?).
Complete:
// mc, _ := sql.Open(...)
// ...
holderId := new(interface{})
holderVal := new(interface{})
res, _ := mc.Query("SELECT id, val FROM config")
for res.Next() {
res.Scan(holderId, holderVal)
// => holderId = *string("1"), holderVal = *string("1.11")
}
res.Close()
// ....
res = mc.Query("SELECT id, val FROM config WHERE id > ?", 0)
for res.Next() {
res.Scan(holderId, holderVal)
// => holderId = *int64(1), holderVal = *float64(1.11)
}
res.Close()
Metadata
Metadata
Assignees
Labels
No labels