Skip to content

Commit

Permalink
Fix mysql type reading
Browse files Browse the repository at this point in the history
> That's a specialty of MySQL: you have to use prepared statements to get the native types. MySQL has two protocols, one transmits everything as text, the other as the "real" type. And that binary protocol is only used when you use prepared statements. The driver is pretty much powerless to enforce a protocol and the text protocol takes less resources on the server.
go-sql-driver/mysql#407 (comment)

0_o
  • Loading branch information
timabell committed Mar 25, 2019
1 parent ff1dbc5 commit 2955035
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,13 @@ func (model mysqlModel) GetSqlRows(table *schema.Table, params *params.TablePara
defer dbc.Close()

sql, values := buildQuery(table, params, peekFinder)
rows, err = dbc.Query(sql, values...)
statement, err := dbc.Prepare(sql)
if err != nil {
log.Print("GetRows failed to prepare query")
log.Println(sql)
log.Println(err)
}
rows, err = statement.Query(values...)
if err != nil {
log.Print("GetRows failed to get query")
log.Println(sql)
Expand Down

0 comments on commit 2955035

Please sign in to comment.