mirror of
https://github.com/ent/ent.git
synced 2026-03-05 19:35:23 +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:
@@ -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...)...)
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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...))
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user