entc/gen: rename <type>.Order to <type>.OrderOption (#3468)

Also, avoid generting predicate without op in case a field named: order_option
This commit is contained in:
Ariel Mashraki
2023-04-11 08:23:29 +03:00
committed by GitHub
parent 065cb9f9ff
commit da69615bd0
308 changed files with 2837 additions and 1561 deletions

View File

@@ -61,26 +61,26 @@ func ValidColumn(column string) bool {
return false
}
// Order defines the ordering method for the Card queries.
type Order func(*sql.Selector)
// OrderOption defines the ordering options for the Card queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) Order {
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByExpired orders the results by the expired field.
func ByExpired(opts ...sql.OrderTermOption) Order {
func ByExpired(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldExpired, opts...).ToFunc()
}
// ByNumber orders the results by the number field.
func ByNumber(opts ...sql.OrderTermOption) Order {
func ByNumber(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldNumber, opts...).ToFunc()
}
// ByOwnerField orders the results by owner field.
func ByOwnerField(field string, opts ...sql.OrderTermOption) Order {
func ByOwnerField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newOwnerStep(), sql.OrderByField(field, opts...))
}

View File

@@ -23,7 +23,7 @@ import (
type CardQuery struct {
config
ctx *QueryContext
order []card.Order
order []card.OrderOption
inters []Interceptor
predicates []predicate.Card
withOwner *UserQuery
@@ -59,7 +59,7 @@ func (cq *CardQuery) Unique(unique bool) *CardQuery {
}
// Order specifies how the records should be ordered.
func (cq *CardQuery) Order(o ...card.Order) *CardQuery {
func (cq *CardQuery) Order(o ...card.OrderOption) *CardQuery {
cq.order = append(cq.order, o...)
return cq
}
@@ -275,7 +275,7 @@ func (cq *CardQuery) Clone() *CardQuery {
return &CardQuery{
config: cq.config,
ctx: cq.ctx.Clone(),
order: append([]card.Order{}, cq.order...),
order: append([]card.OrderOption{}, cq.order...),
inters: append([]Interceptor{}, cq.inters...),
predicates: append([]predicate.Card{}, cq.predicates...),
withOwner: cq.withOwner.Clone(),

View File

@@ -50,26 +50,26 @@ func ValidColumn(column string) bool {
return false
}
// Order defines the ordering method for the User queries.
type Order func(*sql.Selector)
// OrderOption defines the ordering options for the User queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) Order {
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByAge orders the results by the age field.
func ByAge(opts ...sql.OrderTermOption) Order {
func ByAge(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAge, opts...).ToFunc()
}
// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) Order {
func ByName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldName, opts...).ToFunc()
}
// ByCardField orders the results by card field.
func ByCardField(field string, opts ...sql.OrderTermOption) Order {
func ByCardField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newCardStep(), sql.OrderByField(field, opts...))
}

View File

@@ -24,7 +24,7 @@ import (
type UserQuery struct {
config
ctx *QueryContext
order []user.Order
order []user.OrderOption
inters []Interceptor
predicates []predicate.User
withCard *CardQuery
@@ -59,7 +59,7 @@ func (uq *UserQuery) Unique(unique bool) *UserQuery {
}
// Order specifies how the records should be ordered.
func (uq *UserQuery) Order(o ...user.Order) *UserQuery {
func (uq *UserQuery) Order(o ...user.OrderOption) *UserQuery {
uq.order = append(uq.order, o...)
return uq
}
@@ -275,7 +275,7 @@ func (uq *UserQuery) Clone() *UserQuery {
return &UserQuery{
config: uq.config,
ctx: uq.ctx.Clone(),
order: append([]user.Order{}, uq.order...),
order: append([]user.OrderOption{}, uq.order...),
inters: append([]Interceptor{}, uq.inters...),
predicates: append([]predicate.User{}, uq.predicates...),
withCard: uq.withCard.Clone(),