mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: <T>Query.IDs should not return duplicates (#3304)
This commit is contained in:
@@ -228,10 +228,12 @@ func (nq *NodeQuery) AllX(ctx context.Context) []*Node {
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Node IDs.
|
||||
func (nq *NodeQuery) IDs(ctx context.Context) ([]int, error) {
|
||||
var ids []int
|
||||
func (nq *NodeQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if nq.ctx.Unique == nil && nq.path != nil {
|
||||
nq.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, nq.ctx, "IDs")
|
||||
if err := nq.Select(node.FieldID).Scan(ctx, &ids); err != nil {
|
||||
if err = nq.Select(node.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
|
||||
Reference in New Issue
Block a user