From 6cb3bb08935ac980efd2793189da30218fb2152b Mon Sep 17 00:00:00 2001 From: Qu Xuan Date: Wed, 31 Dec 2025 10:58:46 +0800 Subject: [PATCH] fix: format time debug string --- debug.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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) }