mirror of
https://github.com/ent/ent.git
synced 2026-04-28 21:50:56 +03:00
entc/gen: reduce the usage of DISTINCT in queries (#3305)
Most queries are not graph traversals but rather regular table scans, in which case the DISTINCT clause is not needed as duplicates cannot be returned (unless query was modified by the user).
This commit is contained in:
@@ -577,6 +577,17 @@ type QuerySpec struct {
|
||||
Assign func(columns []string, values []any) error
|
||||
}
|
||||
|
||||
// NewQuerySpec creates a new node query spec.
|
||||
func NewQuerySpec(table string, columns []string, id *FieldSpec) *QuerySpec {
|
||||
return &QuerySpec{
|
||||
Node: &NodeSpec{
|
||||
ID: id,
|
||||
Table: table,
|
||||
Columns: columns,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// QueryNodes queries the nodes in the graph query and scans them to the given values.
|
||||
func QueryNodes(ctx context.Context, drv dialect.Driver, spec *QuerySpec) error {
|
||||
builder := sql.Dialect(drv.Dialect())
|
||||
|
||||
Reference in New Issue
Block a user