diff --git a/database/gdb/gdb_func.go b/database/gdb/gdb_func.go index 0b6047ec2..4c20d26a7 100644 --- a/database/gdb/gdb_func.go +++ b/database/gdb/gdb_func.go @@ -374,13 +374,11 @@ func formatWhereHolder(db DB, in formatWhereHolderInput) (newWhere string, newAr case reflect.Map: for key, value := range DataToMapDeep(in.Where) { - if gregex.IsMatchString(regularFieldNameRegPattern, key) { - if in.OmitNil && empty.IsNil(value) { - continue - } - if in.OmitEmpty && empty.IsEmpty(value) { - continue - } + if in.OmitNil && empty.IsNil(value) { + continue + } + if in.OmitEmpty && empty.IsEmpty(value) { + continue } newArgs = formatWhereKeyValue(formatWhereKeyValueInput{ Db: db, @@ -406,13 +404,11 @@ func formatWhereHolder(db DB, in formatWhereHolderInput) (newWhere string, newAr if iterator, ok := in.Where.(iIterator); ok { iterator.Iterator(func(key, value interface{}) bool { ketStr := gconv.String(key) - if gregex.IsMatchString(regularFieldNameRegPattern, ketStr) { - if in.OmitNil && empty.IsNil(value) { - return true - } - if in.OmitEmpty && empty.IsEmpty(value) { - return true - } + if in.OmitNil && empty.IsNil(value) { + return true + } + if in.OmitEmpty && empty.IsEmpty(value) { + return true } newArgs = formatWhereKeyValue(formatWhereKeyValueInput{ Db: db, diff --git a/database/gdb/gdb_z_mysql_model_test.go b/database/gdb/gdb_z_mysql_model_test.go index 7af800d37..c68e9eeb5 100644 --- a/database/gdb/gdb_z_mysql_model_test.go +++ b/database/gdb/gdb_z_mysql_model_test.go @@ -1454,7 +1454,7 @@ func Test_Model_Where_ISNULL_2(t *testing.T) { "create_time > 0": nil, "id": g.Slice{1, 2, 3}, } - result, err := db.Model(table).WherePri(conditions).Order("id asc").All() + result, err := db.Model(table).Where(conditions).Order("id asc").All() t.AssertNil(err) t.Assert(len(result), 3) t.Assert(result[0]["id"].Int(), 1) @@ -1468,19 +1468,19 @@ func Test_Model_Where_OmitEmpty(t *testing.T) { conditions := g.Map{ "id < 4": "", } - result, err := db.Model(table).WherePri(conditions).Order("id asc").All() + result, err := db.Model(table).Where(conditions).Order("id desc").All() t.AssertNil(err) t.Assert(len(result), 3) - t.Assert(result[0]["id"].Int(), 1) + t.Assert(result[0]["id"].Int(), 3) }) gtest.C(t, func(t *gtest.T) { conditions := g.Map{ "id < 4": "", } - result, err := db.Model(table).WherePri(conditions).OmitEmpty().Order("id asc").All() + result, err := db.Model(table).Where(conditions).OmitEmpty().Order("id desc").All() t.AssertNil(err) - t.Assert(len(result), 3) - t.Assert(result[0]["id"].Int(), 1) + t.Assert(len(result), 10) + t.Assert(result[0]["id"].Int(), 10) }) }