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