Fix regression in db.Not introduced in 940358e.
This commit is contained in:
parent
d81ae6f701
commit
72a2252049
@ -153,11 +153,6 @@ func Not(exprs ...Expression) Expression {
|
|||||||
if len(exprs) == 0 {
|
if len(exprs) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if len(exprs) == 1 {
|
|
||||||
if andCondition, ok := exprs[0].(AndConditions); ok {
|
|
||||||
exprs = andCondition.Exprs
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NotConditions{Exprs: exprs}
|
return NotConditions{Exprs: exprs}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +105,13 @@ func TestWhere(t *testing.T) {
|
|||||||
"SELECT * FROM `users` WHERE (`users`.`id` <> ? AND NOT `score` <= ?)",
|
"SELECT * FROM `users` WHERE (`users`.`id` <> ? AND NOT `score` <= ?)",
|
||||||
[]interface{}{"1", 100},
|
[]interface{}{"1", 100},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
[]clause.Interface{clause.Select{}, clause.From{}, clause.Where{
|
||||||
|
Exprs: []clause.Expression{clause.Not(clause.And(clause.Eq{Column: clause.PrimaryColumn, Value: "1"}, clause.Expr{SQL: "`score` <= ?", Vars: []interface{}{100}, WithoutParentheses: false}))},
|
||||||
|
}},
|
||||||
|
"SELECT * FROM `users` WHERE NOT (`users`.`id` = ? AND `score` <= ?)",
|
||||||
|
[]interface{}{"1", 100},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for idx, result := range results {
|
for idx, result := range results {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user