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 Car queries.
type Order func(*sql.Selector)
// OrderOption defines the ordering options for the Car 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()
}
// ByModel orders the results by the model field.
func ByModel(opts ...sql.OrderTermOption) Order {
func ByModel(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldModel, opts...).ToFunc()
}
// ByRegisteredAt orders the results by the registered_at field.
func ByRegisteredAt(opts ...sql.OrderTermOption) Order {
func ByRegisteredAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRegisteredAt, 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 CarQuery struct {
config
ctx *QueryContext
order []car.Order
order []car.OrderOption
inters []Interceptor
predicates []predicate.Car
withOwner *UserQuery
@@ -59,7 +59,7 @@ func (cq *CarQuery) Unique(unique bool) *CarQuery {
}
// Order specifies how the records should be ordered.
func (cq *CarQuery) Order(o ...car.Order) *CarQuery {
func (cq *CarQuery) Order(o ...car.OrderOption) *CarQuery {
cq.order = append(cq.order, o...)
return cq
}
@@ -275,7 +275,7 @@ func (cq *CarQuery) Clone() *CarQuery {
return &CarQuery{
config: cq.config,
ctx: cq.ctx.Clone(),
order: append([]car.Order{}, cq.order...),
order: append([]car.OrderOption{}, cq.order...),
inters: append([]Interceptor{}, cq.inters...),
predicates: append([]predicate.Car{}, cq.predicates...),
withOwner: cq.withOwner.Clone(),

View File

@@ -56,28 +56,28 @@ var (
NameValidator func(string) error
)
// Order defines the ordering method for the Group queries.
type Order func(*sql.Selector)
// OrderOption defines the ordering options for the Group 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()
}
// ByUsersCount orders the results by users count.
func ByUsersCount(opts ...sql.OrderTermOption) Order {
func ByUsersCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newUsersStep(), opts...)
}
}
// ByUsers orders the results by users terms.
func ByUsers(term sql.OrderTerm, terms ...sql.OrderTerm) Order {
func ByUsers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newUsersStep(), append([]sql.OrderTerm{term}, terms...)...)
}

View File

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

View File

@@ -70,47 +70,47 @@ var (
DefaultName string
)
// 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()
}
// ByCarsCount orders the results by cars count.
func ByCarsCount(opts ...sql.OrderTermOption) Order {
func ByCarsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newCarsStep(), opts...)
}
}
// ByCars orders the results by cars terms.
func ByCars(term sql.OrderTerm, terms ...sql.OrderTerm) Order {
func ByCars(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newCarsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByGroupsCount orders the results by groups count.
func ByGroupsCount(opts ...sql.OrderTermOption) Order {
func ByGroupsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newGroupsStep(), opts...)
}
}
// ByGroups orders the results by groups terms.
func ByGroups(term sql.OrderTerm, terms ...sql.OrderTerm) Order {
func ByGroups(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newGroupsStep(), append([]sql.OrderTerm{term}, terms...)...)
}

View File

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