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

@@ -72,49 +72,49 @@ 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()
}
// 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()
}
// BySpouseField orders the results by spouse field.
func BySpouseField(field string, opts ...sql.OrderTermOption) Order {
func BySpouseField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newSpouseStep(), sql.OrderByField(field, opts...))
}
}
// ByFollowersCount orders the results by followers count.
func ByFollowersCount(opts ...sql.OrderTermOption) Order {
func ByFollowersCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newFollowersStep(), opts...)
}
}
// ByFollowers orders the results by followers terms.
func ByFollowers(term sql.OrderTerm, terms ...sql.OrderTerm) Order {
func ByFollowers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newFollowersStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByFollowingCount orders the results by following count.
func ByFollowingCount(opts ...sql.OrderTermOption) Order {
func ByFollowingCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newFollowingStep(), opts...)
}
}
// ByFollowing orders the results by following terms.
func ByFollowing(term sql.OrderTerm, terms ...sql.OrderTerm) Order {
func ByFollowing(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newFollowingStep(), append([]sql.OrderTerm{term}, terms...)...)
}

View File

@@ -23,7 +23,7 @@ import (
type UserQuery struct {
config
ctx *QueryContext
order []user.Order
order []user.OrderOption
inters []Interceptor
predicates []predicate.User
withSpouse *UserQuery
@@ -61,7 +61,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
}
@@ -321,7 +321,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...),
withSpouse: uq.withSpouse.Clone(),