dialect/sql/builder: make sql.NotIn() with empty args fallback to NOT FALSE (#2757)

* dialect/sql/builder: make sql.NotIn() with empty args fallback to False()

This is basically the identical change to #2735, but for NotIn().

This bug currently prevents anyone using NotIn() from upgrading from v0.10.x to v0.11.x

* Update go.sum

untidy

* feedback
This commit is contained in:
Andy Day
2022-07-18 20:36:39 -07:00
committed by GitHub
parent 42b68cb9fc
commit 8beaef87ba
2 changed files with 13 additions and 1 deletions

View File

@@ -1587,8 +1587,10 @@ func NotIn(col string, args ...interface{}) *Predicate {
// NotIn appends the `Not IN` predicate.
func (p *Predicate) NotIn(col string, args ...interface{}) *Predicate {
// If no arguments were provided, append the NOT FALSE constant, since
// we cannot apply "NOT IN ()". This will make this predicate truthy.
if len(args) == 0 {
return p
return Not(p.False())
}
return p.Append(func(b *Builder) {
b.Ident(col).WriteOp(OpNotIn)