Skip to content

Commit

Permalink
Merge pull request #7 from lifegit/v2
Browse files Browse the repository at this point in the history
fix  name
  • Loading branch information
lifegit authored Sep 4, 2021
2 parents 0e4aede + badf8b3 commit 7026984
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions pkg/fire/fire.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 ===
Expand Down
8 changes: 4 additions & 4 deletions pkg/fire/fire_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down

0 comments on commit 7026984

Please sign in to comment.