diff --git a/pkg/fire/fire.go b/pkg/fire/fire.go index 61dbeef..9ca2f0e 100644 --- a/pkg/fire/fire.go +++ b/pkg/fire/fire.go @@ -95,7 +95,7 @@ func (d *Fire) Allow(param Param, allow Allow) *Fire { return tx } -func toCamel2Case(m map[string]interface{}) { +func toCamel2Case(m map[string]interface{}) { for key, value := range m { if !strings.Contains(key, "_") { delete(m, key) @@ -121,11 +121,11 @@ func Camel2Case(name string) string { type CompareType string const ( - CompareEqual CompareType = "=" - CompareAboutEqual CompareType = ">=" - CompareAbout CompareType = ">" - CompareLessEqual CompareType = "<=" - CompareLess CompareType = "<" + CompareEqual CompareType = "=" + CompareGreaterEqual CompareType = ">=" + CompareGreater CompareType = ">" + CompareSmallerEqual CompareType = "<=" + CompareSmaller CompareType = "<" ) // === where === diff --git a/pkg/fire/fire_test.go b/pkg/fire/fire_test.go index 17bd116..1f7722c 100644 --- a/pkg/fire/fire_test.go +++ b/pkg/fire/fire_test.go @@ -29,16 +29,16 @@ func TestFormatColumn(t *testing.T) { } func TestWhereCompare(t *testing.T) { - DBDryRun.WhereCompare("age", 18, fire.CompareAboutEqual).Model(User{}).Take(&User{}) + DBDryRun.WhereCompare("age", 18, fire.CompareGreaterEqual).Model(User{}).Take(&User{}) assert.Equal(t, DBDryRun.Logger.(*Diary).LastSql(), "SELECT * FROM `user` WHERE `age` >= 18 LIMIT 1") - DBDryRun.WhereCompare("age", 18, fire.CompareAbout).Model(User{}).Take(&User{}) + DBDryRun.WhereCompare("age", 18, fire.CompareGreater).Model(User{}).Take(&User{}) assert.Equal(t, DBDryRun.Logger.(*Diary).LastSql(), "SELECT * FROM `user` WHERE `age` > 18 LIMIT 1") - DBDryRun.WhereCompare("age", 18, fire.CompareLessEqual).Model(User{}).Take(&User{}) + DBDryRun.WhereCompare("age", 18, fire.CompareSmallerEqual).Model(User{}).Take(&User{}) assert.Equal(t, DBDryRun.Logger.(*Diary).LastSql(), "SELECT * FROM `user` WHERE `age` <= 18 LIMIT 1") - DBDryRun.WhereCompare("age", 18, fire.CompareLess).Model(User{}).Take(&User{}) + DBDryRun.WhereCompare("age", 18, fire.CompareSmaller).Model(User{}).Take(&User{}) assert.Equal(t, DBDryRun.Logger.(*Diary).LastSql(), "SELECT * FROM `user` WHERE `age` < 18 LIMIT 1") }