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

@@ -53,33 +53,33 @@ func ValidColumn(column string) bool {
return false
}
// Order defines the ordering method for the Node queries.
type Order func(*sql.Selector)
// OrderOption defines the ordering options for the Node 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()
}
// ByValue orders the results by the value field.
func ByValue(opts ...sql.OrderTermOption) Order {
func ByValue(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldValue, opts...).ToFunc()
}
// ByPrevID orders the results by the prev_id field.
func ByPrevID(opts ...sql.OrderTermOption) Order {
func ByPrevID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPrevID, opts...).ToFunc()
}
// ByPrevField orders the results by prev field.
func ByPrevField(field string, opts ...sql.OrderTermOption) Order {
func ByPrevField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newPrevStep(), sql.OrderByField(field, opts...))
}
}
// ByNextField orders the results by next field.
func ByNextField(field string, opts ...sql.OrderTermOption) Order {
func ByNextField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newNextStep(), sql.OrderByField(field, opts...))
}

View File

@@ -23,7 +23,7 @@ import (
type NodeQuery struct {
config
ctx *QueryContext
order []node.Order
order []node.OrderOption
inters []Interceptor
predicates []predicate.Node
withPrev *NodeQuery
@@ -59,7 +59,7 @@ func (nq *NodeQuery) Unique(unique bool) *NodeQuery {
}
// Order specifies how the records should be ordered.
func (nq *NodeQuery) Order(o ...node.Order) *NodeQuery {
func (nq *NodeQuery) Order(o ...node.OrderOption) *NodeQuery {
nq.order = append(nq.order, o...)
return nq
}
@@ -297,7 +297,7 @@ func (nq *NodeQuery) Clone() *NodeQuery {
return &NodeQuery{
config: nq.config,
ctx: nq.ctx.Clone(),
order: append([]node.Order{}, nq.order...),
order: append([]node.OrderOption{}, nq.order...),
inters: append([]Interceptor{}, nq.inters...),
predicates: append([]predicate.Node{}, nq.predicates...),
withPrev: nq.withPrev.Clone(),