ent/gen: remove unnecessary if block in IN predicates (#2758)

This commit is contained in:
Ariel Mashraki
2022-07-15 10:30:23 +03:00
committed by GitHub
parent 1c6ba55f9c
commit 047b804dcd
95 changed files with 0 additions and 3512 deletions

View File

@@ -120,12 +120,6 @@ func ModelIn(vs ...string) predicate.Car {
v[i] = vs[i]
}
return predicate.Car(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldModel), v...))
})
}
@@ -137,12 +131,6 @@ func ModelNotIn(vs ...string) predicate.Car {
v[i] = vs[i]
}
return predicate.Car(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldModel), v...))
})
}
@@ -231,12 +219,6 @@ func RegisteredAtIn(vs ...time.Time) predicate.Car {
v[i] = vs[i]
}
return predicate.Car(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldRegisteredAt), v...))
})
}
@@ -248,12 +230,6 @@ func RegisteredAtNotIn(vs ...time.Time) predicate.Car {
v[i] = vs[i]
}
return predicate.Car(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldRegisteredAt), v...))
})
}

View File

@@ -111,12 +111,6 @@ func NameIn(vs ...string) predicate.Group {
v[i] = vs[i]
}
return predicate.Group(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldName), v...))
})
}
@@ -128,12 +122,6 @@ func NameNotIn(vs ...string) predicate.Group {
v[i] = vs[i]
}
return predicate.Group(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldName), v...))
})
}

View File

@@ -118,12 +118,6 @@ func AgeIn(vs ...int) predicate.User {
v[i] = vs[i]
}
return predicate.User(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldAge), v...))
})
}
@@ -135,12 +129,6 @@ func AgeNotIn(vs ...int) predicate.User {
v[i] = vs[i]
}
return predicate.User(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldAge), v...))
})
}
@@ -194,12 +182,6 @@ func NameIn(vs ...string) predicate.User {
v[i] = vs[i]
}
return predicate.User(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldName), v...))
})
}
@@ -211,12 +193,6 @@ func NameNotIn(vs ...string) predicate.User {
v[i] = vs[i]
}
return predicate.User(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldName), v...))
})
}