mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
dialect/sql: add support for selector in the notIn predicate (#861)
* `notIn` support Selector like `in` * `notIn` args check
This commit is contained in:
@@ -1054,10 +1054,17 @@ func NotIn(col string, args ...interface{}) *Predicate {
|
|||||||
|
|
||||||
// NotIn appends the `Not IN` predicate.
|
// NotIn appends the `Not IN` predicate.
|
||||||
func (p *Predicate) NotIn(col string, args ...interface{}) *Predicate {
|
func (p *Predicate) NotIn(col string, args ...interface{}) *Predicate {
|
||||||
|
if len(args) == 0 {
|
||||||
|
return p
|
||||||
|
}
|
||||||
return p.Append(func(b *Builder) {
|
return p.Append(func(b *Builder) {
|
||||||
b.Ident(col).WriteOp(OpNotIn)
|
b.Ident(col).WriteOp(OpNotIn)
|
||||||
b.Nested(func(b *Builder) {
|
b.Nested(func(b *Builder) {
|
||||||
b.Args(args...)
|
if s, ok := args[0].(*Selector); ok {
|
||||||
|
b.Join(s)
|
||||||
|
} else {
|
||||||
|
b.Args(args...)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user