@@ -176,7 +176,7 @@ func (mc *mysqlConn) escapeBytes(v []byte) string {
176
176
return "'" + string (escape (v )) + "'"
177
177
}
178
178
179
- func (mc * mysqlConn ) buildQuery (query string , args []driver.Value ) (string , error ) {
179
+ func (mc * mysqlConn ) interpolateParams (query string , args []driver.Value ) (string , error ) {
180
180
chunks := strings .Split (query , "?" )
181
181
if len (chunks ) != len (args )+ 1 {
182
182
return "" , driver .ErrSkip
@@ -196,7 +196,7 @@ func (mc *mysqlConn) buildQuery(query string, args []driver.Value) (string, erro
196
196
case int64 :
197
197
parts [pos ] = strconv .FormatInt (v , 10 )
198
198
case float64 :
199
- parts [pos ] = strconv .FormatFloat (v , 'f ' , - 1 , 64 )
199
+ parts [pos ] = strconv .FormatFloat (v , 'g ' , - 1 , 64 )
200
200
case bool :
201
201
if v {
202
202
parts [pos ] = "1"
@@ -211,11 +211,7 @@ func (mc *mysqlConn) buildQuery(query string, args []driver.Value) (string, erro
211
211
parts [pos ] = v .In (mc .cfg .loc ).Format (fmt )
212
212
}
213
213
case []byte :
214
- if v == nil {
215
- parts [pos ] = "NULL"
216
- } else {
217
- parts [pos ] = mc .escapeBytes (v )
218
- }
214
+ parts [pos ] = mc .escapeBytes (v )
219
215
case string :
220
216
parts [pos ] = mc .escapeBytes ([]byte (v ))
221
217
default :
@@ -242,7 +238,7 @@ func (mc *mysqlConn) Exec(query string, args []driver.Value) (driver.Result, err
242
238
return nil , driver .ErrSkip
243
239
}
244
240
// try client-side prepare to reduce roundtrip
245
- prepared , err := mc .buildQuery (query , args )
241
+ prepared , err := mc .interpolateParams (query , args )
246
242
if err != nil {
247
243
return nil , err
248
244
}
0 commit comments