From 7244e2ea4f74c25880fb24579a9b426b20b48e30 Mon Sep 17 00:00:00 2001 From: qqxhb <1252905006@qq.com> Date: Fri, 18 Oct 2024 20:11:00 +0800 Subject: [PATCH] feat: rm trim empty --- do_test.go | 11 +++++++++++ internal/model/tbl_column.go | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/do_test.go b/do_test.go index 00e52f44..a69c4d81 100644 --- a/do_test.go +++ b/do_test.go @@ -1,6 +1,7 @@ package gen import ( + "fmt" "reflect" "strings" "testing" @@ -74,6 +75,16 @@ func build(stmt *gorm.Statement, opts ...stmtOpt) *gorm.Statement { } func TestDO_methods(t *testing.T) { + s := "' '" + for (len(s) >= 3 && s[0] == '\'' && s[len(s)-1] == '\'' && s[len(s)-2] != '\\') || + (len(s) == 2 && s == "''") { + fmt.Println("xxx") + s = s[1 : len(s)-1] + } + fmt.Println("aa", s, "bb") + + return + testcases := []struct { Expr SubQuery Opts []stmtOpt diff --git a/internal/model/tbl_column.go b/internal/model/tbl_column.go index 3dd59673..f1c394e0 100644 --- a/internal/model/tbl_column.go +++ b/internal/model/tbl_column.go @@ -136,7 +136,7 @@ func (c *Column) needDefaultTag(defaultTagValue string) bool { case reflect.String: return defaultTagValue != "" case reflect.Struct: - return strings.Trim(defaultTagValue, "'0:- ") != "" + return strings.Trim(defaultTagValue, "'0:-") != "" } return c.Name() != "created_at" && c.Name() != "updated_at" }