mirror of
https://github.com/ent/ent.git
synced 2026-05-28 09:49:08 +03:00
entc/gen: remove multi storage support
This commit is contained in:
@@ -61,7 +61,6 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error)
|
||||
return nil, err
|
||||
}
|
||||
return NewClient(append(options, Driver(drv))...), nil
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported driver: %q", driverName)
|
||||
}
|
||||
|
||||
@@ -20,31 +20,24 @@ type Order func(*sql.Selector)
|
||||
|
||||
// Asc applies the given fields in ASC order.
|
||||
func Asc(fields ...string) Order {
|
||||
return Order(
|
||||
func(s *sql.Selector) {
|
||||
for _, f := range fields {
|
||||
s.OrderBy(sql.Asc(f))
|
||||
}
|
||||
},
|
||||
)
|
||||
return func(s *sql.Selector) {
|
||||
for _, f := range fields {
|
||||
s.OrderBy(sql.Asc(f))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Desc applies the given fields in DESC order.
|
||||
func Desc(fields ...string) Order {
|
||||
return Order(
|
||||
func(s *sql.Selector) {
|
||||
for _, f := range fields {
|
||||
s.OrderBy(sql.Desc(f))
|
||||
}
|
||||
},
|
||||
)
|
||||
return func(s *sql.Selector) {
|
||||
for _, f := range fields {
|
||||
s.OrderBy(sql.Desc(f))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Aggregate applies an aggregation step on the group-by traversal/selector.
|
||||
type Aggregate struct {
|
||||
// SQL the column wrapped with the aggregation function.
|
||||
SQL func(*sql.Selector) string
|
||||
}
|
||||
type Aggregate func(*sql.Selector) string
|
||||
|
||||
// As is a pseudo aggregation function for renaming another other functions with custom names. For example:
|
||||
//
|
||||
@@ -53,55 +46,43 @@ type Aggregate struct {
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func As(fn Aggregate, end string) Aggregate {
|
||||
return Aggregate{
|
||||
SQL: func(s *sql.Selector) string {
|
||||
return sql.As(fn.SQL(s), end)
|
||||
},
|
||||
return func(s *sql.Selector) string {
|
||||
return sql.As(fn(s), end)
|
||||
}
|
||||
}
|
||||
|
||||
// Count applies the "count" aggregation function on each group.
|
||||
func Count() Aggregate {
|
||||
return Aggregate{
|
||||
SQL: func(s *sql.Selector) string {
|
||||
return sql.Count("*")
|
||||
},
|
||||
return func(s *sql.Selector) string {
|
||||
return sql.Count("*")
|
||||
}
|
||||
}
|
||||
|
||||
// Max applies the "max" aggregation function on the given field of each group.
|
||||
func Max(field string) Aggregate {
|
||||
return Aggregate{
|
||||
SQL: func(s *sql.Selector) string {
|
||||
return sql.Max(s.C(field))
|
||||
},
|
||||
return func(s *sql.Selector) string {
|
||||
return sql.Max(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// Mean applies the "mean" aggregation function on the given field of each group.
|
||||
func Mean(field string) Aggregate {
|
||||
return Aggregate{
|
||||
SQL: func(s *sql.Selector) string {
|
||||
return sql.Avg(s.C(field))
|
||||
},
|
||||
return func(s *sql.Selector) string {
|
||||
return sql.Avg(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// Min applies the "min" aggregation function on the given field of each group.
|
||||
func Min(field string) Aggregate {
|
||||
return Aggregate{
|
||||
SQL: func(s *sql.Selector) string {
|
||||
return sql.Min(s.C(field))
|
||||
},
|
||||
return func(s *sql.Selector) string {
|
||||
return sql.Min(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// Sum applies the "sum" aggregation function on the given field of each group.
|
||||
func Sum(field string) Aggregate {
|
||||
return Aggregate{
|
||||
SQL: func(s *sql.Selector) string {
|
||||
return sql.Sum(s.C(field))
|
||||
},
|
||||
return func(s *sql.Selector) string {
|
||||
return sql.Sum(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,120 +22,109 @@ func ID(id int) predicate.Group {
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.Group {
|
||||
return predicate.Group(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
},
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.Group {
|
||||
return predicate.Group(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldID), id))
|
||||
},
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldID), id))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.Group {
|
||||
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(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldID), v...))
|
||||
},
|
||||
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(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldID), v...))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.Group {
|
||||
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(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldID), v...))
|
||||
},
|
||||
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(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldID), v...))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.Group {
|
||||
return predicate.Group(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldID), id))
|
||||
},
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldID), id))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.Group {
|
||||
return predicate.Group(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldID), id))
|
||||
},
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldID), id))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.Group {
|
||||
return predicate.Group(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldID), id))
|
||||
},
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldID), id))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.Group {
|
||||
return predicate.Group(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldID), id))
|
||||
},
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldID), id))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// MaxUsers applies equality check predicate on the "max_users" field. It's identical to MaxUsersEQ.
|
||||
func MaxUsers(v int) predicate.Group {
|
||||
return predicate.Group(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldMaxUsers), v))
|
||||
},
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldMaxUsers), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// MaxUsersEQ applies the EQ predicate on the "max_users" field.
|
||||
func MaxUsersEQ(v int) predicate.Group {
|
||||
return predicate.Group(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldMaxUsers), v))
|
||||
},
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldMaxUsers), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// MaxUsersNEQ applies the NEQ predicate on the "max_users" field.
|
||||
func MaxUsersNEQ(v int) predicate.Group {
|
||||
return predicate.Group(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldMaxUsers), v))
|
||||
},
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldMaxUsers), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -145,16 +134,15 @@ func MaxUsersIn(vs ...int) predicate.Group {
|
||||
for i := range v {
|
||||
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(vs) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldMaxUsers), v...))
|
||||
},
|
||||
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(vs) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldMaxUsers), v...))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -164,52 +152,47 @@ func MaxUsersNotIn(vs ...int) predicate.Group {
|
||||
for i := range v {
|
||||
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(vs) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldMaxUsers), v...))
|
||||
},
|
||||
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(vs) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldMaxUsers), v...))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// MaxUsersGT applies the GT predicate on the "max_users" field.
|
||||
func MaxUsersGT(v int) predicate.Group {
|
||||
return predicate.Group(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldMaxUsers), v))
|
||||
},
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldMaxUsers), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// MaxUsersGTE applies the GTE predicate on the "max_users" field.
|
||||
func MaxUsersGTE(v int) predicate.Group {
|
||||
return predicate.Group(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldMaxUsers), v))
|
||||
},
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldMaxUsers), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// MaxUsersLT applies the LT predicate on the "max_users" field.
|
||||
func MaxUsersLT(v int) predicate.Group {
|
||||
return predicate.Group(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldMaxUsers), v))
|
||||
},
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldMaxUsers), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// MaxUsersLTE applies the LTE predicate on the "max_users" field.
|
||||
func MaxUsersLTE(v int) predicate.Group {
|
||||
return predicate.Group(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldMaxUsers), v))
|
||||
},
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldMaxUsers), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ type GroupQuery struct {
|
||||
order []Order
|
||||
unique []string
|
||||
predicates []predicate.Group
|
||||
// intermediate queries.
|
||||
// intermediate query.
|
||||
sql *sql.Selector
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ func (gq *GroupQuery) Clone() *GroupQuery {
|
||||
order: append([]Order{}, gq.order...),
|
||||
unique: append([]string{}, gq.unique...),
|
||||
predicates: append([]predicate.Group{}, gq.predicates...),
|
||||
// clone intermediate queries.
|
||||
// clone intermediate query.
|
||||
sql: gq.sql.Clone(),
|
||||
}
|
||||
}
|
||||
@@ -343,7 +343,7 @@ type GroupGroupBy struct {
|
||||
config
|
||||
fields []string
|
||||
fns []Aggregate
|
||||
// intermediate queries.
|
||||
// intermediate query.
|
||||
sql *sql.Selector
|
||||
}
|
||||
|
||||
@@ -464,7 +464,7 @@ func (ggb *GroupGroupBy) sqlQuery() *sql.Selector {
|
||||
columns := make([]string, 0, len(ggb.fields)+len(ggb.fns))
|
||||
columns = append(columns, ggb.fields...)
|
||||
for _, fn := range ggb.fns {
|
||||
columns = append(columns, fn.SQL(selector))
|
||||
columns = append(columns, fn(selector))
|
||||
}
|
||||
return selector.Select(columns...).GroupBy(ggb.fields...)
|
||||
}
|
||||
|
||||
@@ -24,129 +24,117 @@ func ID(id int) predicate.Pet {
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldID), id))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldID), id))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
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(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldID), v...))
|
||||
},
|
||||
return predicate.Pet(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(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldID), v...))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
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(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldID), v...))
|
||||
},
|
||||
return predicate.Pet(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(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldID), v...))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldID), id))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldID), id))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldID), id))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldID), id))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldID), id))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldID), id))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldID), id))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldID), id))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// Age applies equality check predicate on the "age" field. It's identical to AgeEQ.
|
||||
func Age(v int) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldAge), v))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldAge), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// LicensedAt applies equality check predicate on the "licensed_at" field. It's identical to LicensedAtEQ.
|
||||
func LicensedAt(v time.Time) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldLicensedAt), v))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldLicensedAt), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// AgeEQ applies the EQ predicate on the "age" field.
|
||||
func AgeEQ(v int) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldAge), v))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldAge), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// AgeNEQ applies the NEQ predicate on the "age" field.
|
||||
func AgeNEQ(v int) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldAge), v))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldAge), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -156,16 +144,15 @@ func AgeIn(vs ...int) predicate.Pet {
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Pet(
|
||||
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(vs) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldAge), v...))
|
||||
},
|
||||
return predicate.Pet(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(vs) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldAge), v...))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -175,70 +162,63 @@ func AgeNotIn(vs ...int) predicate.Pet {
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Pet(
|
||||
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(vs) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldAge), v...))
|
||||
},
|
||||
return predicate.Pet(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(vs) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldAge), v...))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// AgeGT applies the GT predicate on the "age" field.
|
||||
func AgeGT(v int) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldAge), v))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldAge), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// AgeGTE applies the GTE predicate on the "age" field.
|
||||
func AgeGTE(v int) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldAge), v))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldAge), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// AgeLT applies the LT predicate on the "age" field.
|
||||
func AgeLT(v int) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldAge), v))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldAge), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// AgeLTE applies the LTE predicate on the "age" field.
|
||||
func AgeLTE(v int) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldAge), v))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldAge), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// LicensedAtEQ applies the EQ predicate on the "licensed_at" field.
|
||||
func LicensedAtEQ(v time.Time) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldLicensedAt), v))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldLicensedAt), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// LicensedAtNEQ applies the NEQ predicate on the "licensed_at" field.
|
||||
func LicensedAtNEQ(v time.Time) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldLicensedAt), v))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldLicensedAt), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -248,16 +228,15 @@ func LicensedAtIn(vs ...time.Time) predicate.Pet {
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Pet(
|
||||
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(vs) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldLicensedAt), v...))
|
||||
},
|
||||
return predicate.Pet(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(vs) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldLicensedAt), v...))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -267,102 +246,93 @@ func LicensedAtNotIn(vs ...time.Time) predicate.Pet {
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Pet(
|
||||
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(vs) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldLicensedAt), v...))
|
||||
},
|
||||
return predicate.Pet(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(vs) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldLicensedAt), v...))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// LicensedAtGT applies the GT predicate on the "licensed_at" field.
|
||||
func LicensedAtGT(v time.Time) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldLicensedAt), v))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldLicensedAt), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// LicensedAtGTE applies the GTE predicate on the "licensed_at" field.
|
||||
func LicensedAtGTE(v time.Time) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldLicensedAt), v))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldLicensedAt), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// LicensedAtLT applies the LT predicate on the "licensed_at" field.
|
||||
func LicensedAtLT(v time.Time) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldLicensedAt), v))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldLicensedAt), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// LicensedAtLTE applies the LTE predicate on the "licensed_at" field.
|
||||
func LicensedAtLTE(v time.Time) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldLicensedAt), v))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldLicensedAt), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// LicensedAtIsNil applies the IsNil predicate on the "licensed_at" field.
|
||||
func LicensedAtIsNil() predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.IsNull(s.C(FieldLicensedAt)))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.IsNull(s.C(FieldLicensedAt)))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// LicensedAtNotNil applies the NotNil predicate on the "licensed_at" field.
|
||||
func LicensedAtNotNil() predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.NotNull(s.C(FieldLicensedAt)))
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
s.Where(sql.NotNull(s.C(FieldLicensedAt)))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// HasOwner applies the HasEdge predicate on the "owner" edge.
|
||||
func HasOwner() predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
step := sql.NewStep(
|
||||
sql.From(Table, FieldID),
|
||||
sql.To(OwnerTable, FieldID),
|
||||
sql.Edge(sql.M2O, true, OwnerTable, OwnerColumn),
|
||||
)
|
||||
sql.HasNeighbors(s, step)
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
step := sql.NewStep(
|
||||
sql.From(Table, FieldID),
|
||||
sql.To(OwnerTable, FieldID),
|
||||
sql.Edge(sql.M2O, true, OwnerTable, OwnerColumn),
|
||||
)
|
||||
sql.HasNeighbors(s, step)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// HasOwnerWith applies the HasEdge predicate on the "owner" edge with a given conditions (other predicates).
|
||||
func HasOwnerWith(preds ...predicate.User) predicate.Pet {
|
||||
return predicate.Pet(
|
||||
func(s *sql.Selector) {
|
||||
step := sql.NewStep(
|
||||
sql.From(Table, FieldID),
|
||||
sql.To(OwnerInverseTable, FieldID),
|
||||
sql.Edge(sql.M2O, true, OwnerTable, OwnerColumn),
|
||||
)
|
||||
sql.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
},
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
step := sql.NewStep(
|
||||
sql.From(Table, FieldID),
|
||||
sql.To(OwnerInverseTable, FieldID),
|
||||
sql.Edge(sql.M2O, true, OwnerTable, OwnerColumn),
|
||||
)
|
||||
sql.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ type PetQuery struct {
|
||||
order []Order
|
||||
unique []string
|
||||
predicates []predicate.Pet
|
||||
// intermediate queries.
|
||||
// intermediate query.
|
||||
sql *sql.Selector
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ func (pq *PetQuery) Clone() *PetQuery {
|
||||
order: append([]Order{}, pq.order...),
|
||||
unique: append([]string{}, pq.unique...),
|
||||
predicates: append([]predicate.Pet{}, pq.predicates...),
|
||||
// clone intermediate queries.
|
||||
// clone intermediate query.
|
||||
sql: pq.sql.Clone(),
|
||||
}
|
||||
}
|
||||
@@ -356,7 +356,7 @@ type PetGroupBy struct {
|
||||
config
|
||||
fields []string
|
||||
fns []Aggregate
|
||||
// intermediate queries.
|
||||
// intermediate query.
|
||||
sql *sql.Selector
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ func (pgb *PetGroupBy) sqlQuery() *sql.Selector {
|
||||
columns := make([]string, 0, len(pgb.fields)+len(pgb.fns))
|
||||
columns = append(columns, pgb.fields...)
|
||||
for _, fn := range pgb.fns {
|
||||
columns = append(columns, fn.SQL(selector))
|
||||
columns = append(columns, fn(selector))
|
||||
}
|
||||
return selector.Select(columns...).GroupBy(pgb.fields...)
|
||||
}
|
||||
|
||||
@@ -22,120 +22,109 @@ func ID(id int) predicate.User {
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldID), id))
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldID), id))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.User {
|
||||
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(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldID), v...))
|
||||
},
|
||||
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(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldID), v...))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.User {
|
||||
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(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldID), v...))
|
||||
},
|
||||
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(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldID), v...))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldID), id))
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldID), id))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldID), id))
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldID), id))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldID), id))
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldID), id))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldID), id))
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldID), id))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||
func Name(v string) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldName), v))
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldName), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldName), v))
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldName), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// NameNEQ applies the NEQ predicate on the "name" field.
|
||||
func NameNEQ(v string) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldName), v))
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldName), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -145,16 +134,15 @@ func NameIn(vs ...string) predicate.User {
|
||||
for i := range v {
|
||||
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(vs) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldName), v...))
|
||||
},
|
||||
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(vs) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldName), v...))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -164,161 +152,147 @@ func NameNotIn(vs ...string) predicate.User {
|
||||
for i := range v {
|
||||
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(vs) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldName), v...))
|
||||
},
|
||||
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(vs) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldName), v...))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// NameGT applies the GT predicate on the "name" field.
|
||||
func NameGT(v string) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldName), v))
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldName), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// NameGTE applies the GTE predicate on the "name" field.
|
||||
func NameGTE(v string) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldName), v))
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldName), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// NameLT applies the LT predicate on the "name" field.
|
||||
func NameLT(v string) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldName), v))
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldName), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// NameLTE applies the LTE predicate on the "name" field.
|
||||
func NameLTE(v string) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldName), v))
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldName), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// NameContains applies the Contains predicate on the "name" field.
|
||||
func NameContains(v string) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.Contains(s.C(FieldName), v))
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
s.Where(sql.Contains(s.C(FieldName), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
|
||||
func NameHasPrefix(v string) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.HasPrefix(s.C(FieldName), v))
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
s.Where(sql.HasPrefix(s.C(FieldName), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
|
||||
func NameHasSuffix(v string) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.HasSuffix(s.C(FieldName), v))
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
s.Where(sql.HasSuffix(s.C(FieldName), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||
func NameEqualFold(v string) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.EqualFold(s.C(FieldName), v))
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
s.Where(sql.EqualFold(s.C(FieldName), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// NameContainsFold applies the ContainsFold predicate on the "name" field.
|
||||
func NameContainsFold(v string) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
s.Where(sql.ContainsFold(s.C(FieldName), v))
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
s.Where(sql.ContainsFold(s.C(FieldName), v))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// HasPets applies the HasEdge predicate on the "pets" edge.
|
||||
func HasPets() predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
step := sql.NewStep(
|
||||
sql.From(Table, FieldID),
|
||||
sql.To(PetsTable, FieldID),
|
||||
sql.Edge(sql.O2M, false, PetsTable, PetsColumn),
|
||||
)
|
||||
sql.HasNeighbors(s, step)
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
step := sql.NewStep(
|
||||
sql.From(Table, FieldID),
|
||||
sql.To(PetsTable, FieldID),
|
||||
sql.Edge(sql.O2M, false, PetsTable, PetsColumn),
|
||||
)
|
||||
sql.HasNeighbors(s, step)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// HasPetsWith applies the HasEdge predicate on the "pets" edge with a given conditions (other predicates).
|
||||
func HasPetsWith(preds ...predicate.Pet) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
step := sql.NewStep(
|
||||
sql.From(Table, FieldID),
|
||||
sql.To(PetsInverseTable, FieldID),
|
||||
sql.Edge(sql.O2M, false, PetsTable, PetsColumn),
|
||||
)
|
||||
sql.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
step := sql.NewStep(
|
||||
sql.From(Table, FieldID),
|
||||
sql.To(PetsInverseTable, FieldID),
|
||||
sql.Edge(sql.O2M, false, PetsTable, PetsColumn),
|
||||
)
|
||||
sql.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// HasFriends applies the HasEdge predicate on the "friends" edge.
|
||||
func HasFriends() predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
step := sql.NewStep(
|
||||
sql.From(Table, FieldID),
|
||||
sql.To(FriendsTable, FieldID),
|
||||
sql.Edge(sql.M2M, false, FriendsTable, FriendsPrimaryKey...),
|
||||
)
|
||||
sql.HasNeighbors(s, step)
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
step := sql.NewStep(
|
||||
sql.From(Table, FieldID),
|
||||
sql.To(FriendsTable, FieldID),
|
||||
sql.Edge(sql.M2M, false, FriendsTable, FriendsPrimaryKey...),
|
||||
)
|
||||
sql.HasNeighbors(s, step)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// HasFriendsWith applies the HasEdge predicate on the "friends" edge with a given conditions (other predicates).
|
||||
func HasFriendsWith(preds ...predicate.User) predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
step := sql.NewStep(
|
||||
sql.From(Table, FieldID),
|
||||
sql.To(Table, FieldID),
|
||||
sql.Edge(sql.M2M, false, FriendsTable, FriendsPrimaryKey...),
|
||||
)
|
||||
sql.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
},
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
step := sql.NewStep(
|
||||
sql.From(Table, FieldID),
|
||||
sql.To(Table, FieldID),
|
||||
sql.Edge(sql.M2M, false, FriendsTable, FriendsPrimaryKey...),
|
||||
)
|
||||
sql.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ type UserQuery struct {
|
||||
order []Order
|
||||
unique []string
|
||||
predicates []predicate.User
|
||||
// intermediate queries.
|
||||
// intermediate query.
|
||||
sql *sql.Selector
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ func (uq *UserQuery) Clone() *UserQuery {
|
||||
order: append([]Order{}, uq.order...),
|
||||
unique: append([]string{}, uq.unique...),
|
||||
predicates: append([]predicate.User{}, uq.predicates...),
|
||||
// clone intermediate queries.
|
||||
// clone intermediate query.
|
||||
sql: uq.sql.Clone(),
|
||||
}
|
||||
}
|
||||
@@ -368,7 +368,7 @@ type UserGroupBy struct {
|
||||
config
|
||||
fields []string
|
||||
fns []Aggregate
|
||||
// intermediate queries.
|
||||
// intermediate query.
|
||||
sql *sql.Selector
|
||||
}
|
||||
|
||||
@@ -489,7 +489,7 @@ func (ugb *UserGroupBy) sqlQuery() *sql.Selector {
|
||||
columns := make([]string, 0, len(ugb.fields)+len(ugb.fns))
|
||||
columns = append(columns, ugb.fields...)
|
||||
for _, fn := range ugb.fns {
|
||||
columns = append(columns, fn.SQL(selector))
|
||||
columns = append(columns, fn(selector))
|
||||
}
|
||||
return selector.Select(columns...).GroupBy(ugb.fields...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user