mirror of
https://github.com/ent/ent.git
synced 2026-05-28 09:49:08 +03:00
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:
@@ -89,41 +89,41 @@ var (
|
||||
DefaultCreatedAt func() time.Time
|
||||
)
|
||||
|
||||
// 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()
|
||||
}
|
||||
|
||||
// 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()
|
||||
}
|
||||
|
||||
// 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()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) Order {
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByInHook orders the results by the in_hook field.
|
||||
func ByInHook(opts ...sql.OrderTermOption) Order {
|
||||
func ByInHook(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldInHook, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByExpiredAt orders the results by the expired_at field.
|
||||
func ByExpiredAt(opts ...sql.OrderTermOption) Order {
|
||||
func ByExpiredAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldExpiredAt, 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...))
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -159,11 +159,11 @@ func (f TraverseUser) Traverse(ctx context.Context, q ent.Query) error {
|
||||
func NewQuery(q ent.Query) (Query, error) {
|
||||
switch q := q.(type) {
|
||||
case *ent.CardQuery:
|
||||
return &query[*ent.CardQuery, predicate.Card, card.Order]{typ: ent.TypeCard, tq: q}, nil
|
||||
return &query[*ent.CardQuery, predicate.Card, card.OrderOption]{typ: ent.TypeCard, tq: q}, nil
|
||||
case *ent.PetQuery:
|
||||
return &query[*ent.PetQuery, predicate.Pet, pet.Order]{typ: ent.TypePet, tq: q}, nil
|
||||
return &query[*ent.PetQuery, predicate.Pet, pet.OrderOption]{typ: ent.TypePet, tq: q}, nil
|
||||
case *ent.UserQuery:
|
||||
return &query[*ent.UserQuery, predicate.User, user.Order]{typ: ent.TypeUser, tq: q}, nil
|
||||
return &query[*ent.UserQuery, predicate.User, user.OrderOption]{typ: ent.TypeUser, tq: q}, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown query type %T", q)
|
||||
}
|
||||
|
||||
@@ -72,26 +72,26 @@ var (
|
||||
Interceptors [1]ent.Interceptor
|
||||
)
|
||||
|
||||
// Order defines the ordering method for the Pet queries.
|
||||
type Order func(*sql.Selector)
|
||||
// OrderOption defines the ordering options for the Pet 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()
|
||||
}
|
||||
|
||||
// ByDeleteTime orders the results by the delete_time field.
|
||||
func ByDeleteTime(opts ...sql.OrderTermOption) Order {
|
||||
func ByDeleteTime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDeleteTime, 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()
|
||||
}
|
||||
|
||||
// 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...))
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
type PetQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []pet.Order
|
||||
order []pet.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.Pet
|
||||
withOwner *UserQuery
|
||||
@@ -59,7 +59,7 @@ func (pq *PetQuery) Unique(unique bool) *PetQuery {
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (pq *PetQuery) Order(o ...pet.Order) *PetQuery {
|
||||
func (pq *PetQuery) Order(o ...pet.OrderOption) *PetQuery {
|
||||
pq.order = append(pq.order, o...)
|
||||
return pq
|
||||
}
|
||||
@@ -275,7 +275,7 @@ func (pq *PetQuery) Clone() *PetQuery {
|
||||
return &PetQuery{
|
||||
config: pq.config,
|
||||
ctx: pq.ctx.Clone(),
|
||||
order: append([]pet.Order{}, pq.order...),
|
||||
order: append([]pet.OrderOption{}, pq.order...),
|
||||
inters: append([]Interceptor{}, pq.inters...),
|
||||
predicates: append([]predicate.Pet{}, pq.predicates...),
|
||||
withOwner: pq.withOwner.Clone(),
|
||||
|
||||
@@ -109,83 +109,83 @@ var (
|
||||
DefaultActive bool
|
||||
)
|
||||
|
||||
// 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()
|
||||
}
|
||||
|
||||
// ByVersion orders the results by the version field.
|
||||
func ByVersion(opts ...sql.OrderTermOption) Order {
|
||||
func ByVersion(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldVersion, 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()
|
||||
}
|
||||
|
||||
// ByWorth orders the results by the worth field.
|
||||
func ByWorth(opts ...sql.OrderTermOption) Order {
|
||||
func ByWorth(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldWorth, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPassword orders the results by the password field.
|
||||
func ByPassword(opts ...sql.OrderTermOption) Order {
|
||||
func ByPassword(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPassword, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByActive orders the results by the active field.
|
||||
func ByActive(opts ...sql.OrderTermOption) Order {
|
||||
func ByActive(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldActive, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCardsCount orders the results by cards count.
|
||||
func ByCardsCount(opts ...sql.OrderTermOption) Order {
|
||||
func ByCardsCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newCardsStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByCards orders the results by cards terms.
|
||||
func ByCards(term sql.OrderTerm, terms ...sql.OrderTerm) Order {
|
||||
func ByCards(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newCardsStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByPetsCount orders the results by pets count.
|
||||
func ByPetsCount(opts ...sql.OrderTermOption) Order {
|
||||
func ByPetsCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newPetsStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByPets orders the results by pets terms.
|
||||
func ByPets(term sql.OrderTerm, terms ...sql.OrderTerm) Order {
|
||||
func ByPets(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newPetsStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByFriendsCount orders the results by friends count.
|
||||
func ByFriendsCount(opts ...sql.OrderTermOption) Order {
|
||||
func ByFriendsCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newFriendsStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByFriends orders the results by friends terms.
|
||||
func ByFriends(term sql.OrderTerm, terms ...sql.OrderTerm) Order {
|
||||
func ByFriends(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newFriendsStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByBestFriendField orders the results by best_friend field.
|
||||
func ByBestFriendField(field string, opts ...sql.OrderTermOption) Order {
|
||||
func ByBestFriendField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newBestFriendStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
type UserQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []user.Order
|
||||
order []user.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.User
|
||||
withCards *CardQuery
|
||||
@@ -64,7 +64,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
|
||||
}
|
||||
@@ -346,7 +346,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...),
|
||||
withCards: uq.withCards.Clone(),
|
||||
|
||||
Reference in New Issue
Block a user