diff --git a/debug.go b/debug.go index 8957603..2bc3d9c 100644 --- a/debug.go +++ b/debug.go @@ -41,11 +41,13 @@ func _sqlDebug(sqlstr string, variables []interface{}) string { func SQLPrintf(sqlstr string, variables []interface{}) string { for _, v := range variables { - switch v.(type) { + switch vv := v.(type) { case bool, int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, float32, float64: sqlstr = strings.Replace(sqlstr, "?", fmt.Sprintf("%v", v), 1) - case string, time.Time: + case string: sqlstr = strings.Replace(sqlstr, "?", fmt.Sprintf("'%s'", v), 1) + case time.Time: + sqlstr = strings.Replace(sqlstr, "?", fmt.Sprintf("'%s'", vv.UTC().Format(time.DateTime)), 1) default: sqlstr = strings.Replace(sqlstr, "?", fmt.Sprintf("'%v'", v), 1) }