mirror of
https://github.com/ent/ent.git
synced 2026-04-28 21:50:56 +03:00
dialect/sql/sqlgraph: add support for query modifiers
This commit is contained in:
committed by
Ariel Mashraki
parent
dfc7a79f6d
commit
279d6c2a12
@@ -492,6 +492,7 @@ type QuerySpec struct {
|
||||
Unique bool
|
||||
Order func(*sql.Selector)
|
||||
Predicate func(*sql.Selector)
|
||||
Modifiers []func(*sql.Selector)
|
||||
|
||||
ScanValues func(columns []string) ([]interface{}, error)
|
||||
Assign func(columns []string, values []interface{}) error
|
||||
@@ -633,6 +634,9 @@ func (q *query) selector(ctx context.Context) (*sql.Selector, error) {
|
||||
if q.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, m := range q.Modifiers {
|
||||
m(selector)
|
||||
}
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user