Closed
Description
Hello,
I need the interface type variables to hold the query results to make library functions.
Suppose that a database table name "test" has the fields: id(int =1), name(varchar), f2(double). Run the following program:
var id, name, f2 interface{} // I need the interface type to make library functions
rows, err := db.Query("SELECT id, name, f2 FROM test where id=?", 1)
if err != nil {
fmt.Println(err)
}
for rows.Next() {
if err = rows.Scan(&id, &name, &f2); err != nil {
fmt.Println(err)
}
fmt.Printf("%t %t %t\n", id, name, f2)
}
if err = rows.Err(); err != nil {
fmt.Println(err)
}
The program show the type of id is int64, name is []byte, f2 is float64. This is fine. But if I change the query to:
rows, err := db.Query("SELECT id, name, f2 FROM test where id=1")
All the types become []byte (I think this is not good).
Is this a bug of the driver?
I think it may be better that the result types can be as the former(with placeholder) case.
Thank you very much.
Metadata
Metadata
Assignees
Labels
No labels