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

@@ -47,28 +47,28 @@ func ValidColumn(column string) bool {
return false
}
// Order defines the ordering method for the City queries.
type Order func(*sql.Selector)
// OrderOption defines the ordering options for the City 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()
}
// ByStreetsCount orders the results by streets count.
func ByStreetsCount(opts ...sql.OrderTermOption) Order {
func ByStreetsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newStreetsStep(), opts...)
}
}
// ByStreets orders the results by streets terms.
func ByStreets(term sql.OrderTerm, terms ...sql.OrderTerm) Order {
func ByStreets(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newStreetsStep(), append([]sql.OrderTerm{term}, terms...)...)
}

View File

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

View File

@@ -58,21 +58,21 @@ func ValidColumn(column string) bool {
return false
}
// Order defines the ordering method for the Street queries.
type Order func(*sql.Selector)
// OrderOption defines the ordering options for the Street 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()
}
// ByCityField orders the results by city field.
func ByCityField(field string, opts ...sql.OrderTermOption) Order {
func ByCityField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newCityStep(), sql.OrderByField(field, opts...))
}

View File

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