diff --git a/entc/gen/template/builder/query.tmpl b/entc/gen/template/builder/query.tmpl index 01f7062c6..c2a195845 100644 --- a/entc/gen/template/builder/query.tmpl +++ b/entc/gen/template/builder/query.tmpl @@ -219,10 +219,13 @@ func ({{ $receiver }} *{{ $builder }}) AllX(ctx context.Context) []*{{ $.Name }} {{ if $.HasOneFieldID }} // IDs executes the query and returns a list of {{ $.Name }} IDs. - func ({{ $receiver }} *{{ $builder }}) IDs(ctx context.Context) ([]{{ $.ID.Type }}, error) { - var ids []{{ $.ID.Type }} + func ({{ $receiver }} *{{ $builder }}) IDs(ctx context.Context) (ids []{{ $.ID.Type }}, err error) { + {{- /* Since a graph traversal such as JOINs can return duplicate IDs, set the Unique modifier unless specified otherwise. */}} + if {{ $receiver }}.ctx.Unique == nil && {{ $receiver }}.path != nil { + {{ $receiver }}.Unique(true) + } ctx = setContextOp(ctx, {{ $receiver }}.ctx, "IDs") - if err := {{ $receiver }}.Select({{ $.Package }}.FieldID).Scan(ctx, &ids); err != nil { + if err = {{ $receiver }}.Select({{ $.Package }}.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/cascadelete/ent/comment_query.go b/entc/integration/cascadelete/ent/comment_query.go index c90fd4c48..2d8581cbc 100644 --- a/entc/integration/cascadelete/ent/comment_query.go +++ b/entc/integration/cascadelete/ent/comment_query.go @@ -205,10 +205,12 @@ func (cq *CommentQuery) AllX(ctx context.Context) []*Comment { } // IDs executes the query and returns a list of Comment IDs. -func (cq *CommentQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (cq *CommentQuery) IDs(ctx context.Context) (ids []int, err error) { + if cq.ctx.Unique == nil && cq.path != nil { + cq.Unique(true) + } ctx = setContextOp(ctx, cq.ctx, "IDs") - if err := cq.Select(comment.FieldID).Scan(ctx, &ids); err != nil { + if err = cq.Select(comment.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/cascadelete/ent/post_query.go b/entc/integration/cascadelete/ent/post_query.go index ea119aece..0f0b34788 100644 --- a/entc/integration/cascadelete/ent/post_query.go +++ b/entc/integration/cascadelete/ent/post_query.go @@ -230,10 +230,12 @@ func (pq *PostQuery) AllX(ctx context.Context) []*Post { } // IDs executes the query and returns a list of Post IDs. -func (pq *PostQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (pq *PostQuery) IDs(ctx context.Context) (ids []int, err error) { + if pq.ctx.Unique == nil && pq.path != nil { + pq.Unique(true) + } ctx = setContextOp(ctx, pq.ctx, "IDs") - if err := pq.Select(post.FieldID).Scan(ctx, &ids); err != nil { + if err = pq.Select(post.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/cascadelete/ent/user_query.go b/entc/integration/cascadelete/ent/user_query.go index 22a55d938..7d76c40e8 100644 --- a/entc/integration/cascadelete/ent/user_query.go +++ b/entc/integration/cascadelete/ent/user_query.go @@ -206,10 +206,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/config/ent/user_query.go b/entc/integration/config/ent/user_query.go index 4ab865448..9714fcc97 100644 --- a/entc/integration/config/ent/user_query.go +++ b/entc/integration/config/ent/user_query.go @@ -181,10 +181,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/customid/ent/account_query.go b/entc/integration/customid/ent/account_query.go index 9c6087435..7a26616de 100644 --- a/entc/integration/customid/ent/account_query.go +++ b/entc/integration/customid/ent/account_query.go @@ -207,10 +207,12 @@ func (aq *AccountQuery) AllX(ctx context.Context) []*Account { } // IDs executes the query and returns a list of Account IDs. -func (aq *AccountQuery) IDs(ctx context.Context) ([]sid.ID, error) { - var ids []sid.ID +func (aq *AccountQuery) IDs(ctx context.Context) (ids []sid.ID, err error) { + if aq.ctx.Unique == nil && aq.path != nil { + aq.Unique(true) + } ctx = setContextOp(ctx, aq.ctx, "IDs") - if err := aq.Select(account.FieldID).Scan(ctx, &ids); err != nil { + if err = aq.Select(account.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/customid/ent/blob_query.go b/entc/integration/customid/ent/blob_query.go index 8b9a9a220..73e40f174 100644 --- a/entc/integration/customid/ent/blob_query.go +++ b/entc/integration/customid/ent/blob_query.go @@ -254,10 +254,12 @@ func (bq *BlobQuery) AllX(ctx context.Context) []*Blob { } // IDs executes the query and returns a list of Blob IDs. -func (bq *BlobQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { - var ids []uuid.UUID +func (bq *BlobQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { + if bq.ctx.Unique == nil && bq.path != nil { + bq.Unique(true) + } ctx = setContextOp(ctx, bq.ctx, "IDs") - if err := bq.Select(blob.FieldID).Scan(ctx, &ids); err != nil { + if err = bq.Select(blob.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/customid/ent/car_query.go b/entc/integration/customid/ent/car_query.go index 491f037a6..fe4d4b770 100644 --- a/entc/integration/customid/ent/car_query.go +++ b/entc/integration/customid/ent/car_query.go @@ -206,10 +206,12 @@ func (cq *CarQuery) AllX(ctx context.Context) []*Car { } // IDs executes the query and returns a list of Car IDs. -func (cq *CarQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (cq *CarQuery) IDs(ctx context.Context) (ids []int, err error) { + if cq.ctx.Unique == nil && cq.path != nil { + cq.Unique(true) + } ctx = setContextOp(ctx, cq.ctx, "IDs") - if err := cq.Select(car.FieldID).Scan(ctx, &ids); err != nil { + if err = cq.Select(car.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/customid/ent/device_query.go b/entc/integration/customid/ent/device_query.go index e91e945ce..1ea74e6c8 100644 --- a/entc/integration/customid/ent/device_query.go +++ b/entc/integration/customid/ent/device_query.go @@ -231,10 +231,12 @@ func (dq *DeviceQuery) AllX(ctx context.Context) []*Device { } // IDs executes the query and returns a list of Device IDs. -func (dq *DeviceQuery) IDs(ctx context.Context) ([]schema.ID, error) { - var ids []schema.ID +func (dq *DeviceQuery) IDs(ctx context.Context) (ids []schema.ID, err error) { + if dq.ctx.Unique == nil && dq.path != nil { + dq.Unique(true) + } ctx = setContextOp(ctx, dq.ctx, "IDs") - if err := dq.Select(device.FieldID).Scan(ctx, &ids); err != nil { + if err = dq.Select(device.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/customid/ent/doc_query.go b/entc/integration/customid/ent/doc_query.go index e8e2ae54d..d85598dcf 100644 --- a/entc/integration/customid/ent/doc_query.go +++ b/entc/integration/customid/ent/doc_query.go @@ -253,10 +253,12 @@ func (dq *DocQuery) AllX(ctx context.Context) []*Doc { } // IDs executes the query and returns a list of Doc IDs. -func (dq *DocQuery) IDs(ctx context.Context) ([]schema.DocID, error) { - var ids []schema.DocID +func (dq *DocQuery) IDs(ctx context.Context) (ids []schema.DocID, err error) { + if dq.ctx.Unique == nil && dq.path != nil { + dq.Unique(true) + } ctx = setContextOp(ctx, dq.ctx, "IDs") - if err := dq.Select(doc.FieldID).Scan(ctx, &ids); err != nil { + if err = dq.Select(doc.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/customid/ent/group_query.go b/entc/integration/customid/ent/group_query.go index f7bd642fc..ae5c78046 100644 --- a/entc/integration/customid/ent/group_query.go +++ b/entc/integration/customid/ent/group_query.go @@ -206,10 +206,12 @@ func (gq *GroupQuery) AllX(ctx context.Context) []*Group { } // IDs executes the query and returns a list of Group IDs. -func (gq *GroupQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (gq *GroupQuery) IDs(ctx context.Context) (ids []int, err error) { + if gq.ctx.Unique == nil && gq.path != nil { + gq.Unique(true) + } ctx = setContextOp(ctx, gq.ctx, "IDs") - if err := gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { + if err = gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/customid/ent/intsid_query.go b/entc/integration/customid/ent/intsid_query.go index 446982e5a..fb9280fab 100644 --- a/entc/integration/customid/ent/intsid_query.go +++ b/entc/integration/customid/ent/intsid_query.go @@ -230,10 +230,12 @@ func (isq *IntSIDQuery) AllX(ctx context.Context) []*IntSID { } // IDs executes the query and returns a list of IntSID IDs. -func (isq *IntSIDQuery) IDs(ctx context.Context) ([]sid.ID, error) { - var ids []sid.ID +func (isq *IntSIDQuery) IDs(ctx context.Context) (ids []sid.ID, err error) { + if isq.ctx.Unique == nil && isq.path != nil { + isq.Unique(true) + } ctx = setContextOp(ctx, isq.ctx, "IDs") - if err := isq.Select(intsid.FieldID).Scan(ctx, &ids); err != nil { + if err = isq.Select(intsid.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/customid/ent/link_query.go b/entc/integration/customid/ent/link_query.go index 6975c1838..6a57f0f31 100644 --- a/entc/integration/customid/ent/link_query.go +++ b/entc/integration/customid/ent/link_query.go @@ -182,10 +182,12 @@ func (lq *LinkQuery) AllX(ctx context.Context) []*Link { } // IDs executes the query and returns a list of Link IDs. -func (lq *LinkQuery) IDs(ctx context.Context) ([]uuidc.UUIDC, error) { - var ids []uuidc.UUIDC +func (lq *LinkQuery) IDs(ctx context.Context) (ids []uuidc.UUIDC, err error) { + if lq.ctx.Unique == nil && lq.path != nil { + lq.Unique(true) + } ctx = setContextOp(ctx, lq.ctx, "IDs") - if err := lq.Select(link.FieldID).Scan(ctx, &ids); err != nil { + if err = lq.Select(link.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/customid/ent/mixinid_query.go b/entc/integration/customid/ent/mixinid_query.go index c88cb44d7..fee3c5fca 100644 --- a/entc/integration/customid/ent/mixinid_query.go +++ b/entc/integration/customid/ent/mixinid_query.go @@ -182,10 +182,12 @@ func (miq *MixinIDQuery) AllX(ctx context.Context) []*MixinID { } // IDs executes the query and returns a list of MixinID IDs. -func (miq *MixinIDQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { - var ids []uuid.UUID +func (miq *MixinIDQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { + if miq.ctx.Unique == nil && miq.path != nil { + miq.Unique(true) + } ctx = setContextOp(ctx, miq.ctx, "IDs") - if err := miq.Select(mixinid.FieldID).Scan(ctx, &ids); err != nil { + if err = miq.Select(mixinid.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/customid/ent/note_query.go b/entc/integration/customid/ent/note_query.go index 8fc519dbe..f2348707b 100644 --- a/entc/integration/customid/ent/note_query.go +++ b/entc/integration/customid/ent/note_query.go @@ -230,10 +230,12 @@ func (nq *NoteQuery) AllX(ctx context.Context) []*Note { } // IDs executes the query and returns a list of Note IDs. -func (nq *NoteQuery) IDs(ctx context.Context) ([]schema.NoteID, error) { - var ids []schema.NoteID +func (nq *NoteQuery) IDs(ctx context.Context) (ids []schema.NoteID, err error) { + if nq.ctx.Unique == nil && nq.path != nil { + nq.Unique(true) + } ctx = setContextOp(ctx, nq.ctx, "IDs") - if err := nq.Select(note.FieldID).Scan(ctx, &ids); err != nil { + if err = nq.Select(note.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/customid/ent/other_query.go b/entc/integration/customid/ent/other_query.go index 83f3b7938..6297619ca 100644 --- a/entc/integration/customid/ent/other_query.go +++ b/entc/integration/customid/ent/other_query.go @@ -182,10 +182,12 @@ func (oq *OtherQuery) AllX(ctx context.Context) []*Other { } // IDs executes the query and returns a list of Other IDs. -func (oq *OtherQuery) IDs(ctx context.Context) ([]sid.ID, error) { - var ids []sid.ID +func (oq *OtherQuery) IDs(ctx context.Context) (ids []sid.ID, err error) { + if oq.ctx.Unique == nil && oq.path != nil { + oq.Unique(true) + } ctx = setContextOp(ctx, oq.ctx, "IDs") - if err := oq.Select(other.FieldID).Scan(ctx, &ids); err != nil { + if err = oq.Select(other.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/customid/ent/pet_query.go b/entc/integration/customid/ent/pet_query.go index d51fded65..f791d8fce 100644 --- a/entc/integration/customid/ent/pet_query.go +++ b/entc/integration/customid/ent/pet_query.go @@ -277,10 +277,12 @@ func (pq *PetQuery) AllX(ctx context.Context) []*Pet { } // IDs executes the query and returns a list of Pet IDs. -func (pq *PetQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string +func (pq *PetQuery) IDs(ctx context.Context) (ids []string, err error) { + if pq.ctx.Unique == nil && pq.path != nil { + pq.Unique(true) + } ctx = setContextOp(ctx, pq.ctx, "IDs") - if err := pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { + if err = pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/customid/ent/revision_query.go b/entc/integration/customid/ent/revision_query.go index 5913796dd..0bd8a838c 100644 --- a/entc/integration/customid/ent/revision_query.go +++ b/entc/integration/customid/ent/revision_query.go @@ -181,10 +181,12 @@ func (rq *RevisionQuery) AllX(ctx context.Context) []*Revision { } // IDs executes the query and returns a list of Revision IDs. -func (rq *RevisionQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string +func (rq *RevisionQuery) IDs(ctx context.Context) (ids []string, err error) { + if rq.ctx.Unique == nil && rq.path != nil { + rq.Unique(true) + } ctx = setContextOp(ctx, rq.ctx, "IDs") - if err := rq.Select(revision.FieldID).Scan(ctx, &ids); err != nil { + if err = rq.Select(revision.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/customid/ent/session_query.go b/entc/integration/customid/ent/session_query.go index 5ba2e0598..37d736ec9 100644 --- a/entc/integration/customid/ent/session_query.go +++ b/entc/integration/customid/ent/session_query.go @@ -207,10 +207,12 @@ func (sq *SessionQuery) AllX(ctx context.Context) []*Session { } // IDs executes the query and returns a list of Session IDs. -func (sq *SessionQuery) IDs(ctx context.Context) ([]schema.ID, error) { - var ids []schema.ID +func (sq *SessionQuery) IDs(ctx context.Context) (ids []schema.ID, err error) { + if sq.ctx.Unique == nil && sq.path != nil { + sq.Unique(true) + } ctx = setContextOp(ctx, sq.ctx, "IDs") - if err := sq.Select(session.FieldID).Scan(ctx, &ids); err != nil { + if err = sq.Select(session.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/customid/ent/token_query.go b/entc/integration/customid/ent/token_query.go index ce005e39e..432e4a76b 100644 --- a/entc/integration/customid/ent/token_query.go +++ b/entc/integration/customid/ent/token_query.go @@ -207,10 +207,12 @@ func (tq *TokenQuery) AllX(ctx context.Context) []*Token { } // IDs executes the query and returns a list of Token IDs. -func (tq *TokenQuery) IDs(ctx context.Context) ([]sid.ID, error) { - var ids []sid.ID +func (tq *TokenQuery) IDs(ctx context.Context) (ids []sid.ID, err error) { + if tq.ctx.Unique == nil && tq.path != nil { + tq.Unique(true) + } ctx = setContextOp(ctx, tq.ctx, "IDs") - if err := tq.Select(token.FieldID).Scan(ctx, &ids); err != nil { + if err = tq.Select(token.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/customid/ent/user_query.go b/entc/integration/customid/ent/user_query.go index e4f4e7b46..107ed5b19 100644 --- a/entc/integration/customid/ent/user_query.go +++ b/entc/integration/customid/ent/user_query.go @@ -277,10 +277,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/edgefield/ent/car_query.go b/entc/integration/edgefield/ent/car_query.go index b97c85876..123414015 100644 --- a/entc/integration/edgefield/ent/car_query.go +++ b/entc/integration/edgefield/ent/car_query.go @@ -207,10 +207,12 @@ func (cq *CarQuery) AllX(ctx context.Context) []*Car { } // IDs executes the query and returns a list of Car IDs. -func (cq *CarQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { - var ids []uuid.UUID +func (cq *CarQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { + if cq.ctx.Unique == nil && cq.path != nil { + cq.Unique(true) + } ctx = setContextOp(ctx, cq.ctx, "IDs") - if err := cq.Select(car.FieldID).Scan(ctx, &ids); err != nil { + if err = cq.Select(car.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/edgefield/ent/card_query.go b/entc/integration/edgefield/ent/card_query.go index 63241bc66..e82f43f1c 100644 --- a/entc/integration/edgefield/ent/card_query.go +++ b/entc/integration/edgefield/ent/card_query.go @@ -205,10 +205,12 @@ func (cq *CardQuery) AllX(ctx context.Context) []*Card { } // IDs executes the query and returns a list of Card IDs. -func (cq *CardQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (cq *CardQuery) IDs(ctx context.Context) (ids []int, err error) { + if cq.ctx.Unique == nil && cq.path != nil { + cq.Unique(true) + } ctx = setContextOp(ctx, cq.ctx, "IDs") - if err := cq.Select(card.FieldID).Scan(ctx, &ids); err != nil { + if err = cq.Select(card.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/edgefield/ent/info_query.go b/entc/integration/edgefield/ent/info_query.go index 9c727b7b8..88244c035 100644 --- a/entc/integration/edgefield/ent/info_query.go +++ b/entc/integration/edgefield/ent/info_query.go @@ -205,10 +205,12 @@ func (iq *InfoQuery) AllX(ctx context.Context) []*Info { } // IDs executes the query and returns a list of Info IDs. -func (iq *InfoQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (iq *InfoQuery) IDs(ctx context.Context) (ids []int, err error) { + if iq.ctx.Unique == nil && iq.path != nil { + iq.Unique(true) + } ctx = setContextOp(ctx, iq.ctx, "IDs") - if err := iq.Select(info.FieldID).Scan(ctx, &ids); err != nil { + if err = iq.Select(info.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/edgefield/ent/metadata_query.go b/entc/integration/edgefield/ent/metadata_query.go index f622660e7..713a96de8 100644 --- a/entc/integration/edgefield/ent/metadata_query.go +++ b/entc/integration/edgefield/ent/metadata_query.go @@ -252,10 +252,12 @@ func (mq *MetadataQuery) AllX(ctx context.Context) []*Metadata { } // IDs executes the query and returns a list of Metadata IDs. -func (mq *MetadataQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (mq *MetadataQuery) IDs(ctx context.Context) (ids []int, err error) { + if mq.ctx.Unique == nil && mq.path != nil { + mq.Unique(true) + } ctx = setContextOp(ctx, mq.ctx, "IDs") - if err := mq.Select(metadata.FieldID).Scan(ctx, &ids); err != nil { + if err = mq.Select(metadata.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/edgefield/ent/node_query.go b/entc/integration/edgefield/ent/node_query.go index 08778edf0..ddefb2a6d 100644 --- a/entc/integration/edgefield/ent/node_query.go +++ b/entc/integration/edgefield/ent/node_query.go @@ -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 diff --git a/entc/integration/edgefield/ent/pet_query.go b/entc/integration/edgefield/ent/pet_query.go index 9b13a4242..e1d57edca 100644 --- a/entc/integration/edgefield/ent/pet_query.go +++ b/entc/integration/edgefield/ent/pet_query.go @@ -205,10 +205,12 @@ func (pq *PetQuery) AllX(ctx context.Context) []*Pet { } // IDs executes the query and returns a list of Pet IDs. -func (pq *PetQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (pq *PetQuery) IDs(ctx context.Context) (ids []int, err error) { + if pq.ctx.Unique == nil && pq.path != nil { + pq.Unique(true) + } ctx = setContextOp(ctx, pq.ctx, "IDs") - if err := pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { + if err = pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/edgefield/ent/post_query.go b/entc/integration/edgefield/ent/post_query.go index 31ef6680e..a9200f994 100644 --- a/entc/integration/edgefield/ent/post_query.go +++ b/entc/integration/edgefield/ent/post_query.go @@ -205,10 +205,12 @@ func (pq *PostQuery) AllX(ctx context.Context) []*Post { } // IDs executes the query and returns a list of Post IDs. -func (pq *PostQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (pq *PostQuery) IDs(ctx context.Context) (ids []int, err error) { + if pq.ctx.Unique == nil && pq.path != nil { + pq.Unique(true) + } ctx = setContextOp(ctx, pq.ctx, "IDs") - if err := pq.Select(post.FieldID).Scan(ctx, &ids); err != nil { + if err = pq.Select(post.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/edgefield/ent/rental_query.go b/entc/integration/edgefield/ent/rental_query.go index 01215f7d4..310645c7a 100644 --- a/entc/integration/edgefield/ent/rental_query.go +++ b/entc/integration/edgefield/ent/rental_query.go @@ -230,10 +230,12 @@ func (rq *RentalQuery) AllX(ctx context.Context) []*Rental { } // IDs executes the query and returns a list of Rental IDs. -func (rq *RentalQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (rq *RentalQuery) IDs(ctx context.Context) (ids []int, err error) { + if rq.ctx.Unique == nil && rq.path != nil { + rq.Unique(true) + } ctx = setContextOp(ctx, rq.ctx, "IDs") - if err := rq.Select(rental.FieldID).Scan(ctx, &ids); err != nil { + if err = rq.Select(rental.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/edgefield/ent/user_query.go b/entc/integration/edgefield/ent/user_query.go index fc6f8bbb0..2e09e299c 100644 --- a/entc/integration/edgefield/ent/user_query.go +++ b/entc/integration/edgefield/ent/user_query.go @@ -371,10 +371,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/edgeschema/ent/friendship_query.go b/entc/integration/edgeschema/ent/friendship_query.go index 18bbc9dee..6789d9422 100644 --- a/entc/integration/edgeschema/ent/friendship_query.go +++ b/entc/integration/edgeschema/ent/friendship_query.go @@ -228,10 +228,12 @@ func (fq *FriendshipQuery) AllX(ctx context.Context) []*Friendship { } // IDs executes the query and returns a list of Friendship IDs. -func (fq *FriendshipQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (fq *FriendshipQuery) IDs(ctx context.Context) (ids []int, err error) { + if fq.ctx.Unique == nil && fq.path != nil { + fq.Unique(true) + } ctx = setContextOp(ctx, fq.ctx, "IDs") - if err := fq.Select(friendship.FieldID).Scan(ctx, &ids); err != nil { + if err = fq.Select(friendship.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/edgeschema/ent/group_query.go b/entc/integration/edgeschema/ent/group_query.go index 5616e8ca8..41115fc20 100644 --- a/entc/integration/edgeschema/ent/group_query.go +++ b/entc/integration/edgeschema/ent/group_query.go @@ -278,10 +278,12 @@ func (gq *GroupQuery) AllX(ctx context.Context) []*Group { } // IDs executes the query and returns a list of Group IDs. -func (gq *GroupQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (gq *GroupQuery) IDs(ctx context.Context) (ids []int, err error) { + if gq.ctx.Unique == nil && gq.path != nil { + gq.Unique(true) + } ctx = setContextOp(ctx, gq.ctx, "IDs") - if err := gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { + if err = gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/edgeschema/ent/grouptag_query.go b/entc/integration/edgeschema/ent/grouptag_query.go index 8e5545e06..8a5721b60 100644 --- a/entc/integration/edgeschema/ent/grouptag_query.go +++ b/entc/integration/edgeschema/ent/grouptag_query.go @@ -229,10 +229,12 @@ func (gtq *GroupTagQuery) AllX(ctx context.Context) []*GroupTag { } // IDs executes the query and returns a list of GroupTag IDs. -func (gtq *GroupTagQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (gtq *GroupTagQuery) IDs(ctx context.Context) (ids []int, err error) { + if gtq.ctx.Unique == nil && gtq.path != nil { + gtq.Unique(true) + } ctx = setContextOp(ctx, gtq.ctx, "IDs") - if err := gtq.Select(grouptag.FieldID).Scan(ctx, &ids); err != nil { + if err = gtq.Select(grouptag.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/edgeschema/ent/relationshipinfo_query.go b/entc/integration/edgeschema/ent/relationshipinfo_query.go index 152233ecf..58d0f5c90 100644 --- a/entc/integration/edgeschema/ent/relationshipinfo_query.go +++ b/entc/integration/edgeschema/ent/relationshipinfo_query.go @@ -181,10 +181,12 @@ func (riq *RelationshipInfoQuery) AllX(ctx context.Context) []*RelationshipInfo } // IDs executes the query and returns a list of RelationshipInfo IDs. -func (riq *RelationshipInfoQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (riq *RelationshipInfoQuery) IDs(ctx context.Context) (ids []int, err error) { + if riq.ctx.Unique == nil && riq.path != nil { + riq.Unique(true) + } ctx = setContextOp(ctx, riq.ctx, "IDs") - if err := riq.Select(relationshipinfo.FieldID).Scan(ctx, &ids); err != nil { + if err = riq.Select(relationshipinfo.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/edgeschema/ent/role_query.go b/entc/integration/edgeschema/ent/role_query.go index 729be29a1..339a03098 100644 --- a/entc/integration/edgeschema/ent/role_query.go +++ b/entc/integration/edgeschema/ent/role_query.go @@ -230,10 +230,12 @@ func (rq *RoleQuery) AllX(ctx context.Context) []*Role { } // IDs executes the query and returns a list of Role IDs. -func (rq *RoleQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (rq *RoleQuery) IDs(ctx context.Context) (ids []int, err error) { + if rq.ctx.Unique == nil && rq.path != nil { + rq.Unique(true) + } ctx = setContextOp(ctx, rq.ctx, "IDs") - if err := rq.Select(role.FieldID).Scan(ctx, &ids); err != nil { + if err = rq.Select(role.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/edgeschema/ent/tag_query.go b/entc/integration/edgeschema/ent/tag_query.go index 029f82efc..d31a90360 100644 --- a/entc/integration/edgeschema/ent/tag_query.go +++ b/entc/integration/edgeschema/ent/tag_query.go @@ -278,10 +278,12 @@ func (tq *TagQuery) AllX(ctx context.Context) []*Tag { } // IDs executes the query and returns a list of Tag IDs. -func (tq *TagQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (tq *TagQuery) IDs(ctx context.Context) (ids []int, err error) { + if tq.ctx.Unique == nil && tq.path != nil { + tq.Unique(true) + } ctx = setContextOp(ctx, tq.ctx, "IDs") - if err := tq.Select(tag.FieldID).Scan(ctx, &ids); err != nil { + if err = tq.Select(tag.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/edgeschema/ent/tweet_query.go b/entc/integration/edgeschema/ent/tweet_query.go index ade1292b4..873bfa6f4 100644 --- a/entc/integration/edgeschema/ent/tweet_query.go +++ b/entc/integration/edgeschema/ent/tweet_query.go @@ -325,10 +325,12 @@ func (tq *TweetQuery) AllX(ctx context.Context) []*Tweet { } // IDs executes the query and returns a list of Tweet IDs. -func (tq *TweetQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (tq *TweetQuery) IDs(ctx context.Context) (ids []int, err error) { + if tq.ctx.Unique == nil && tq.path != nil { + tq.Unique(true) + } ctx = setContextOp(ctx, tq.ctx, "IDs") - if err := tq.Select(tweet.FieldID).Scan(ctx, &ids); err != nil { + if err = tq.Select(tweet.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/edgeschema/ent/tweettag_query.go b/entc/integration/edgeschema/ent/tweettag_query.go index de6c94cdc..a88fa6ca2 100644 --- a/entc/integration/edgeschema/ent/tweettag_query.go +++ b/entc/integration/edgeschema/ent/tweettag_query.go @@ -230,10 +230,12 @@ func (ttq *TweetTagQuery) AllX(ctx context.Context) []*TweetTag { } // IDs executes the query and returns a list of TweetTag IDs. -func (ttq *TweetTagQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { - var ids []uuid.UUID +func (ttq *TweetTagQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { + if ttq.ctx.Unique == nil && ttq.path != nil { + ttq.Unique(true) + } ctx = setContextOp(ctx, ttq.ctx, "IDs") - if err := ttq.Select(tweettag.FieldID).Scan(ctx, &ids); err != nil { + if err = ttq.Select(tweettag.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/edgeschema/ent/user_query.go b/entc/integration/edgeschema/ent/user_query.go index 7a58dc016..6f42e47fc 100644 --- a/entc/integration/edgeschema/ent/user_query.go +++ b/entc/integration/edgeschema/ent/user_query.go @@ -468,10 +468,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/edgeschema/ent/usergroup_query.go b/entc/integration/edgeschema/ent/usergroup_query.go index 779a56e43..556d05b1e 100644 --- a/entc/integration/edgeschema/ent/usergroup_query.go +++ b/entc/integration/edgeschema/ent/usergroup_query.go @@ -229,10 +229,12 @@ func (ugq *UserGroupQuery) AllX(ctx context.Context) []*UserGroup { } // IDs executes the query and returns a list of UserGroup IDs. -func (ugq *UserGroupQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (ugq *UserGroupQuery) IDs(ctx context.Context) (ids []int, err error) { + if ugq.ctx.Unique == nil && ugq.path != nil { + ugq.Unique(true) + } ctx = setContextOp(ctx, ugq.ctx, "IDs") - if err := ugq.Select(usergroup.FieldID).Scan(ctx, &ids); err != nil { + if err = ugq.Select(usergroup.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/edgeschema/ent/usertweet_query.go b/entc/integration/edgeschema/ent/usertweet_query.go index 128400935..54aac25d0 100644 --- a/entc/integration/edgeschema/ent/usertweet_query.go +++ b/entc/integration/edgeschema/ent/usertweet_query.go @@ -229,10 +229,12 @@ func (utq *UserTweetQuery) AllX(ctx context.Context) []*UserTweet { } // IDs executes the query and returns a list of UserTweet IDs. -func (utq *UserTweetQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (utq *UserTweetQuery) IDs(ctx context.Context) (ids []int, err error) { + if utq.ctx.Unique == nil && utq.path != nil { + utq.Unique(true) + } ctx = setContextOp(ctx, utq.ctx, "IDs") - if err := utq.Select(usertweet.FieldID).Scan(ctx, &ids); err != nil { + if err = utq.Select(usertweet.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/ent/api_query.go b/entc/integration/ent/api_query.go index a2b936d93..2a1737aab 100644 --- a/entc/integration/ent/api_query.go +++ b/entc/integration/ent/api_query.go @@ -183,10 +183,12 @@ func (aq *APIQuery) AllX(ctx context.Context) []*Api { } // IDs executes the query and returns a list of Api IDs. -func (aq *APIQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (aq *APIQuery) IDs(ctx context.Context) (ids []int, err error) { + if aq.ctx.Unique == nil && aq.path != nil { + aq.Unique(true) + } ctx = setContextOp(ctx, aq.ctx, "IDs") - if err := aq.Select(api.FieldID).Scan(ctx, &ids); err != nil { + if err = aq.Select(api.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/ent/card_query.go b/entc/integration/ent/card_query.go index f9d4cd819..05d3b2568 100644 --- a/entc/integration/ent/card_query.go +++ b/entc/integration/ent/card_query.go @@ -234,10 +234,12 @@ func (cq *CardQuery) AllX(ctx context.Context) []*Card { } // IDs executes the query and returns a list of Card IDs. -func (cq *CardQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (cq *CardQuery) IDs(ctx context.Context) (ids []int, err error) { + if cq.ctx.Unique == nil && cq.path != nil { + cq.Unique(true) + } ctx = setContextOp(ctx, cq.ctx, "IDs") - if err := cq.Select(card.FieldID).Scan(ctx, &ids); err != nil { + if err = cq.Select(card.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/ent/comment_query.go b/entc/integration/ent/comment_query.go index 6a667ae91..5e9f0c9d3 100644 --- a/entc/integration/ent/comment_query.go +++ b/entc/integration/ent/comment_query.go @@ -183,10 +183,12 @@ func (cq *CommentQuery) AllX(ctx context.Context) []*Comment { } // IDs executes the query and returns a list of Comment IDs. -func (cq *CommentQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (cq *CommentQuery) IDs(ctx context.Context) (ids []int, err error) { + if cq.ctx.Unique == nil && cq.path != nil { + cq.Unique(true) + } ctx = setContextOp(ctx, cq.ctx, "IDs") - if err := cq.Select(comment.FieldID).Scan(ctx, &ids); err != nil { + if err = cq.Select(comment.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/ent/fieldtype_query.go b/entc/integration/ent/fieldtype_query.go index bc74a4bc6..6378e0626 100644 --- a/entc/integration/ent/fieldtype_query.go +++ b/entc/integration/ent/fieldtype_query.go @@ -184,10 +184,12 @@ func (ftq *FieldTypeQuery) AllX(ctx context.Context) []*FieldType { } // IDs executes the query and returns a list of FieldType IDs. -func (ftq *FieldTypeQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (ftq *FieldTypeQuery) IDs(ctx context.Context) (ids []int, err error) { + if ftq.ctx.Unique == nil && ftq.path != nil { + ftq.Unique(true) + } ctx = setContextOp(ctx, ftq.ctx, "IDs") - if err := ftq.Select(fieldtype.FieldID).Scan(ctx, &ids); err != nil { + if err = ftq.Select(fieldtype.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/ent/file_query.go b/entc/integration/ent/file_query.go index 33841824b..a131073f9 100644 --- a/entc/integration/ent/file_query.go +++ b/entc/integration/ent/file_query.go @@ -258,10 +258,12 @@ func (fq *FileQuery) AllX(ctx context.Context) []*File { } // IDs executes the query and returns a list of File IDs. -func (fq *FileQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (fq *FileQuery) IDs(ctx context.Context) (ids []int, err error) { + if fq.ctx.Unique == nil && fq.path != nil { + fq.Unique(true) + } ctx = setContextOp(ctx, fq.ctx, "IDs") - if err := fq.Select(file.FieldID).Scan(ctx, &ids); err != nil { + if err = fq.Select(file.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/ent/filetype_query.go b/entc/integration/ent/filetype_query.go index 95cbdc0da..7b5b4f22e 100644 --- a/entc/integration/ent/filetype_query.go +++ b/entc/integration/ent/filetype_query.go @@ -209,10 +209,12 @@ func (ftq *FileTypeQuery) AllX(ctx context.Context) []*FileType { } // IDs executes the query and returns a list of FileType IDs. -func (ftq *FileTypeQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (ftq *FileTypeQuery) IDs(ctx context.Context) (ids []int, err error) { + if ftq.ctx.Unique == nil && ftq.path != nil { + ftq.Unique(true) + } ctx = setContextOp(ctx, ftq.ctx, "IDs") - if err := ftq.Select(filetype.FieldID).Scan(ctx, &ids); err != nil { + if err = ftq.Select(filetype.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/ent/goods_query.go b/entc/integration/ent/goods_query.go index 27c9c86fa..a6b695f31 100644 --- a/entc/integration/ent/goods_query.go +++ b/entc/integration/ent/goods_query.go @@ -183,10 +183,12 @@ func (gq *GoodsQuery) AllX(ctx context.Context) []*Goods { } // IDs executes the query and returns a list of Goods IDs. -func (gq *GoodsQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (gq *GoodsQuery) IDs(ctx context.Context) (ids []int, err error) { + if gq.ctx.Unique == nil && gq.path != nil { + gq.Unique(true) + } ctx = setContextOp(ctx, gq.ctx, "IDs") - if err := gq.Select(goods.FieldID).Scan(ctx, &ids); err != nil { + if err = gq.Select(goods.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/ent/group_query.go b/entc/integration/ent/group_query.go index f63b0c0b7..0ecc8f68e 100644 --- a/entc/integration/ent/group_query.go +++ b/entc/integration/ent/group_query.go @@ -283,10 +283,12 @@ func (gq *GroupQuery) AllX(ctx context.Context) []*Group { } // IDs executes the query and returns a list of Group IDs. -func (gq *GroupQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (gq *GroupQuery) IDs(ctx context.Context) (ids []int, err error) { + if gq.ctx.Unique == nil && gq.path != nil { + gq.Unique(true) + } ctx = setContextOp(ctx, gq.ctx, "IDs") - if err := gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { + if err = gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/ent/groupinfo_query.go b/entc/integration/ent/groupinfo_query.go index f917e6a0b..65ffa98d2 100644 --- a/entc/integration/ent/groupinfo_query.go +++ b/entc/integration/ent/groupinfo_query.go @@ -209,10 +209,12 @@ func (giq *GroupInfoQuery) AllX(ctx context.Context) []*GroupInfo { } // IDs executes the query and returns a list of GroupInfo IDs. -func (giq *GroupInfoQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (giq *GroupInfoQuery) IDs(ctx context.Context) (ids []int, err error) { + if giq.ctx.Unique == nil && giq.path != nil { + giq.Unique(true) + } ctx = setContextOp(ctx, giq.ctx, "IDs") - if err := giq.Select(groupinfo.FieldID).Scan(ctx, &ids); err != nil { + if err = giq.Select(groupinfo.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/ent/item_query.go b/entc/integration/ent/item_query.go index 7335e6ce6..23144ec82 100644 --- a/entc/integration/ent/item_query.go +++ b/entc/integration/ent/item_query.go @@ -183,10 +183,12 @@ func (iq *ItemQuery) AllX(ctx context.Context) []*Item { } // IDs executes the query and returns a list of Item IDs. -func (iq *ItemQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string +func (iq *ItemQuery) IDs(ctx context.Context) (ids []string, err error) { + if iq.ctx.Unique == nil && iq.path != nil { + iq.Unique(true) + } ctx = setContextOp(ctx, iq.ctx, "IDs") - if err := iq.Select(item.FieldID).Scan(ctx, &ids); err != nil { + if err = iq.Select(item.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/ent/license_query.go b/entc/integration/ent/license_query.go index 949a77345..055c756bf 100644 --- a/entc/integration/ent/license_query.go +++ b/entc/integration/ent/license_query.go @@ -183,10 +183,12 @@ func (lq *LicenseQuery) AllX(ctx context.Context) []*License { } // IDs executes the query and returns a list of License IDs. -func (lq *LicenseQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (lq *LicenseQuery) IDs(ctx context.Context) (ids []int, err error) { + if lq.ctx.Unique == nil && lq.path != nil { + lq.Unique(true) + } ctx = setContextOp(ctx, lq.ctx, "IDs") - if err := lq.Select(license.FieldID).Scan(ctx, &ids); err != nil { + if err = lq.Select(license.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/ent/node_query.go b/entc/integration/ent/node_query.go index 67097ebaa..edeb64c17 100644 --- a/entc/integration/ent/node_query.go +++ b/entc/integration/ent/node_query.go @@ -231,10 +231,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 diff --git a/entc/integration/ent/pet_query.go b/entc/integration/ent/pet_query.go index 85f5cebb7..5a74931a0 100644 --- a/entc/integration/ent/pet_query.go +++ b/entc/integration/ent/pet_query.go @@ -231,10 +231,12 @@ func (pq *PetQuery) AllX(ctx context.Context) []*Pet { } // IDs executes the query and returns a list of Pet IDs. -func (pq *PetQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (pq *PetQuery) IDs(ctx context.Context) (ids []int, err error) { + if pq.ctx.Unique == nil && pq.path != nil { + pq.Unique(true) + } ctx = setContextOp(ctx, pq.ctx, "IDs") - if err := pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { + if err = pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/ent/spec_query.go b/entc/integration/ent/spec_query.go index 0d623a80e..c84a996db 100644 --- a/entc/integration/ent/spec_query.go +++ b/entc/integration/ent/spec_query.go @@ -209,10 +209,12 @@ func (sq *SpecQuery) AllX(ctx context.Context) []*Spec { } // IDs executes the query and returns a list of Spec IDs. -func (sq *SpecQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (sq *SpecQuery) IDs(ctx context.Context) (ids []int, err error) { + if sq.ctx.Unique == nil && sq.path != nil { + sq.Unique(true) + } ctx = setContextOp(ctx, sq.ctx, "IDs") - if err := sq.Select(spec.FieldID).Scan(ctx, &ids); err != nil { + if err = sq.Select(spec.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/ent/task_query.go b/entc/integration/ent/task_query.go index ae4c595b3..91fbf1716 100644 --- a/entc/integration/ent/task_query.go +++ b/entc/integration/ent/task_query.go @@ -184,10 +184,12 @@ func (tq *TaskQuery) AllX(ctx context.Context) []*Task { } // IDs executes the query and returns a list of Task IDs. -func (tq *TaskQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (tq *TaskQuery) IDs(ctx context.Context) (ids []int, err error) { + if tq.ctx.Unique == nil && tq.path != nil { + tq.Unique(true) + } ctx = setContextOp(ctx, tq.ctx, "IDs") - if err := tq.Select(enttask.FieldID).Scan(ctx, &ids); err != nil { + if err = tq.Select(enttask.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/ent/user_query.go b/entc/integration/ent/user_query.go index 64cc9d987..c79280d40 100644 --- a/entc/integration/ent/user_query.go +++ b/entc/integration/ent/user_query.go @@ -449,10 +449,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/gremlin/ent/api_query.go b/entc/integration/gremlin/ent/api_query.go index e13540d67..5199f37fd 100644 --- a/entc/integration/gremlin/ent/api_query.go +++ b/entc/integration/gremlin/ent/api_query.go @@ -182,10 +182,12 @@ func (aq *APIQuery) AllX(ctx context.Context) []*Api { } // IDs executes the query and returns a list of Api IDs. -func (aq *APIQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string +func (aq *APIQuery) IDs(ctx context.Context) (ids []string, err error) { + if aq.ctx.Unique == nil && aq.path != nil { + aq.Unique(true) + } ctx = setContextOp(ctx, aq.ctx, "IDs") - if err := aq.Select(api.FieldID).Scan(ctx, &ids); err != nil { + if err = aq.Select(api.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/gremlin/ent/card_query.go b/entc/integration/gremlin/ent/card_query.go index c26a33edf..2e9e7d6be 100644 --- a/entc/integration/gremlin/ent/card_query.go +++ b/entc/integration/gremlin/ent/card_query.go @@ -214,10 +214,12 @@ func (cq *CardQuery) AllX(ctx context.Context) []*Card { } // IDs executes the query and returns a list of Card IDs. -func (cq *CardQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string +func (cq *CardQuery) IDs(ctx context.Context) (ids []string, err error) { + if cq.ctx.Unique == nil && cq.path != nil { + cq.Unique(true) + } ctx = setContextOp(ctx, cq.ctx, "IDs") - if err := cq.Select(card.FieldID).Scan(ctx, &ids); err != nil { + if err = cq.Select(card.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/gremlin/ent/comment_query.go b/entc/integration/gremlin/ent/comment_query.go index 5e125a07f..83431da78 100644 --- a/entc/integration/gremlin/ent/comment_query.go +++ b/entc/integration/gremlin/ent/comment_query.go @@ -182,10 +182,12 @@ func (cq *CommentQuery) AllX(ctx context.Context) []*Comment { } // IDs executes the query and returns a list of Comment IDs. -func (cq *CommentQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string +func (cq *CommentQuery) IDs(ctx context.Context) (ids []string, err error) { + if cq.ctx.Unique == nil && cq.path != nil { + cq.Unique(true) + } ctx = setContextOp(ctx, cq.ctx, "IDs") - if err := cq.Select(comment.FieldID).Scan(ctx, &ids); err != nil { + if err = cq.Select(comment.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/gremlin/ent/fieldtype_query.go b/entc/integration/gremlin/ent/fieldtype_query.go index b9601b447..468397961 100644 --- a/entc/integration/gremlin/ent/fieldtype_query.go +++ b/entc/integration/gremlin/ent/fieldtype_query.go @@ -182,10 +182,12 @@ func (ftq *FieldTypeQuery) AllX(ctx context.Context) []*FieldType { } // IDs executes the query and returns a list of FieldType IDs. -func (ftq *FieldTypeQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string +func (ftq *FieldTypeQuery) IDs(ctx context.Context) (ids []string, err error) { + if ftq.ctx.Unique == nil && ftq.path != nil { + ftq.Unique(true) + } ctx = setContextOp(ctx, ftq.ctx, "IDs") - if err := ftq.Select(fieldtype.FieldID).Scan(ctx, &ids); err != nil { + if err = ftq.Select(fieldtype.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/gremlin/ent/file_query.go b/entc/integration/gremlin/ent/file_query.go index ce1b6b4c4..787f3aac7 100644 --- a/entc/integration/gremlin/ent/file_query.go +++ b/entc/integration/gremlin/ent/file_query.go @@ -229,10 +229,12 @@ func (fq *FileQuery) AllX(ctx context.Context) []*File { } // IDs executes the query and returns a list of File IDs. -func (fq *FileQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string +func (fq *FileQuery) IDs(ctx context.Context) (ids []string, err error) { + if fq.ctx.Unique == nil && fq.path != nil { + fq.Unique(true) + } ctx = setContextOp(ctx, fq.ctx, "IDs") - if err := fq.Select(file.FieldID).Scan(ctx, &ids); err != nil { + if err = fq.Select(file.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/gremlin/ent/filetype_query.go b/entc/integration/gremlin/ent/filetype_query.go index 51a0128f3..9e3761f28 100644 --- a/entc/integration/gremlin/ent/filetype_query.go +++ b/entc/integration/gremlin/ent/filetype_query.go @@ -197,10 +197,12 @@ func (ftq *FileTypeQuery) AllX(ctx context.Context) []*FileType { } // IDs executes the query and returns a list of FileType IDs. -func (ftq *FileTypeQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string +func (ftq *FileTypeQuery) IDs(ctx context.Context) (ids []string, err error) { + if ftq.ctx.Unique == nil && ftq.path != nil { + ftq.Unique(true) + } ctx = setContextOp(ctx, ftq.ctx, "IDs") - if err := ftq.Select(filetype.FieldID).Scan(ctx, &ids); err != nil { + if err = ftq.Select(filetype.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/gremlin/ent/goods_query.go b/entc/integration/gremlin/ent/goods_query.go index d0e998382..1338cb946 100644 --- a/entc/integration/gremlin/ent/goods_query.go +++ b/entc/integration/gremlin/ent/goods_query.go @@ -182,10 +182,12 @@ func (gq *GoodsQuery) AllX(ctx context.Context) []*Goods { } // IDs executes the query and returns a list of Goods IDs. -func (gq *GoodsQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string +func (gq *GoodsQuery) IDs(ctx context.Context) (ids []string, err error) { + if gq.ctx.Unique == nil && gq.path != nil { + gq.Unique(true) + } ctx = setContextOp(ctx, gq.ctx, "IDs") - if err := gq.Select(goods.FieldID).Scan(ctx, &ids); err != nil { + if err = gq.Select(goods.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/gremlin/ent/group_query.go b/entc/integration/gremlin/ent/group_query.go index ec12360b4..87cdea302 100644 --- a/entc/integration/gremlin/ent/group_query.go +++ b/entc/integration/gremlin/ent/group_query.go @@ -243,10 +243,12 @@ func (gq *GroupQuery) AllX(ctx context.Context) []*Group { } // IDs executes the query and returns a list of Group IDs. -func (gq *GroupQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string +func (gq *GroupQuery) IDs(ctx context.Context) (ids []string, err error) { + if gq.ctx.Unique == nil && gq.path != nil { + gq.Unique(true) + } ctx = setContextOp(ctx, gq.ctx, "IDs") - if err := gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { + if err = gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/gremlin/ent/groupinfo_query.go b/entc/integration/gremlin/ent/groupinfo_query.go index 855506770..6989d8ae7 100644 --- a/entc/integration/gremlin/ent/groupinfo_query.go +++ b/entc/integration/gremlin/ent/groupinfo_query.go @@ -198,10 +198,12 @@ func (giq *GroupInfoQuery) AllX(ctx context.Context) []*GroupInfo { } // IDs executes the query and returns a list of GroupInfo IDs. -func (giq *GroupInfoQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string +func (giq *GroupInfoQuery) IDs(ctx context.Context) (ids []string, err error) { + if giq.ctx.Unique == nil && giq.path != nil { + giq.Unique(true) + } ctx = setContextOp(ctx, giq.ctx, "IDs") - if err := giq.Select(groupinfo.FieldID).Scan(ctx, &ids); err != nil { + if err = giq.Select(groupinfo.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/gremlin/ent/item_query.go b/entc/integration/gremlin/ent/item_query.go index e579ca448..fd2feac26 100644 --- a/entc/integration/gremlin/ent/item_query.go +++ b/entc/integration/gremlin/ent/item_query.go @@ -182,10 +182,12 @@ func (iq *ItemQuery) AllX(ctx context.Context) []*Item { } // IDs executes the query and returns a list of Item IDs. -func (iq *ItemQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string +func (iq *ItemQuery) IDs(ctx context.Context) (ids []string, err error) { + if iq.ctx.Unique == nil && iq.path != nil { + iq.Unique(true) + } ctx = setContextOp(ctx, iq.ctx, "IDs") - if err := iq.Select(item.FieldID).Scan(ctx, &ids); err != nil { + if err = iq.Select(item.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/gremlin/ent/license_query.go b/entc/integration/gremlin/ent/license_query.go index d36710833..ab598067b 100644 --- a/entc/integration/gremlin/ent/license_query.go +++ b/entc/integration/gremlin/ent/license_query.go @@ -182,10 +182,12 @@ func (lq *LicenseQuery) AllX(ctx context.Context) []*License { } // IDs executes the query and returns a list of License IDs. -func (lq *LicenseQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (lq *LicenseQuery) IDs(ctx context.Context) (ids []int, err error) { + if lq.ctx.Unique == nil && lq.path != nil { + lq.Unique(true) + } ctx = setContextOp(ctx, lq.ctx, "IDs") - if err := lq.Select(license.FieldID).Scan(ctx, &ids); err != nil { + if err = lq.Select(license.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/gremlin/ent/node_query.go b/entc/integration/gremlin/ent/node_query.go index 0af224115..5318cd1d4 100644 --- a/entc/integration/gremlin/ent/node_query.go +++ b/entc/integration/gremlin/ent/node_query.go @@ -212,10 +212,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) ([]string, error) { - var ids []string +func (nq *NodeQuery) IDs(ctx context.Context) (ids []string, 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 diff --git a/entc/integration/gremlin/ent/pet_query.go b/entc/integration/gremlin/ent/pet_query.go index f241ad818..ded002d05 100644 --- a/entc/integration/gremlin/ent/pet_query.go +++ b/entc/integration/gremlin/ent/pet_query.go @@ -213,10 +213,12 @@ func (pq *PetQuery) AllX(ctx context.Context) []*Pet { } // IDs executes the query and returns a list of Pet IDs. -func (pq *PetQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string +func (pq *PetQuery) IDs(ctx context.Context) (ids []string, err error) { + if pq.ctx.Unique == nil && pq.path != nil { + pq.Unique(true) + } ctx = setContextOp(ctx, pq.ctx, "IDs") - if err := pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { + if err = pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/gremlin/ent/spec_query.go b/entc/integration/gremlin/ent/spec_query.go index 180241223..141bb78d3 100644 --- a/entc/integration/gremlin/ent/spec_query.go +++ b/entc/integration/gremlin/ent/spec_query.go @@ -197,10 +197,12 @@ func (sq *SpecQuery) AllX(ctx context.Context) []*Spec { } // IDs executes the query and returns a list of Spec IDs. -func (sq *SpecQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string +func (sq *SpecQuery) IDs(ctx context.Context) (ids []string, err error) { + if sq.ctx.Unique == nil && sq.path != nil { + sq.Unique(true) + } ctx = setContextOp(ctx, sq.ctx, "IDs") - if err := sq.Select(spec.FieldID).Scan(ctx, &ids); err != nil { + if err = sq.Select(spec.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/gremlin/ent/task_query.go b/entc/integration/gremlin/ent/task_query.go index 55feb5985..431592d76 100644 --- a/entc/integration/gremlin/ent/task_query.go +++ b/entc/integration/gremlin/ent/task_query.go @@ -183,10 +183,12 @@ func (tq *TaskQuery) AllX(ctx context.Context) []*Task { } // IDs executes the query and returns a list of Task IDs. -func (tq *TaskQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string +func (tq *TaskQuery) IDs(ctx context.Context) (ids []string, err error) { + if tq.ctx.Unique == nil && tq.path != nil { + tq.Unique(true) + } ctx = setContextOp(ctx, tq.ctx, "IDs") - if err := tq.Select(enttask.FieldID).Scan(ctx, &ids); err != nil { + if err = tq.Select(enttask.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/gremlin/ent/user_query.go b/entc/integration/gremlin/ent/user_query.go index b001b8e69..7405de73d 100644 --- a/entc/integration/gremlin/ent/user_query.go +++ b/entc/integration/gremlin/ent/user_query.go @@ -347,10 +347,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string +func (uq *UserQuery) IDs(ctx context.Context) (ids []string, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/hooks/ent/card_query.go b/entc/integration/hooks/ent/card_query.go index ae454a27e..77009428d 100644 --- a/entc/integration/hooks/ent/card_query.go +++ b/entc/integration/hooks/ent/card_query.go @@ -206,10 +206,12 @@ func (cq *CardQuery) AllX(ctx context.Context) []*Card { } // IDs executes the query and returns a list of Card IDs. -func (cq *CardQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (cq *CardQuery) IDs(ctx context.Context) (ids []int, err error) { + if cq.ctx.Unique == nil && cq.path != nil { + cq.Unique(true) + } ctx = setContextOp(ctx, cq.ctx, "IDs") - if err := cq.Select(card.FieldID).Scan(ctx, &ids); err != nil { + if err = cq.Select(card.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/hooks/ent/pet_query.go b/entc/integration/hooks/ent/pet_query.go index 28c1ce313..623446f96 100644 --- a/entc/integration/hooks/ent/pet_query.go +++ b/entc/integration/hooks/ent/pet_query.go @@ -206,10 +206,12 @@ func (pq *PetQuery) AllX(ctx context.Context) []*Pet { } // IDs executes the query and returns a list of Pet IDs. -func (pq *PetQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (pq *PetQuery) IDs(ctx context.Context) (ids []int, err error) { + if pq.ctx.Unique == nil && pq.path != nil { + pq.Unique(true) + } ctx = setContextOp(ctx, pq.ctx, "IDs") - if err := pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { + if err = pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/hooks/ent/user_query.go b/entc/integration/hooks/ent/user_query.go index 5191b30fb..9be32d949 100644 --- a/entc/integration/hooks/ent/user_query.go +++ b/entc/integration/hooks/ent/user_query.go @@ -277,10 +277,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/idtype/ent/user_query.go b/entc/integration/idtype/ent/user_query.go index 2385b6cc5..d0f15d4d5 100644 --- a/entc/integration/idtype/ent/user_query.go +++ b/entc/integration/idtype/ent/user_query.go @@ -252,10 +252,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]uint64, error) { - var ids []uint64 +func (uq *UserQuery) IDs(ctx context.Context) (ids []uint64, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/integration_test.go b/entc/integration/integration_test.go index d25a963d9..6429fb034 100644 --- a/entc/integration/integration_test.go +++ b/entc/integration/integration_test.go @@ -1223,6 +1223,8 @@ func Relation(t *testing.T, client *ent.Client) { require.Equal(neta.Name, usr.QueryGroups().Where(group.Name("Github")).QueryUsers().QuerySpouse().OnlyX(ctx).Name) require.Empty(client.GroupInfo.Query().Where(groupinfo.Desc("group info")).QueryGroups().Where(group.Name("boring")).AllX(ctx)) require.Equal(child.Name, client.GroupInfo.Query().Where(groupinfo.Desc("group info")).QueryGroups().Where(group.Name("Github")).QueryUsers().QueryChildren().FirstX(ctx).Name) + neta.Update().AddGroups(grp).ExecX(ctx) + require.Equal(grp.ID, client.User.Query().QueryGroups().OnlyIDX(ctx)) t.Log("query using string predicate") require.Len(client.User.Query().Where(user.NameIn("a8m", "neta", "pedro")).AllX(ctx), 3) diff --git a/entc/integration/json/ent/user_query.go b/entc/integration/json/ent/user_query.go index 8138bb42f..bbd7428be 100644 --- a/entc/integration/json/ent/user_query.go +++ b/entc/integration/json/ent/user_query.go @@ -182,10 +182,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/migrate/entv1/car_query.go b/entc/integration/migrate/entv1/car_query.go index dc1ef0953..0b1daa3d6 100644 --- a/entc/integration/migrate/entv1/car_query.go +++ b/entc/integration/migrate/entv1/car_query.go @@ -206,10 +206,12 @@ func (cq *CarQuery) AllX(ctx context.Context) []*Car { } // IDs executes the query and returns a list of Car IDs. -func (cq *CarQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (cq *CarQuery) IDs(ctx context.Context) (ids []int, err error) { + if cq.ctx.Unique == nil && cq.path != nil { + cq.Unique(true) + } ctx = setContextOp(ctx, cq.ctx, "IDs") - if err := cq.Select(car.FieldID).Scan(ctx, &ids); err != nil { + if err = cq.Select(car.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/migrate/entv1/conversion_query.go b/entc/integration/migrate/entv1/conversion_query.go index 743f3b67b..3e1dd4bda 100644 --- a/entc/integration/migrate/entv1/conversion_query.go +++ b/entc/integration/migrate/entv1/conversion_query.go @@ -181,10 +181,12 @@ func (cq *ConversionQuery) AllX(ctx context.Context) []*Conversion { } // IDs executes the query and returns a list of Conversion IDs. -func (cq *ConversionQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (cq *ConversionQuery) IDs(ctx context.Context) (ids []int, err error) { + if cq.ctx.Unique == nil && cq.path != nil { + cq.Unique(true) + } ctx = setContextOp(ctx, cq.ctx, "IDs") - if err := cq.Select(conversion.FieldID).Scan(ctx, &ids); err != nil { + if err = cq.Select(conversion.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/migrate/entv1/customtype_query.go b/entc/integration/migrate/entv1/customtype_query.go index 7d394e298..8746a6bc6 100644 --- a/entc/integration/migrate/entv1/customtype_query.go +++ b/entc/integration/migrate/entv1/customtype_query.go @@ -181,10 +181,12 @@ func (ctq *CustomTypeQuery) AllX(ctx context.Context) []*CustomType { } // IDs executes the query and returns a list of CustomType IDs. -func (ctq *CustomTypeQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (ctq *CustomTypeQuery) IDs(ctx context.Context) (ids []int, err error) { + if ctq.ctx.Unique == nil && ctq.path != nil { + ctq.Unique(true) + } ctx = setContextOp(ctx, ctq.ctx, "IDs") - if err := ctq.Select(customtype.FieldID).Scan(ctx, &ids); err != nil { + if err = ctq.Select(customtype.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/migrate/entv1/user_query.go b/entc/integration/migrate/entv1/user_query.go index 58482f90f..003411c10 100644 --- a/entc/integration/migrate/entv1/user_query.go +++ b/entc/integration/migrate/entv1/user_query.go @@ -276,10 +276,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/migrate/entv2/blog_query.go b/entc/integration/migrate/entv2/blog_query.go index 09eae6a2c..a0c627339 100644 --- a/entc/integration/migrate/entv2/blog_query.go +++ b/entc/integration/migrate/entv2/blog_query.go @@ -206,10 +206,12 @@ func (bq *BlogQuery) AllX(ctx context.Context) []*Blog { } // IDs executes the query and returns a list of Blog IDs. -func (bq *BlogQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (bq *BlogQuery) IDs(ctx context.Context) (ids []int, err error) { + if bq.ctx.Unique == nil && bq.path != nil { + bq.Unique(true) + } ctx = setContextOp(ctx, bq.ctx, "IDs") - if err := bq.Select(blog.FieldID).Scan(ctx, &ids); err != nil { + if err = bq.Select(blog.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/migrate/entv2/car_query.go b/entc/integration/migrate/entv2/car_query.go index a695ec453..4c2c56e14 100644 --- a/entc/integration/migrate/entv2/car_query.go +++ b/entc/integration/migrate/entv2/car_query.go @@ -206,10 +206,12 @@ func (cq *CarQuery) AllX(ctx context.Context) []*Car { } // IDs executes the query and returns a list of Car IDs. -func (cq *CarQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (cq *CarQuery) IDs(ctx context.Context) (ids []int, err error) { + if cq.ctx.Unique == nil && cq.path != nil { + cq.Unique(true) + } ctx = setContextOp(ctx, cq.ctx, "IDs") - if err := cq.Select(car.FieldID).Scan(ctx, &ids); err != nil { + if err = cq.Select(car.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/migrate/entv2/conversion_query.go b/entc/integration/migrate/entv2/conversion_query.go index 42d699989..a5893646c 100644 --- a/entc/integration/migrate/entv2/conversion_query.go +++ b/entc/integration/migrate/entv2/conversion_query.go @@ -181,10 +181,12 @@ func (cq *ConversionQuery) AllX(ctx context.Context) []*Conversion { } // IDs executes the query and returns a list of Conversion IDs. -func (cq *ConversionQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (cq *ConversionQuery) IDs(ctx context.Context) (ids []int, err error) { + if cq.ctx.Unique == nil && cq.path != nil { + cq.Unique(true) + } ctx = setContextOp(ctx, cq.ctx, "IDs") - if err := cq.Select(conversion.FieldID).Scan(ctx, &ids); err != nil { + if err = cq.Select(conversion.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/migrate/entv2/customtype_query.go b/entc/integration/migrate/entv2/customtype_query.go index 1a59c8b7a..253f574d4 100644 --- a/entc/integration/migrate/entv2/customtype_query.go +++ b/entc/integration/migrate/entv2/customtype_query.go @@ -181,10 +181,12 @@ func (ctq *CustomTypeQuery) AllX(ctx context.Context) []*CustomType { } // IDs executes the query and returns a list of CustomType IDs. -func (ctq *CustomTypeQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (ctq *CustomTypeQuery) IDs(ctx context.Context) (ids []int, err error) { + if ctq.ctx.Unique == nil && ctq.path != nil { + ctq.Unique(true) + } ctx = setContextOp(ctx, ctq.ctx, "IDs") - if err := ctq.Select(customtype.FieldID).Scan(ctx, &ids); err != nil { + if err = ctq.Select(customtype.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/migrate/entv2/group_query.go b/entc/integration/migrate/entv2/group_query.go index 9a9e8363d..b580b37af 100644 --- a/entc/integration/migrate/entv2/group_query.go +++ b/entc/integration/migrate/entv2/group_query.go @@ -181,10 +181,12 @@ func (gq *GroupQuery) AllX(ctx context.Context) []*Group { } // IDs executes the query and returns a list of Group IDs. -func (gq *GroupQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (gq *GroupQuery) IDs(ctx context.Context) (ids []int, err error) { + if gq.ctx.Unique == nil && gq.path != nil { + gq.Unique(true) + } ctx = setContextOp(ctx, gq.ctx, "IDs") - if err := gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { + if err = gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/migrate/entv2/media_query.go b/entc/integration/migrate/entv2/media_query.go index 9db5f1c6b..a5f7598fb 100644 --- a/entc/integration/migrate/entv2/media_query.go +++ b/entc/integration/migrate/entv2/media_query.go @@ -181,10 +181,12 @@ func (mq *MediaQuery) AllX(ctx context.Context) []*Media { } // IDs executes the query and returns a list of Media IDs. -func (mq *MediaQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (mq *MediaQuery) IDs(ctx context.Context) (ids []int, err error) { + if mq.ctx.Unique == nil && mq.path != nil { + mq.Unique(true) + } ctx = setContextOp(ctx, mq.ctx, "IDs") - if err := mq.Select(media.FieldID).Scan(ctx, &ids); err != nil { + if err = mq.Select(media.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/migrate/entv2/pet_query.go b/entc/integration/migrate/entv2/pet_query.go index 9837d8234..f7a27945f 100644 --- a/entc/integration/migrate/entv2/pet_query.go +++ b/entc/integration/migrate/entv2/pet_query.go @@ -206,10 +206,12 @@ func (pq *PetQuery) AllX(ctx context.Context) []*Pet { } // IDs executes the query and returns a list of Pet IDs. -func (pq *PetQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (pq *PetQuery) IDs(ctx context.Context) (ids []int, err error) { + if pq.ctx.Unique == nil && pq.path != nil { + pq.Unique(true) + } ctx = setContextOp(ctx, pq.ctx, "IDs") - if err := pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { + if err = pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/migrate/entv2/user_query.go b/entc/integration/migrate/entv2/user_query.go index ec20140ec..dfbd02b1c 100644 --- a/entc/integration/migrate/entv2/user_query.go +++ b/entc/integration/migrate/entv2/user_query.go @@ -254,10 +254,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/migrate/entv2/zoo_query.go b/entc/integration/migrate/entv2/zoo_query.go index 346587eab..5b8ef1c48 100644 --- a/entc/integration/migrate/entv2/zoo_query.go +++ b/entc/integration/migrate/entv2/zoo_query.go @@ -181,10 +181,12 @@ func (zq *ZooQuery) AllX(ctx context.Context) []*Zoo { } // IDs executes the query and returns a list of Zoo IDs. -func (zq *ZooQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (zq *ZooQuery) IDs(ctx context.Context) (ids []int, err error) { + if zq.ctx.Unique == nil && zq.path != nil { + zq.Unique(true) + } ctx = setContextOp(ctx, zq.ctx, "IDs") - if err := zq.Select(zoo.FieldID).Scan(ctx, &ids); err != nil { + if err = zq.Select(zoo.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/migrate/versioned/group_query.go b/entc/integration/migrate/versioned/group_query.go index 922c45d35..1804252ec 100644 --- a/entc/integration/migrate/versioned/group_query.go +++ b/entc/integration/migrate/versioned/group_query.go @@ -181,10 +181,12 @@ func (gq *GroupQuery) AllX(ctx context.Context) []*Group { } // IDs executes the query and returns a list of Group IDs. -func (gq *GroupQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (gq *GroupQuery) IDs(ctx context.Context) (ids []int, err error) { + if gq.ctx.Unique == nil && gq.path != nil { + gq.Unique(true) + } ctx = setContextOp(ctx, gq.ctx, "IDs") - if err := gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { + if err = gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/migrate/versioned/user_query.go b/entc/integration/migrate/versioned/user_query.go index 711503ab6..c747ead2b 100644 --- a/entc/integration/migrate/versioned/user_query.go +++ b/entc/integration/migrate/versioned/user_query.go @@ -181,10 +181,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/multischema/ent/friendship_query.go b/entc/integration/multischema/ent/friendship_query.go index 951008595..7299997ce 100644 --- a/entc/integration/multischema/ent/friendship_query.go +++ b/entc/integration/multischema/ent/friendship_query.go @@ -236,10 +236,12 @@ func (fq *FriendshipQuery) AllX(ctx context.Context) []*Friendship { } // IDs executes the query and returns a list of Friendship IDs. -func (fq *FriendshipQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (fq *FriendshipQuery) IDs(ctx context.Context) (ids []int, err error) { + if fq.ctx.Unique == nil && fq.path != nil { + fq.Unique(true) + } ctx = setContextOp(ctx, fq.ctx, "IDs") - if err := fq.Select(friendship.FieldID).Scan(ctx, &ids); err != nil { + if err = fq.Select(friendship.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/multischema/ent/group_query.go b/entc/integration/multischema/ent/group_query.go index bd1b35116..f64cc6c26 100644 --- a/entc/integration/multischema/ent/group_query.go +++ b/entc/integration/multischema/ent/group_query.go @@ -211,10 +211,12 @@ func (gq *GroupQuery) AllX(ctx context.Context) []*Group { } // IDs executes the query and returns a list of Group IDs. -func (gq *GroupQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (gq *GroupQuery) IDs(ctx context.Context) (ids []int, err error) { + if gq.ctx.Unique == nil && gq.path != nil { + gq.Unique(true) + } ctx = setContextOp(ctx, gq.ctx, "IDs") - if err := gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { + if err = gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/multischema/ent/pet_query.go b/entc/integration/multischema/ent/pet_query.go index 494b09dab..06213c52e 100644 --- a/entc/integration/multischema/ent/pet_query.go +++ b/entc/integration/multischema/ent/pet_query.go @@ -210,10 +210,12 @@ func (pq *PetQuery) AllX(ctx context.Context) []*Pet { } // IDs executes the query and returns a list of Pet IDs. -func (pq *PetQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (pq *PetQuery) IDs(ctx context.Context) (ids []int, err error) { + if pq.ctx.Unique == nil && pq.path != nil { + pq.Unique(true) + } ctx = setContextOp(ctx, pq.ctx, "IDs") - if err := pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { + if err = pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/multischema/ent/user_query.go b/entc/integration/multischema/ent/user_query.go index ffd67fa0c..c620a07d7 100644 --- a/entc/integration/multischema/ent/user_query.go +++ b/entc/integration/multischema/ent/user_query.go @@ -291,10 +291,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/privacy/ent/task_query.go b/entc/integration/privacy/ent/task_query.go index 9889c87fa..f641b2d93 100644 --- a/entc/integration/privacy/ent/task_query.go +++ b/entc/integration/privacy/ent/task_query.go @@ -232,10 +232,12 @@ func (tq *TaskQuery) AllX(ctx context.Context) []*Task { } // IDs executes the query and returns a list of Task IDs. -func (tq *TaskQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (tq *TaskQuery) IDs(ctx context.Context) (ids []int, err error) { + if tq.ctx.Unique == nil && tq.path != nil { + tq.Unique(true) + } ctx = setContextOp(ctx, tq.ctx, "IDs") - if err := tq.Select(task.FieldID).Scan(ctx, &ids); err != nil { + if err = tq.Select(task.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/privacy/ent/team_query.go b/entc/integration/privacy/ent/team_query.go index ae6123549..b4f86ca06 100644 --- a/entc/integration/privacy/ent/team_query.go +++ b/entc/integration/privacy/ent/team_query.go @@ -231,10 +231,12 @@ func (tq *TeamQuery) AllX(ctx context.Context) []*Team { } // IDs executes the query and returns a list of Team IDs. -func (tq *TeamQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (tq *TeamQuery) IDs(ctx context.Context) (ids []int, err error) { + if tq.ctx.Unique == nil && tq.path != nil { + tq.Unique(true) + } ctx = setContextOp(ctx, tq.ctx, "IDs") - if err := tq.Select(team.FieldID).Scan(ctx, &ids); err != nil { + if err = tq.Select(team.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/privacy/ent/user_query.go b/entc/integration/privacy/ent/user_query.go index 7cd844d17..9e8c16c49 100644 --- a/entc/integration/privacy/ent/user_query.go +++ b/entc/integration/privacy/ent/user_query.go @@ -231,10 +231,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/template/ent/group_query.go b/entc/integration/template/ent/group_query.go index 93f5cb998..3f841b883 100644 --- a/entc/integration/template/ent/group_query.go +++ b/entc/integration/template/ent/group_query.go @@ -184,10 +184,12 @@ func (gq *GroupQuery) AllX(ctx context.Context) []*Group { } // IDs executes the query and returns a list of Group IDs. -func (gq *GroupQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (gq *GroupQuery) IDs(ctx context.Context) (ids []int, err error) { + if gq.ctx.Unique == nil && gq.path != nil { + gq.Unique(true) + } ctx = setContextOp(ctx, gq.ctx, "IDs") - if err := gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { + if err = gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/template/ent/pet_query.go b/entc/integration/template/ent/pet_query.go index 1549c0453..b1859e800 100644 --- a/entc/integration/template/ent/pet_query.go +++ b/entc/integration/template/ent/pet_query.go @@ -209,10 +209,12 @@ func (pq *PetQuery) AllX(ctx context.Context) []*Pet { } // IDs executes the query and returns a list of Pet IDs. -func (pq *PetQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (pq *PetQuery) IDs(ctx context.Context) (ids []int, err error) { + if pq.ctx.Unique == nil && pq.path != nil { + pq.Unique(true) + } ctx = setContextOp(ctx, pq.ctx, "IDs") - if err := pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { + if err = pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/entc/integration/template/ent/user_query.go b/entc/integration/template/ent/user_query.go index df90ecf48..519ad5831 100644 --- a/entc/integration/template/ent/user_query.go +++ b/entc/integration/template/ent/user_query.go @@ -232,10 +232,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/edgeindex/ent/city_query.go b/examples/edgeindex/ent/city_query.go index fec54e783..32eba9c06 100644 --- a/examples/edgeindex/ent/city_query.go +++ b/examples/edgeindex/ent/city_query.go @@ -206,10 +206,12 @@ func (cq *CityQuery) AllX(ctx context.Context) []*City { } // IDs executes the query and returns a list of City IDs. -func (cq *CityQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (cq *CityQuery) IDs(ctx context.Context) (ids []int, err error) { + if cq.ctx.Unique == nil && cq.path != nil { + cq.Unique(true) + } ctx = setContextOp(ctx, cq.ctx, "IDs") - if err := cq.Select(city.FieldID).Scan(ctx, &ids); err != nil { + if err = cq.Select(city.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/edgeindex/ent/street_query.go b/examples/edgeindex/ent/street_query.go index 66810ed10..5296cf3d0 100644 --- a/examples/edgeindex/ent/street_query.go +++ b/examples/edgeindex/ent/street_query.go @@ -206,10 +206,12 @@ func (sq *StreetQuery) AllX(ctx context.Context) []*Street { } // IDs executes the query and returns a list of Street IDs. -func (sq *StreetQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (sq *StreetQuery) IDs(ctx context.Context) (ids []int, err error) { + if sq.ctx.Unique == nil && sq.path != nil { + sq.Unique(true) + } ctx = setContextOp(ctx, sq.ctx, "IDs") - if err := sq.Select(street.FieldID).Scan(ctx, &ids); err != nil { + if err = sq.Select(street.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/encryptfield/ent/user_query.go b/examples/encryptfield/ent/user_query.go index 857763dc7..74dbc959b 100644 --- a/examples/encryptfield/ent/user_query.go +++ b/examples/encryptfield/ent/user_query.go @@ -181,10 +181,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/entcpkg/ent/user_query.go b/examples/entcpkg/ent/user_query.go index 256639614..98e8becaf 100644 --- a/examples/entcpkg/ent/user_query.go +++ b/examples/entcpkg/ent/user_query.go @@ -181,10 +181,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/fs/ent/file_query.go b/examples/fs/ent/file_query.go index f5b47ff9e..a8d3f2ccb 100644 --- a/examples/fs/ent/file_query.go +++ b/examples/fs/ent/file_query.go @@ -228,10 +228,12 @@ func (fq *FileQuery) AllX(ctx context.Context) []*File { } // IDs executes the query and returns a list of File IDs. -func (fq *FileQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (fq *FileQuery) IDs(ctx context.Context) (ids []int, err error) { + if fq.ctx.Unique == nil && fq.path != nil { + fq.Unique(true) + } ctx = setContextOp(ctx, fq.ctx, "IDs") - if err := fq.Select(file.FieldID).Scan(ctx, &ids); err != nil { + if err = fq.Select(file.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/jsonencode/ent/card_query.go b/examples/jsonencode/ent/card_query.go index 5c8c6a327..19289a368 100644 --- a/examples/jsonencode/ent/card_query.go +++ b/examples/jsonencode/ent/card_query.go @@ -181,10 +181,12 @@ func (cq *CardQuery) AllX(ctx context.Context) []*Card { } // IDs executes the query and returns a list of Card IDs. -func (cq *CardQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (cq *CardQuery) IDs(ctx context.Context) (ids []int, err error) { + if cq.ctx.Unique == nil && cq.path != nil { + cq.Unique(true) + } ctx = setContextOp(ctx, cq.ctx, "IDs") - if err := cq.Select(card.FieldID).Scan(ctx, &ids); err != nil { + if err = cq.Select(card.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/jsonencode/ent/pet_query.go b/examples/jsonencode/ent/pet_query.go index b6fd0c8b8..6deab0cd2 100644 --- a/examples/jsonencode/ent/pet_query.go +++ b/examples/jsonencode/ent/pet_query.go @@ -205,10 +205,12 @@ func (pq *PetQuery) AllX(ctx context.Context) []*Pet { } // IDs executes the query and returns a list of Pet IDs. -func (pq *PetQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (pq *PetQuery) IDs(ctx context.Context) (ids []int, err error) { + if pq.ctx.Unique == nil && pq.path != nil { + pq.Unique(true) + } ctx = setContextOp(ctx, pq.ctx, "IDs") - if err := pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { + if err = pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/jsonencode/ent/user_query.go b/examples/jsonencode/ent/user_query.go index c35622537..fcfedff6e 100644 --- a/examples/jsonencode/ent/user_query.go +++ b/examples/jsonencode/ent/user_query.go @@ -206,10 +206,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/m2m2types/ent/group_query.go b/examples/m2m2types/ent/group_query.go index 115c62a87..121775dc2 100644 --- a/examples/m2m2types/ent/group_query.go +++ b/examples/m2m2types/ent/group_query.go @@ -206,10 +206,12 @@ func (gq *GroupQuery) AllX(ctx context.Context) []*Group { } // IDs executes the query and returns a list of Group IDs. -func (gq *GroupQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (gq *GroupQuery) IDs(ctx context.Context) (ids []int, err error) { + if gq.ctx.Unique == nil && gq.path != nil { + gq.Unique(true) + } ctx = setContextOp(ctx, gq.ctx, "IDs") - if err := gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { + if err = gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/m2m2types/ent/user_query.go b/examples/m2m2types/ent/user_query.go index 1e3d4b195..a3b476d7f 100644 --- a/examples/m2m2types/ent/user_query.go +++ b/examples/m2m2types/ent/user_query.go @@ -206,10 +206,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/m2mbidi/ent/user_query.go b/examples/m2mbidi/ent/user_query.go index 5b9dc67fd..20e0a7e53 100644 --- a/examples/m2mbidi/ent/user_query.go +++ b/examples/m2mbidi/ent/user_query.go @@ -205,10 +205,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/m2mrecur/ent/user_query.go b/examples/m2mrecur/ent/user_query.go index e8b6ec128..0f8a68f77 100644 --- a/examples/m2mrecur/ent/user_query.go +++ b/examples/m2mrecur/ent/user_query.go @@ -228,10 +228,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/migration/ent/card_query.go b/examples/migration/ent/card_query.go index a89df2860..dca8be521 100644 --- a/examples/migration/ent/card_query.go +++ b/examples/migration/ent/card_query.go @@ -205,10 +205,12 @@ func (cq *CardQuery) AllX(ctx context.Context) []*Card { } // IDs executes the query and returns a list of Card IDs. -func (cq *CardQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (cq *CardQuery) IDs(ctx context.Context) (ids []int, err error) { + if cq.ctx.Unique == nil && cq.path != nil { + cq.Unique(true) + } ctx = setContextOp(ctx, cq.ctx, "IDs") - if err := cq.Select(card.FieldID).Scan(ctx, &ids); err != nil { + if err = cq.Select(card.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/migration/ent/pet_query.go b/examples/migration/ent/pet_query.go index e1cb89a8a..8ebbda75b 100644 --- a/examples/migration/ent/pet_query.go +++ b/examples/migration/ent/pet_query.go @@ -229,10 +229,12 @@ func (pq *PetQuery) AllX(ctx context.Context) []*Pet { } // IDs executes the query and returns a list of Pet IDs. -func (pq *PetQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { - var ids []uuid.UUID +func (pq *PetQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { + if pq.ctx.Unique == nil && pq.path != nil { + pq.Unique(true) + } ctx = setContextOp(ctx, pq.ctx, "IDs") - if err := pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { + if err = pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/migration/ent/user_query.go b/examples/migration/ent/user_query.go index d3256ccf8..2a9477516 100644 --- a/examples/migration/ent/user_query.go +++ b/examples/migration/ent/user_query.go @@ -206,10 +206,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/o2m2types/ent/pet_query.go b/examples/o2m2types/ent/pet_query.go index 0fefdb618..e7dbe1fc1 100644 --- a/examples/o2m2types/ent/pet_query.go +++ b/examples/o2m2types/ent/pet_query.go @@ -206,10 +206,12 @@ func (pq *PetQuery) AllX(ctx context.Context) []*Pet { } // IDs executes the query and returns a list of Pet IDs. -func (pq *PetQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (pq *PetQuery) IDs(ctx context.Context) (ids []int, err error) { + if pq.ctx.Unique == nil && pq.path != nil { + pq.Unique(true) + } ctx = setContextOp(ctx, pq.ctx, "IDs") - if err := pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { + if err = pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/o2m2types/ent/user_query.go b/examples/o2m2types/ent/user_query.go index 5db7e2e40..b97be5813 100644 --- a/examples/o2m2types/ent/user_query.go +++ b/examples/o2m2types/ent/user_query.go @@ -206,10 +206,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/o2mrecur/ent/node_query.go b/examples/o2mrecur/ent/node_query.go index 2d134b085..43cb318de 100644 --- a/examples/o2mrecur/ent/node_query.go +++ b/examples/o2mrecur/ent/node_query.go @@ -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 diff --git a/examples/o2o2types/ent/card_query.go b/examples/o2o2types/ent/card_query.go index aefd18e60..f6f58a296 100644 --- a/examples/o2o2types/ent/card_query.go +++ b/examples/o2o2types/ent/card_query.go @@ -206,10 +206,12 @@ func (cq *CardQuery) AllX(ctx context.Context) []*Card { } // IDs executes the query and returns a list of Card IDs. -func (cq *CardQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (cq *CardQuery) IDs(ctx context.Context) (ids []int, err error) { + if cq.ctx.Unique == nil && cq.path != nil { + cq.Unique(true) + } ctx = setContextOp(ctx, cq.ctx, "IDs") - if err := cq.Select(card.FieldID).Scan(ctx, &ids); err != nil { + if err = cq.Select(card.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/o2o2types/ent/user_query.go b/examples/o2o2types/ent/user_query.go index be6fd0cf4..721ab1177 100644 --- a/examples/o2o2types/ent/user_query.go +++ b/examples/o2o2types/ent/user_query.go @@ -206,10 +206,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/o2obidi/ent/user_query.go b/examples/o2obidi/ent/user_query.go index f4713bb87..14a627318 100644 --- a/examples/o2obidi/ent/user_query.go +++ b/examples/o2obidi/ent/user_query.go @@ -205,10 +205,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/o2orecur/ent/node_query.go b/examples/o2orecur/ent/node_query.go index c6db4575d..c92be0914 100644 --- a/examples/o2orecur/ent/node_query.go +++ b/examples/o2orecur/ent/node_query.go @@ -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 diff --git a/examples/privacyadmin/ent/user_query.go b/examples/privacyadmin/ent/user_query.go index c4ca5c8c4..2c55dcd3b 100644 --- a/examples/privacyadmin/ent/user_query.go +++ b/examples/privacyadmin/ent/user_query.go @@ -182,10 +182,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/privacytenant/ent/group_query.go b/examples/privacytenant/ent/group_query.go index acf1cfd65..bf0f480a6 100644 --- a/examples/privacytenant/ent/group_query.go +++ b/examples/privacytenant/ent/group_query.go @@ -231,10 +231,12 @@ func (gq *GroupQuery) AllX(ctx context.Context) []*Group { } // IDs executes the query and returns a list of Group IDs. -func (gq *GroupQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (gq *GroupQuery) IDs(ctx context.Context) (ids []int, err error) { + if gq.ctx.Unique == nil && gq.path != nil { + gq.Unique(true) + } ctx = setContextOp(ctx, gq.ctx, "IDs") - if err := gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { + if err = gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/privacytenant/ent/tenant_query.go b/examples/privacytenant/ent/tenant_query.go index db3e79fb8..d9c20bd24 100644 --- a/examples/privacytenant/ent/tenant_query.go +++ b/examples/privacytenant/ent/tenant_query.go @@ -182,10 +182,12 @@ func (tq *TenantQuery) AllX(ctx context.Context) []*Tenant { } // IDs executes the query and returns a list of Tenant IDs. -func (tq *TenantQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (tq *TenantQuery) IDs(ctx context.Context) (ids []int, err error) { + if tq.ctx.Unique == nil && tq.path != nil { + tq.Unique(true) + } ctx = setContextOp(ctx, tq.ctx, "IDs") - if err := tq.Select(tenant.FieldID).Scan(ctx, &ids); err != nil { + if err = tq.Select(tenant.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/privacytenant/ent/user_query.go b/examples/privacytenant/ent/user_query.go index a6927069f..cc4d73b45 100644 --- a/examples/privacytenant/ent/user_query.go +++ b/examples/privacytenant/ent/user_query.go @@ -231,10 +231,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/start/ent/car_query.go b/examples/start/ent/car_query.go index b98469d65..ad1181c02 100644 --- a/examples/start/ent/car_query.go +++ b/examples/start/ent/car_query.go @@ -206,10 +206,12 @@ func (cq *CarQuery) AllX(ctx context.Context) []*Car { } // IDs executes the query and returns a list of Car IDs. -func (cq *CarQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (cq *CarQuery) IDs(ctx context.Context) (ids []int, err error) { + if cq.ctx.Unique == nil && cq.path != nil { + cq.Unique(true) + } ctx = setContextOp(ctx, cq.ctx, "IDs") - if err := cq.Select(car.FieldID).Scan(ctx, &ids); err != nil { + if err = cq.Select(car.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/start/ent/group_query.go b/examples/start/ent/group_query.go index df7a4e46f..875af8add 100644 --- a/examples/start/ent/group_query.go +++ b/examples/start/ent/group_query.go @@ -206,10 +206,12 @@ func (gq *GroupQuery) AllX(ctx context.Context) []*Group { } // IDs executes the query and returns a list of Group IDs. -func (gq *GroupQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (gq *GroupQuery) IDs(ctx context.Context) (ids []int, err error) { + if gq.ctx.Unique == nil && gq.path != nil { + gq.Unique(true) + } ctx = setContextOp(ctx, gq.ctx, "IDs") - if err := gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { + if err = gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/start/ent/user_query.go b/examples/start/ent/user_query.go index 24a5a09e3..766566c28 100644 --- a/examples/start/ent/user_query.go +++ b/examples/start/ent/user_query.go @@ -230,10 +230,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/traversal/ent/group_query.go b/examples/traversal/ent/group_query.go index 492c7619b..32c0bb4c4 100644 --- a/examples/traversal/ent/group_query.go +++ b/examples/traversal/ent/group_query.go @@ -230,10 +230,12 @@ func (gq *GroupQuery) AllX(ctx context.Context) []*Group { } // IDs executes the query and returns a list of Group IDs. -func (gq *GroupQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (gq *GroupQuery) IDs(ctx context.Context) (ids []int, err error) { + if gq.ctx.Unique == nil && gq.path != nil { + gq.Unique(true) + } ctx = setContextOp(ctx, gq.ctx, "IDs") - if err := gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { + if err = gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/traversal/ent/pet_query.go b/examples/traversal/ent/pet_query.go index efc837071..236eab7e7 100644 --- a/examples/traversal/ent/pet_query.go +++ b/examples/traversal/ent/pet_query.go @@ -230,10 +230,12 @@ func (pq *PetQuery) AllX(ctx context.Context) []*Pet { } // IDs executes the query and returns a list of Pet IDs. -func (pq *PetQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (pq *PetQuery) IDs(ctx context.Context) (ids []int, err error) { + if pq.ctx.Unique == nil && pq.path != nil { + pq.Unique(true) + } ctx = setContextOp(ctx, pq.ctx, "IDs") - if err := pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { + if err = pq.Select(pet.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/traversal/ent/user_query.go b/examples/traversal/ent/user_query.go index 08cc664d7..df0af0f45 100644 --- a/examples/traversal/ent/user_query.go +++ b/examples/traversal/ent/user_query.go @@ -276,10 +276,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil diff --git a/examples/version/ent/user_query.go b/examples/version/ent/user_query.go index c4c2fe259..5ed0b08a0 100644 --- a/examples/version/ent/user_query.go +++ b/examples/version/ent/user_query.go @@ -181,10 +181,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (uq *UserQuery) IDs(ctx context.Context) (ids []int, err error) { + if uq.ctx.Unique == nil && uq.path != nil { + uq.Unique(true) + } ctx = setContextOp(ctx, uq.ctx, "IDs") - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil