|
@@ -7,7 +7,6 @@ import (
|
|
"fmt"
|
|
"fmt"
|
|
"math"
|
|
"math"
|
|
|
|
|
|
- "entgo.io/ent/dialect"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"entgo.io/ent/schema/field"
|
|
@@ -24,7 +23,6 @@ type LockQuery struct {
|
|
order []OrderFunc
|
|
order []OrderFunc
|
|
fields []string
|
|
fields []string
|
|
predicates []predicate.Lock
|
|
predicates []predicate.Lock
|
|
- modifiers []func(*sql.Selector)
|
|
|
|
// intermediate query (i.e. traversal path).
|
|
// intermediate query (i.e. traversal path).
|
|
sql *sql.Selector
|
|
sql *sql.Selector
|
|
path func(context.Context) (*sql.Selector, error)
|
|
path func(context.Context) (*sql.Selector, error)
|
|
@@ -326,9 +324,6 @@ func (lq *LockQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Lock, e
|
|
nodes = append(nodes, node)
|
|
nodes = append(nodes, node)
|
|
return node.assignValues(columns, values)
|
|
return node.assignValues(columns, values)
|
|
}
|
|
}
|
|
- if len(lq.modifiers) > 0 {
|
|
|
|
- _spec.Modifiers = lq.modifiers
|
|
|
|
- }
|
|
|
|
for i := range hooks {
|
|
for i := range hooks {
|
|
hooks[i](ctx, _spec)
|
|
hooks[i](ctx, _spec)
|
|
}
|
|
}
|
|
@@ -343,9 +338,6 @@ func (lq *LockQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Lock, e
|
|
|
|
|
|
func (lq *LockQuery) sqlCount(ctx context.Context) (int, error) {
|
|
func (lq *LockQuery) sqlCount(ctx context.Context) (int, error) {
|
|
_spec := lq.querySpec()
|
|
_spec := lq.querySpec()
|
|
- if len(lq.modifiers) > 0 {
|
|
|
|
- _spec.Modifiers = lq.modifiers
|
|
|
|
- }
|
|
|
|
_spec.Node.Columns = lq.fields
|
|
_spec.Node.Columns = lq.fields
|
|
if len(lq.fields) > 0 {
|
|
if len(lq.fields) > 0 {
|
|
_spec.Unique = lq.unique != nil && *lq.unique
|
|
_spec.Unique = lq.unique != nil && *lq.unique
|
|
@@ -427,9 +419,6 @@ func (lq *LockQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
|
if lq.unique != nil && *lq.unique {
|
|
if lq.unique != nil && *lq.unique {
|
|
selector.Distinct()
|
|
selector.Distinct()
|
|
}
|
|
}
|
|
- for _, m := range lq.modifiers {
|
|
|
|
- m(selector)
|
|
|
|
- }
|
|
|
|
for _, p := range lq.predicates {
|
|
for _, p := range lq.predicates {
|
|
p(selector)
|
|
p(selector)
|
|
}
|
|
}
|
|
@@ -447,32 +436,6 @@ func (lq *LockQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
|
return selector
|
|
return selector
|
|
}
|
|
}
|
|
|
|
|
|
-// ForUpdate locks the selected rows against concurrent updates, and prevent them from being
|
|
|
|
-// updated, deleted or "selected ... for update" by other sessions, until the transaction is
|
|
|
|
-// either committed or rolled-back.
|
|
|
|
-func (lq *LockQuery) ForUpdate(opts ...sql.LockOption) *LockQuery {
|
|
|
|
- if lq.driver.Dialect() == dialect.Postgres {
|
|
|
|
- lq.Unique(false)
|
|
|
|
- }
|
|
|
|
- lq.modifiers = append(lq.modifiers, func(s *sql.Selector) {
|
|
|
|
- s.ForUpdate(opts...)
|
|
|
|
- })
|
|
|
|
- return lq
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock
|
|
|
|
-// on any rows that are read. Other sessions can read the rows, but cannot modify them
|
|
|
|
-// until your transaction commits.
|
|
|
|
-func (lq *LockQuery) ForShare(opts ...sql.LockOption) *LockQuery {
|
|
|
|
- if lq.driver.Dialect() == dialect.Postgres {
|
|
|
|
- lq.Unique(false)
|
|
|
|
- }
|
|
|
|
- lq.modifiers = append(lq.modifiers, func(s *sql.Selector) {
|
|
|
|
- s.ForShare(opts...)
|
|
|
|
- })
|
|
|
|
- return lq
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// LockGroupBy is the group-by builder for Lock entities.
|
|
// LockGroupBy is the group-by builder for Lock entities.
|
|
type LockGroupBy struct {
|
|
type LockGroupBy struct {
|
|
config
|
|
config
|