diff --git a/dialect/sql/sqlgraph/graph.go b/dialect/sql/sqlgraph/graph.go index 82f4a88586..17bb5c44bf 100644 --- a/dialect/sql/sqlgraph/graph.go +++ b/dialect/sql/sqlgraph/graph.go @@ -577,6 +577,17 @@ type QuerySpec struct { Assign func(columns []string, values []any) error } +// NewQuerySpec creates a new node query spec. +func NewQuerySpec(table string, columns []string, id *FieldSpec) *QuerySpec { + return &QuerySpec{ + Node: &NodeSpec{ + ID: id, + Table: table, + Columns: columns, + }, + } +} + // QueryNodes queries the nodes in the graph query and scans them to the given values. func QueryNodes(ctx context.Context, drv dialect.Driver, spec *QuerySpec) error { builder := sql.Dialect(drv.Dialect()) diff --git a/entc/gen/template/dialect/sql/query.tmpl b/entc/gen/template/dialect/sql/query.tmpl index 9572e934ab..4ed810c5d7 100644 --- a/entc/gen/template/dialect/sql/query.tmpl +++ b/entc/gen/template/dialect/sql/query.tmpl @@ -262,22 +262,13 @@ func ({{ $receiver }} *{{ $builder }}) sqlCount(ctx context.Context) (int, error } func ({{ $receiver }} *{{ $builder }}) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: {{ $.Package }}.Table, - Columns: {{ $.Package }}.Columns, - {{- if $.HasOneFieldID }} - ID: &sqlgraph.FieldSpec{ - Type: field.{{ $.ID.Type.ConstName }}, - Column: {{ $.Package }}.{{ $.ID.Constant }}, - }, - {{- end }} - }, - From: {{ $receiver }}.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec({{ $.Package }}.Table, {{ $.Package }}.Columns, {{ if $.HasOneFieldID }}sqlgraph.NewFieldSpec({{ $.Package }}.{{ $.ID.Constant }}, field.{{ $.ID.Type.ConstName }}){{ else }}nil{{ end }}) + {{- /* Setup any intermediate queries if exist (traversal path). */}} + _spec.From = {{ $receiver }}.sql if unique := {{ $receiver }}.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if {{ $receiver }}.path != nil { + _spec.Unique = true } if fields := {{ $receiver }}.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/cascadelete/ent/comment_query.go b/entc/integration/cascadelete/ent/comment_query.go index 2d8581cbc2..ff3c644173 100644 --- a/entc/integration/cascadelete/ent/comment_query.go +++ b/entc/integration/cascadelete/ent/comment_query.go @@ -444,20 +444,12 @@ func (cq *CommentQuery) sqlCount(ctx context.Context) (int, error) { } func (cq *CommentQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: comment.Table, - Columns: comment.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: comment.FieldID, - }, - }, - From: cq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(comment.Table, comment.Columns, sqlgraph.NewFieldSpec(comment.FieldID, field.TypeInt)) + _spec.From = cq.sql if unique := cq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if cq.path != nil { + _spec.Unique = true } if fields := cq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/cascadelete/ent/post_query.go b/entc/integration/cascadelete/ent/post_query.go index 0f0b347886..6f7c35d9aa 100644 --- a/entc/integration/cascadelete/ent/post_query.go +++ b/entc/integration/cascadelete/ent/post_query.go @@ -516,20 +516,12 @@ func (pq *PostQuery) sqlCount(ctx context.Context) (int, error) { } func (pq *PostQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: post.Table, - Columns: post.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: post.FieldID, - }, - }, - From: pq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(post.Table, post.Columns, sqlgraph.NewFieldSpec(post.FieldID, field.TypeInt)) + _spec.From = pq.sql if unique := pq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if pq.path != nil { + _spec.Unique = true } if fields := pq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/cascadelete/ent/user_query.go b/entc/integration/cascadelete/ent/user_query.go index 7d76c40e80..d8d542ddf6 100644 --- a/entc/integration/cascadelete/ent/user_query.go +++ b/entc/integration/cascadelete/ent/user_query.go @@ -444,20 +444,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/config/ent/user_query.go b/entc/integration/config/ent/user_query.go index 9714fcc973..aa530b359c 100644 --- a/entc/integration/config/ent/user_query.go +++ b/entc/integration/config/ent/user_query.go @@ -368,20 +368,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/customid/ent/account_query.go b/entc/integration/customid/ent/account_query.go index 7a26616ded..e41c0696f7 100644 --- a/entc/integration/customid/ent/account_query.go +++ b/entc/integration/customid/ent/account_query.go @@ -449,20 +449,12 @@ func (aq *AccountQuery) sqlCount(ctx context.Context) (int, error) { } func (aq *AccountQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: account.Table, - Columns: account.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeOther, - Column: account.FieldID, - }, - }, - From: aq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(account.Table, account.Columns, sqlgraph.NewFieldSpec(account.FieldID, field.TypeOther)) + _spec.From = aq.sql if unique := aq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if aq.path != nil { + _spec.Unique = true } if fields := aq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/customid/ent/blob_query.go b/entc/integration/customid/ent/blob_query.go index 73e40f174b..b818a32383 100644 --- a/entc/integration/customid/ent/blob_query.go +++ b/entc/integration/customid/ent/blob_query.go @@ -631,20 +631,12 @@ func (bq *BlobQuery) sqlCount(ctx context.Context) (int, error) { } func (bq *BlobQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: blob.Table, - Columns: blob.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeUUID, - Column: blob.FieldID, - }, - }, - From: bq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(blob.Table, blob.Columns, sqlgraph.NewFieldSpec(blob.FieldID, field.TypeUUID)) + _spec.From = bq.sql if unique := bq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if bq.path != nil { + _spec.Unique = true } if fields := bq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/customid/ent/bloblink_query.go b/entc/integration/customid/ent/bloblink_query.go index f98e8b894f..71bc5b928f 100644 --- a/entc/integration/customid/ent/bloblink_query.go +++ b/entc/integration/customid/ent/bloblink_query.go @@ -441,16 +441,12 @@ func (blq *BlobLinkQuery) sqlCount(ctx context.Context) (int, error) { } func (blq *BlobLinkQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: bloblink.Table, - Columns: bloblink.Columns, - }, - From: blq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(bloblink.Table, bloblink.Columns, nil) + _spec.From = blq.sql if unique := blq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if blq.path != nil { + _spec.Unique = true } if fields := blq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/customid/ent/car_query.go b/entc/integration/customid/ent/car_query.go index fe4d4b770b..7178c84fb7 100644 --- a/entc/integration/customid/ent/car_query.go +++ b/entc/integration/customid/ent/car_query.go @@ -455,20 +455,12 @@ func (cq *CarQuery) sqlCount(ctx context.Context) (int, error) { } func (cq *CarQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: car.Table, - Columns: car.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: car.FieldID, - }, - }, - From: cq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(car.Table, car.Columns, sqlgraph.NewFieldSpec(car.FieldID, field.TypeInt)) + _spec.From = cq.sql if unique := cq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if cq.path != nil { + _spec.Unique = true } if fields := cq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/customid/ent/device_query.go b/entc/integration/customid/ent/device_query.go index 1ea74e6c80..d6de5de67c 100644 --- a/entc/integration/customid/ent/device_query.go +++ b/entc/integration/customid/ent/device_query.go @@ -509,20 +509,12 @@ func (dq *DeviceQuery) sqlCount(ctx context.Context) (int, error) { } func (dq *DeviceQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: device.Table, - Columns: device.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeBytes, - Column: device.FieldID, - }, - }, - From: dq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(device.Table, device.Columns, sqlgraph.NewFieldSpec(device.FieldID, field.TypeBytes)) + _spec.From = dq.sql if unique := dq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if dq.path != nil { + _spec.Unique = true } if fields := dq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/customid/ent/doc_query.go b/entc/integration/customid/ent/doc_query.go index d85598dcf2..af6a533679 100644 --- a/entc/integration/customid/ent/doc_query.go +++ b/entc/integration/customid/ent/doc_query.go @@ -634,20 +634,12 @@ func (dq *DocQuery) sqlCount(ctx context.Context) (int, error) { } func (dq *DocQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: doc.Table, - Columns: doc.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: doc.FieldID, - }, - }, - From: dq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(doc.Table, doc.Columns, sqlgraph.NewFieldSpec(doc.FieldID, field.TypeString)) + _spec.From = dq.sql if unique := dq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if dq.path != nil { + _spec.Unique = true } if fields := dq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/customid/ent/group_query.go b/entc/integration/customid/ent/group_query.go index ae5c78046c..9c1104cc31 100644 --- a/entc/integration/customid/ent/group_query.go +++ b/entc/integration/customid/ent/group_query.go @@ -456,20 +456,12 @@ func (gq *GroupQuery) sqlCount(ctx context.Context) (int, error) { } func (gq *GroupQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: group.Table, - Columns: group.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: group.FieldID, - }, - }, - From: gq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt)) + _spec.From = gq.sql if unique := gq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if gq.path != nil { + _spec.Unique = true } if fields := gq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/customid/ent/intsid_query.go b/entc/integration/customid/ent/intsid_query.go index fb9280fabc..22e41fe57a 100644 --- a/entc/integration/customid/ent/intsid_query.go +++ b/entc/integration/customid/ent/intsid_query.go @@ -508,20 +508,12 @@ func (isq *IntSIDQuery) sqlCount(ctx context.Context) (int, error) { } func (isq *IntSIDQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: intsid.Table, - Columns: intsid.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt64, - Column: intsid.FieldID, - }, - }, - From: isq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(intsid.Table, intsid.Columns, sqlgraph.NewFieldSpec(intsid.FieldID, field.TypeInt64)) + _spec.From = isq.sql if unique := isq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if isq.path != nil { + _spec.Unique = true } if fields := isq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/customid/ent/link_query.go b/entc/integration/customid/ent/link_query.go index 6a57f0f31a..ac78948136 100644 --- a/entc/integration/customid/ent/link_query.go +++ b/entc/integration/customid/ent/link_query.go @@ -369,20 +369,12 @@ func (lq *LinkQuery) sqlCount(ctx context.Context) (int, error) { } func (lq *LinkQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: link.Table, - Columns: link.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeUUID, - Column: link.FieldID, - }, - }, - From: lq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(link.Table, link.Columns, sqlgraph.NewFieldSpec(link.FieldID, field.TypeUUID)) + _spec.From = lq.sql if unique := lq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if lq.path != nil { + _spec.Unique = true } if fields := lq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/customid/ent/mixinid_query.go b/entc/integration/customid/ent/mixinid_query.go index fee3c5fca2..df21da3d93 100644 --- a/entc/integration/customid/ent/mixinid_query.go +++ b/entc/integration/customid/ent/mixinid_query.go @@ -369,20 +369,12 @@ func (miq *MixinIDQuery) sqlCount(ctx context.Context) (int, error) { } func (miq *MixinIDQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: mixinid.Table, - Columns: mixinid.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeUUID, - Column: mixinid.FieldID, - }, - }, - From: miq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(mixinid.Table, mixinid.Columns, sqlgraph.NewFieldSpec(mixinid.FieldID, field.TypeUUID)) + _spec.From = miq.sql if unique := miq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if miq.path != nil { + _spec.Unique = true } if fields := miq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/customid/ent/note_query.go b/entc/integration/customid/ent/note_query.go index f2348707b4..83d06a4509 100644 --- a/entc/integration/customid/ent/note_query.go +++ b/entc/integration/customid/ent/note_query.go @@ -530,20 +530,12 @@ func (nq *NoteQuery) sqlCount(ctx context.Context) (int, error) { } func (nq *NoteQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: note.Table, - Columns: note.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: note.FieldID, - }, - }, - From: nq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(note.Table, note.Columns, sqlgraph.NewFieldSpec(note.FieldID, field.TypeString)) + _spec.From = nq.sql if unique := nq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if nq.path != nil { + _spec.Unique = true } if fields := nq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/customid/ent/other_query.go b/entc/integration/customid/ent/other_query.go index 6297619cab..1282164d7c 100644 --- a/entc/integration/customid/ent/other_query.go +++ b/entc/integration/customid/ent/other_query.go @@ -347,20 +347,12 @@ func (oq *OtherQuery) sqlCount(ctx context.Context) (int, error) { } func (oq *OtherQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: other.Table, - Columns: other.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeOther, - Column: other.FieldID, - }, - }, - From: oq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(other.Table, other.Columns, sqlgraph.NewFieldSpec(other.FieldID, field.TypeOther)) + _spec.From = oq.sql if unique := oq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if oq.path != nil { + _spec.Unique = true } if fields := oq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/customid/ent/pet_query.go b/entc/integration/customid/ent/pet_query.go index f791d8fcee..c292d4a9a3 100644 --- a/entc/integration/customid/ent/pet_query.go +++ b/entc/integration/customid/ent/pet_query.go @@ -687,20 +687,12 @@ func (pq *PetQuery) sqlCount(ctx context.Context) (int, error) { } func (pq *PetQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: pet.Table, - Columns: pet.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: pet.FieldID, - }, - }, - From: pq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(pet.Table, pet.Columns, sqlgraph.NewFieldSpec(pet.FieldID, field.TypeString)) + _spec.From = pq.sql if unique := pq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if pq.path != nil { + _spec.Unique = true } if fields := pq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/customid/ent/revision_query.go b/entc/integration/customid/ent/revision_query.go index 0bd8a838c7..f432279f18 100644 --- a/entc/integration/customid/ent/revision_query.go +++ b/entc/integration/customid/ent/revision_query.go @@ -346,20 +346,12 @@ func (rq *RevisionQuery) sqlCount(ctx context.Context) (int, error) { } func (rq *RevisionQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: revision.Table, - Columns: revision.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: revision.FieldID, - }, - }, - From: rq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(revision.Table, revision.Columns, sqlgraph.NewFieldSpec(revision.FieldID, field.TypeString)) + _spec.From = rq.sql if unique := rq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if rq.path != nil { + _spec.Unique = true } if fields := rq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/customid/ent/session_query.go b/entc/integration/customid/ent/session_query.go index 37d736ec9b..bed16fc0b4 100644 --- a/entc/integration/customid/ent/session_query.go +++ b/entc/integration/customid/ent/session_query.go @@ -434,20 +434,12 @@ func (sq *SessionQuery) sqlCount(ctx context.Context) (int, error) { } func (sq *SessionQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: session.Table, - Columns: session.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeBytes, - Column: session.FieldID, - }, - }, - From: sq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(session.Table, session.Columns, sqlgraph.NewFieldSpec(session.FieldID, field.TypeBytes)) + _spec.From = sq.sql if unique := sq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if sq.path != nil { + _spec.Unique = true } if fields := sq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/customid/ent/token_query.go b/entc/integration/customid/ent/token_query.go index 432e4a76b9..30b51ab3b3 100644 --- a/entc/integration/customid/ent/token_query.go +++ b/entc/integration/customid/ent/token_query.go @@ -456,20 +456,12 @@ func (tq *TokenQuery) sqlCount(ctx context.Context) (int, error) { } func (tq *TokenQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: token.Table, - Columns: token.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeOther, - Column: token.FieldID, - }, - }, - From: tq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(token.Table, token.Columns, sqlgraph.NewFieldSpec(token.FieldID, field.TypeOther)) + _spec.From = tq.sql if unique := tq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if tq.path != nil { + _spec.Unique = true } if fields := tq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/customid/ent/user_query.go b/entc/integration/customid/ent/user_query.go index 107ed5b194..f7c9099015 100644 --- a/entc/integration/customid/ent/user_query.go +++ b/entc/integration/customid/ent/user_query.go @@ -687,20 +687,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgefield/ent/car_query.go b/entc/integration/edgefield/ent/car_query.go index 123414015b..0cd88c3a81 100644 --- a/entc/integration/edgefield/ent/car_query.go +++ b/entc/integration/edgefield/ent/car_query.go @@ -445,20 +445,12 @@ func (cq *CarQuery) sqlCount(ctx context.Context) (int, error) { } func (cq *CarQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: car.Table, - Columns: car.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeUUID, - Column: car.FieldID, - }, - }, - From: cq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(car.Table, car.Columns, sqlgraph.NewFieldSpec(car.FieldID, field.TypeUUID)) + _spec.From = cq.sql if unique := cq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if cq.path != nil { + _spec.Unique = true } if fields := cq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgefield/ent/card_query.go b/entc/integration/edgefield/ent/card_query.go index e82f43f1c8..ff2a9f1e76 100644 --- a/entc/integration/edgefield/ent/card_query.go +++ b/entc/integration/edgefield/ent/card_query.go @@ -444,20 +444,12 @@ func (cq *CardQuery) sqlCount(ctx context.Context) (int, error) { } func (cq *CardQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: card.Table, - Columns: card.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: card.FieldID, - }, - }, - From: cq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(card.Table, card.Columns, sqlgraph.NewFieldSpec(card.FieldID, field.TypeInt)) + _spec.From = cq.sql if unique := cq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if cq.path != nil { + _spec.Unique = true } if fields := cq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgefield/ent/info_query.go b/entc/integration/edgefield/ent/info_query.go index 88244c0350..a303bcd6e3 100644 --- a/entc/integration/edgefield/ent/info_query.go +++ b/entc/integration/edgefield/ent/info_query.go @@ -444,20 +444,12 @@ func (iq *InfoQuery) sqlCount(ctx context.Context) (int, error) { } func (iq *InfoQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: info.Table, - Columns: info.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: info.FieldID, - }, - }, - From: iq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(info.Table, info.Columns, sqlgraph.NewFieldSpec(info.FieldID, field.TypeInt)) + _spec.From = iq.sql if unique := iq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if iq.path != nil { + _spec.Unique = true } if fields := iq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgefield/ent/metadata_query.go b/entc/integration/edgefield/ent/metadata_query.go index 713a96de8a..500ab5355b 100644 --- a/entc/integration/edgefield/ent/metadata_query.go +++ b/entc/integration/edgefield/ent/metadata_query.go @@ -586,20 +586,12 @@ func (mq *MetadataQuery) sqlCount(ctx context.Context) (int, error) { } func (mq *MetadataQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: metadata.Table, - Columns: metadata.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: metadata.FieldID, - }, - }, - From: mq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(metadata.Table, metadata.Columns, sqlgraph.NewFieldSpec(metadata.FieldID, field.TypeInt)) + _spec.From = mq.sql if unique := mq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if mq.path != nil { + _spec.Unique = true } if fields := mq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgefield/ent/node_query.go b/entc/integration/edgefield/ent/node_query.go index ddefb2a6dc..9723725979 100644 --- a/entc/integration/edgefield/ent/node_query.go +++ b/entc/integration/edgefield/ent/node_query.go @@ -510,20 +510,12 @@ func (nq *NodeQuery) sqlCount(ctx context.Context) (int, error) { } func (nq *NodeQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: node.Table, - Columns: node.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: node.FieldID, - }, - }, - From: nq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(node.Table, node.Columns, sqlgraph.NewFieldSpec(node.FieldID, field.TypeInt)) + _spec.From = nq.sql if unique := nq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if nq.path != nil { + _spec.Unique = true } if fields := nq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgefield/ent/pet_query.go b/entc/integration/edgefield/ent/pet_query.go index e1d57edcae..9d99cd5108 100644 --- a/entc/integration/edgefield/ent/pet_query.go +++ b/entc/integration/edgefield/ent/pet_query.go @@ -444,20 +444,12 @@ func (pq *PetQuery) sqlCount(ctx context.Context) (int, error) { } func (pq *PetQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: pet.Table, - Columns: pet.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: pet.FieldID, - }, - }, - From: pq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(pet.Table, pet.Columns, sqlgraph.NewFieldSpec(pet.FieldID, field.TypeInt)) + _spec.From = pq.sql if unique := pq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if pq.path != nil { + _spec.Unique = true } if fields := pq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgefield/ent/post_query.go b/entc/integration/edgefield/ent/post_query.go index a9200f994e..d8f7c60d3f 100644 --- a/entc/integration/edgefield/ent/post_query.go +++ b/entc/integration/edgefield/ent/post_query.go @@ -447,20 +447,12 @@ func (pq *PostQuery) sqlCount(ctx context.Context) (int, error) { } func (pq *PostQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: post.Table, - Columns: post.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: post.FieldID, - }, - }, - From: pq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(post.Table, post.Columns, sqlgraph.NewFieldSpec(post.FieldID, field.TypeInt)) + _spec.From = pq.sql if unique := pq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if pq.path != nil { + _spec.Unique = true } if fields := pq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgefield/ent/rental_query.go b/entc/integration/edgefield/ent/rental_query.go index 310645c7ad..548faf4696 100644 --- a/entc/integration/edgefield/ent/rental_query.go +++ b/entc/integration/edgefield/ent/rental_query.go @@ -517,20 +517,12 @@ func (rq *RentalQuery) sqlCount(ctx context.Context) (int, error) { } func (rq *RentalQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: rental.Table, - Columns: rental.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: rental.FieldID, - }, - }, - From: rq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(rental.Table, rental.Columns, sqlgraph.NewFieldSpec(rental.FieldID, field.TypeInt)) + _spec.From = rq.sql if unique := rq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if rq.path != nil { + _spec.Unique = true } if fields := rq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgefield/ent/user_query.go b/entc/integration/edgefield/ent/user_query.go index 2e09e299c8..fe5ef626e2 100644 --- a/entc/integration/edgefield/ent/user_query.go +++ b/entc/integration/edgefield/ent/user_query.go @@ -932,20 +932,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgeschema/ent/friendship_query.go b/entc/integration/edgeschema/ent/friendship_query.go index 6789d94223..b9f4d4e0a3 100644 --- a/entc/integration/edgeschema/ent/friendship_query.go +++ b/entc/integration/edgeschema/ent/friendship_query.go @@ -515,20 +515,12 @@ func (fq *FriendshipQuery) sqlCount(ctx context.Context) (int, error) { } func (fq *FriendshipQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: friendship.Table, - Columns: friendship.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: friendship.FieldID, - }, - }, - From: fq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(friendship.Table, friendship.Columns, sqlgraph.NewFieldSpec(friendship.FieldID, field.TypeInt)) + _spec.From = fq.sql if unique := fq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if fq.path != nil { + _spec.Unique = true } if fields := fq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgeschema/ent/group_query.go b/entc/integration/edgeschema/ent/group_query.go index 41115fc20f..48b2bb3348 100644 --- a/entc/integration/edgeschema/ent/group_query.go +++ b/entc/integration/edgeschema/ent/group_query.go @@ -725,20 +725,12 @@ func (gq *GroupQuery) sqlCount(ctx context.Context) (int, error) { } func (gq *GroupQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: group.Table, - Columns: group.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: group.FieldID, - }, - }, - From: gq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt)) + _spec.From = gq.sql if unique := gq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if gq.path != nil { + _spec.Unique = true } if fields := gq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgeschema/ent/grouptag_query.go b/entc/integration/edgeschema/ent/grouptag_query.go index 8a5721b608..2802580a90 100644 --- a/entc/integration/edgeschema/ent/grouptag_query.go +++ b/entc/integration/edgeschema/ent/grouptag_query.go @@ -516,20 +516,12 @@ func (gtq *GroupTagQuery) sqlCount(ctx context.Context) (int, error) { } func (gtq *GroupTagQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: grouptag.Table, - Columns: grouptag.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: grouptag.FieldID, - }, - }, - From: gtq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(grouptag.Table, grouptag.Columns, sqlgraph.NewFieldSpec(grouptag.FieldID, field.TypeInt)) + _spec.From = gtq.sql if unique := gtq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if gtq.path != nil { + _spec.Unique = true } if fields := gtq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgeschema/ent/relationship_query.go b/entc/integration/edgeschema/ent/relationship_query.go index 13c47fbd7d..89ed60212e 100644 --- a/entc/integration/edgeschema/ent/relationship_query.go +++ b/entc/integration/edgeschema/ent/relationship_query.go @@ -519,16 +519,12 @@ func (rq *RelationshipQuery) sqlCount(ctx context.Context) (int, error) { } func (rq *RelationshipQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: relationship.Table, - Columns: relationship.Columns, - }, - From: rq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(relationship.Table, relationship.Columns, nil) + _spec.From = rq.sql if unique := rq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if rq.path != nil { + _spec.Unique = true } if fields := rq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgeschema/ent/relationshipinfo_query.go b/entc/integration/edgeschema/ent/relationshipinfo_query.go index 58d0f5c90d..0362525e94 100644 --- a/entc/integration/edgeschema/ent/relationshipinfo_query.go +++ b/entc/integration/edgeschema/ent/relationshipinfo_query.go @@ -368,20 +368,12 @@ func (riq *RelationshipInfoQuery) sqlCount(ctx context.Context) (int, error) { } func (riq *RelationshipInfoQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: relationshipinfo.Table, - Columns: relationshipinfo.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: relationshipinfo.FieldID, - }, - }, - From: riq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(relationshipinfo.Table, relationshipinfo.Columns, sqlgraph.NewFieldSpec(relationshipinfo.FieldID, field.TypeInt)) + _spec.From = riq.sql if unique := riq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if riq.path != nil { + _spec.Unique = true } if fields := riq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgeschema/ent/role_query.go b/entc/integration/edgeschema/ent/role_query.go index 339a030980..806face81b 100644 --- a/entc/integration/edgeschema/ent/role_query.go +++ b/entc/integration/edgeschema/ent/role_query.go @@ -549,20 +549,12 @@ func (rq *RoleQuery) sqlCount(ctx context.Context) (int, error) { } func (rq *RoleQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: role.Table, - Columns: role.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: role.FieldID, - }, - }, - From: rq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(role.Table, role.Columns, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt)) + _spec.From = rq.sql if unique := rq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if rq.path != nil { + _spec.Unique = true } if fields := rq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgeschema/ent/roleuser_query.go b/entc/integration/edgeschema/ent/roleuser_query.go index 1b6546b0e5..2170624ae7 100644 --- a/entc/integration/edgeschema/ent/roleuser_query.go +++ b/entc/integration/edgeschema/ent/roleuser_query.go @@ -441,16 +441,12 @@ func (ruq *RoleUserQuery) sqlCount(ctx context.Context) (int, error) { } func (ruq *RoleUserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: roleuser.Table, - Columns: roleuser.Columns, - }, - From: ruq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(roleuser.Table, roleuser.Columns, nil) + _spec.From = ruq.sql if unique := ruq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if ruq.path != nil { + _spec.Unique = true } if fields := ruq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgeschema/ent/tag_query.go b/entc/integration/edgeschema/ent/tag_query.go index d31a90360e..e71c62c2e5 100644 --- a/entc/integration/edgeschema/ent/tag_query.go +++ b/entc/integration/edgeschema/ent/tag_query.go @@ -725,20 +725,12 @@ func (tq *TagQuery) sqlCount(ctx context.Context) (int, error) { } func (tq *TagQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: tag.Table, - Columns: tag.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: tag.FieldID, - }, - }, - From: tq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(tag.Table, tag.Columns, sqlgraph.NewFieldSpec(tag.FieldID, field.TypeInt)) + _spec.From = tq.sql if unique := tq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if tq.path != nil { + _spec.Unique = true } if fields := tq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgeschema/ent/tweet_query.go b/entc/integration/edgeschema/ent/tweet_query.go index 873bfa6f44..d44f51e73a 100644 --- a/entc/integration/edgeschema/ent/tweet_query.go +++ b/entc/integration/edgeschema/ent/tweet_query.go @@ -900,20 +900,12 @@ func (tq *TweetQuery) sqlCount(ctx context.Context) (int, error) { } func (tq *TweetQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: tweet.Table, - Columns: tweet.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: tweet.FieldID, - }, - }, - From: tq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(tweet.Table, tweet.Columns, sqlgraph.NewFieldSpec(tweet.FieldID, field.TypeInt)) + _spec.From = tq.sql if unique := tq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if tq.path != nil { + _spec.Unique = true } if fields := tq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgeschema/ent/tweetlike_query.go b/entc/integration/edgeschema/ent/tweetlike_query.go index db326d2f35..361fd05217 100644 --- a/entc/integration/edgeschema/ent/tweetlike_query.go +++ b/entc/integration/edgeschema/ent/tweetlike_query.go @@ -448,16 +448,12 @@ func (tlq *TweetLikeQuery) sqlCount(ctx context.Context) (int, error) { } func (tlq *TweetLikeQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: tweetlike.Table, - Columns: tweetlike.Columns, - }, - From: tlq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(tweetlike.Table, tweetlike.Columns, nil) + _spec.From = tlq.sql if unique := tlq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if tlq.path != nil { + _spec.Unique = true } if fields := tlq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgeschema/ent/tweettag_query.go b/entc/integration/edgeschema/ent/tweettag_query.go index a88fa6ca2d..612296e904 100644 --- a/entc/integration/edgeschema/ent/tweettag_query.go +++ b/entc/integration/edgeschema/ent/tweettag_query.go @@ -517,20 +517,12 @@ func (ttq *TweetTagQuery) sqlCount(ctx context.Context) (int, error) { } func (ttq *TweetTagQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: tweettag.Table, - Columns: tweettag.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeUUID, - Column: tweettag.FieldID, - }, - }, - From: ttq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(tweettag.Table, tweettag.Columns, sqlgraph.NewFieldSpec(tweettag.FieldID, field.TypeUUID)) + _spec.From = ttq.sql if unique := ttq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if ttq.path != nil { + _spec.Unique = true } if fields := ttq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgeschema/ent/user_query.go b/entc/integration/edgeschema/ent/user_query.go index 6f42e47fcc..f0e6513dba 100644 --- a/entc/integration/edgeschema/ent/user_query.go +++ b/entc/integration/edgeschema/ent/user_query.go @@ -1433,20 +1433,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgeschema/ent/usergroup_query.go b/entc/integration/edgeschema/ent/usergroup_query.go index 556d05b1e0..7c905bcf8a 100644 --- a/entc/integration/edgeschema/ent/usergroup_query.go +++ b/entc/integration/edgeschema/ent/usergroup_query.go @@ -516,20 +516,12 @@ func (ugq *UserGroupQuery) sqlCount(ctx context.Context) (int, error) { } func (ugq *UserGroupQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: usergroup.Table, - Columns: usergroup.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: usergroup.FieldID, - }, - }, - From: ugq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(usergroup.Table, usergroup.Columns, sqlgraph.NewFieldSpec(usergroup.FieldID, field.TypeInt)) + _spec.From = ugq.sql if unique := ugq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if ugq.path != nil { + _spec.Unique = true } if fields := ugq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/edgeschema/ent/usertweet_query.go b/entc/integration/edgeschema/ent/usertweet_query.go index 54aac25d07..3a675adb7b 100644 --- a/entc/integration/edgeschema/ent/usertweet_query.go +++ b/entc/integration/edgeschema/ent/usertweet_query.go @@ -516,20 +516,12 @@ func (utq *UserTweetQuery) sqlCount(ctx context.Context) (int, error) { } func (utq *UserTweetQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: usertweet.Table, - Columns: usertweet.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: usertweet.FieldID, - }, - }, - From: utq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(usertweet.Table, usertweet.Columns, sqlgraph.NewFieldSpec(usertweet.FieldID, field.TypeInt)) + _spec.From = utq.sql if unique := utq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if utq.path != nil { + _spec.Unique = true } if fields := utq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/ent/api_query.go b/entc/integration/ent/api_query.go index 2a1737aabd..23acdca2f6 100644 --- a/entc/integration/ent/api_query.go +++ b/entc/integration/ent/api_query.go @@ -354,20 +354,12 @@ func (aq *APIQuery) sqlCount(ctx context.Context) (int, error) { } func (aq *APIQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: api.Table, - Columns: api.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: api.FieldID, - }, - }, - From: aq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(api.Table, api.Columns, sqlgraph.NewFieldSpec(api.FieldID, field.TypeInt)) + _spec.From = aq.sql if unique := aq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if aq.path != nil { + _spec.Unique = true } if fields := aq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/ent/card_query.go b/entc/integration/ent/card_query.go index 05d3b25688..454e758fe2 100644 --- a/entc/integration/ent/card_query.go +++ b/entc/integration/ent/card_query.go @@ -577,20 +577,12 @@ func (cq *CardQuery) sqlCount(ctx context.Context) (int, error) { } func (cq *CardQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: card.Table, - Columns: card.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: card.FieldID, - }, - }, - From: cq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(card.Table, card.Columns, sqlgraph.NewFieldSpec(card.FieldID, field.TypeInt)) + _spec.From = cq.sql if unique := cq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if cq.path != nil { + _spec.Unique = true } if fields := cq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/ent/comment_query.go b/entc/integration/ent/comment_query.go index 5e9f0c9d3c..bb8f12a549 100644 --- a/entc/integration/ent/comment_query.go +++ b/entc/integration/ent/comment_query.go @@ -376,20 +376,12 @@ func (cq *CommentQuery) sqlCount(ctx context.Context) (int, error) { } func (cq *CommentQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: comment.Table, - Columns: comment.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: comment.FieldID, - }, - }, - From: cq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(comment.Table, comment.Columns, sqlgraph.NewFieldSpec(comment.FieldID, field.TypeInt)) + _spec.From = cq.sql if unique := cq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if cq.path != nil { + _spec.Unique = true } if fields := cq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/ent/fieldtype_query.go b/entc/integration/ent/fieldtype_query.go index 6378e0626e..b281d1cc09 100644 --- a/entc/integration/ent/fieldtype_query.go +++ b/entc/integration/ent/fieldtype_query.go @@ -381,20 +381,12 @@ func (ftq *FieldTypeQuery) sqlCount(ctx context.Context) (int, error) { } func (ftq *FieldTypeQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: fieldtype.Table, - Columns: fieldtype.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: fieldtype.FieldID, - }, - }, - From: ftq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(fieldtype.Table, fieldtype.Columns, sqlgraph.NewFieldSpec(fieldtype.FieldID, field.TypeInt)) + _spec.From = ftq.sql if unique := ftq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if ftq.path != nil { + _spec.Unique = true } if fields := ftq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/ent/file_query.go b/entc/integration/ent/file_query.go index a131073f9b..983c0957b1 100644 --- a/entc/integration/ent/file_query.go +++ b/entc/integration/ent/file_query.go @@ -622,20 +622,12 @@ func (fq *FileQuery) sqlCount(ctx context.Context) (int, error) { } func (fq *FileQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: file.Table, - Columns: file.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: file.FieldID, - }, - }, - From: fq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(file.Table, file.Columns, sqlgraph.NewFieldSpec(file.FieldID, field.TypeInt)) + _spec.From = fq.sql if unique := fq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if fq.path != nil { + _spec.Unique = true } if fields := fq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/ent/filetype_query.go b/entc/integration/ent/filetype_query.go index 7b5b4f22ed..ec579a46ab 100644 --- a/entc/integration/ent/filetype_query.go +++ b/entc/integration/ent/filetype_query.go @@ -464,20 +464,12 @@ func (ftq *FileTypeQuery) sqlCount(ctx context.Context) (int, error) { } func (ftq *FileTypeQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: filetype.Table, - Columns: filetype.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: filetype.FieldID, - }, - }, - From: ftq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(filetype.Table, filetype.Columns, sqlgraph.NewFieldSpec(filetype.FieldID, field.TypeInt)) + _spec.From = ftq.sql if unique := ftq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if ftq.path != nil { + _spec.Unique = true } if fields := ftq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/ent/goods_query.go b/entc/integration/ent/goods_query.go index a6b695f315..f5e10e5053 100644 --- a/entc/integration/ent/goods_query.go +++ b/entc/integration/ent/goods_query.go @@ -354,20 +354,12 @@ func (gq *GoodsQuery) sqlCount(ctx context.Context) (int, error) { } func (gq *GoodsQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: goods.Table, - Columns: goods.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: goods.FieldID, - }, - }, - From: gq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(goods.Table, goods.Columns, sqlgraph.NewFieldSpec(goods.FieldID, field.TypeInt)) + _spec.From = gq.sql if unique := gq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if gq.path != nil { + _spec.Unique = true } if fields := gq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/ent/group_query.go b/entc/integration/ent/group_query.go index 0ecc8f68e5..230e7d24f6 100644 --- a/entc/integration/ent/group_query.go +++ b/entc/integration/ent/group_query.go @@ -742,20 +742,12 @@ func (gq *GroupQuery) sqlCount(ctx context.Context) (int, error) { } func (gq *GroupQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: group.Table, - Columns: group.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: group.FieldID, - }, - }, - From: gq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt)) + _spec.From = gq.sql if unique := gq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if gq.path != nil { + _spec.Unique = true } if fields := gq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/ent/groupinfo_query.go b/entc/integration/ent/groupinfo_query.go index 65ffa98d24..eaa4428066 100644 --- a/entc/integration/ent/groupinfo_query.go +++ b/entc/integration/ent/groupinfo_query.go @@ -464,20 +464,12 @@ func (giq *GroupInfoQuery) sqlCount(ctx context.Context) (int, error) { } func (giq *GroupInfoQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: groupinfo.Table, - Columns: groupinfo.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: groupinfo.FieldID, - }, - }, - From: giq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(groupinfo.Table, groupinfo.Columns, sqlgraph.NewFieldSpec(groupinfo.FieldID, field.TypeInt)) + _spec.From = giq.sql if unique := giq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if giq.path != nil { + _spec.Unique = true } if fields := giq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/ent/item_query.go b/entc/integration/ent/item_query.go index 23144ec82d..99de7c6d74 100644 --- a/entc/integration/ent/item_query.go +++ b/entc/integration/ent/item_query.go @@ -376,20 +376,12 @@ func (iq *ItemQuery) sqlCount(ctx context.Context) (int, error) { } func (iq *ItemQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: item.Table, - Columns: item.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: item.FieldID, - }, - }, - From: iq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(item.Table, item.Columns, sqlgraph.NewFieldSpec(item.FieldID, field.TypeString)) + _spec.From = iq.sql if unique := iq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if iq.path != nil { + _spec.Unique = true } if fields := iq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/ent/license_query.go b/entc/integration/ent/license_query.go index 055c756bfe..b053b9c9dc 100644 --- a/entc/integration/ent/license_query.go +++ b/entc/integration/ent/license_query.go @@ -376,20 +376,12 @@ func (lq *LicenseQuery) sqlCount(ctx context.Context) (int, error) { } func (lq *LicenseQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: license.Table, - Columns: license.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: license.FieldID, - }, - }, - From: lq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(license.Table, license.Columns, sqlgraph.NewFieldSpec(license.FieldID, field.TypeInt)) + _spec.From = lq.sql if unique := lq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if lq.path != nil { + _spec.Unique = true } if fields := lq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/ent/node_query.go b/entc/integration/ent/node_query.go index edeb64c174..e484c3a938 100644 --- a/entc/integration/ent/node_query.go +++ b/entc/integration/ent/node_query.go @@ -533,20 +533,12 @@ func (nq *NodeQuery) sqlCount(ctx context.Context) (int, error) { } func (nq *NodeQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: node.Table, - Columns: node.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: node.FieldID, - }, - }, - From: nq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(node.Table, node.Columns, sqlgraph.NewFieldSpec(node.FieldID, field.TypeInt)) + _spec.From = nq.sql if unique := nq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if nq.path != nil { + _spec.Unique = true } if fields := nq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/ent/pet_query.go b/entc/integration/ent/pet_query.go index 5a74931a0a..8da1aea215 100644 --- a/entc/integration/ent/pet_query.go +++ b/entc/integration/ent/pet_query.go @@ -537,20 +537,12 @@ func (pq *PetQuery) sqlCount(ctx context.Context) (int, error) { } func (pq *PetQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: pet.Table, - Columns: pet.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: pet.FieldID, - }, - }, - From: pq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(pet.Table, pet.Columns, sqlgraph.NewFieldSpec(pet.FieldID, field.TypeInt)) + _spec.From = pq.sql if unique := pq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if pq.path != nil { + _spec.Unique = true } if fields := pq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/ent/spec_query.go b/entc/integration/ent/spec_query.go index c84a996db1..a2ff11506c 100644 --- a/entc/integration/ent/spec_query.go +++ b/entc/integration/ent/spec_query.go @@ -472,20 +472,12 @@ func (sq *SpecQuery) sqlCount(ctx context.Context) (int, error) { } func (sq *SpecQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: spec.Table, - Columns: spec.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: spec.FieldID, - }, - }, - From: sq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(spec.Table, spec.Columns, sqlgraph.NewFieldSpec(spec.FieldID, field.TypeInt)) + _spec.From = sq.sql if unique := sq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if sq.path != nil { + _spec.Unique = true } if fields := sq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/ent/task_query.go b/entc/integration/ent/task_query.go index 91fbf17164..3bd7d70200 100644 --- a/entc/integration/ent/task_query.go +++ b/entc/integration/ent/task_query.go @@ -377,20 +377,12 @@ func (tq *TaskQuery) sqlCount(ctx context.Context) (int, error) { } func (tq *TaskQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: enttask.Table, - Columns: enttask.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: enttask.FieldID, - }, - }, - From: tq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(enttask.Table, enttask.Columns, sqlgraph.NewFieldSpec(enttask.FieldID, field.TypeInt)) + _spec.From = tq.sql if unique := tq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if tq.path != nil { + _spec.Unique = true } if fields := tq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/ent/user_query.go b/entc/integration/ent/user_query.go index c79280d406..17fae28aa7 100644 --- a/entc/integration/ent/user_query.go +++ b/entc/integration/ent/user_query.go @@ -1375,20 +1375,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/hooks/ent/card_query.go b/entc/integration/hooks/ent/card_query.go index 77009428d3..21282c7d2b 100644 --- a/entc/integration/hooks/ent/card_query.go +++ b/entc/integration/hooks/ent/card_query.go @@ -455,20 +455,12 @@ func (cq *CardQuery) sqlCount(ctx context.Context) (int, error) { } func (cq *CardQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: card.Table, - Columns: card.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: card.FieldID, - }, - }, - From: cq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(card.Table, card.Columns, sqlgraph.NewFieldSpec(card.FieldID, field.TypeInt)) + _spec.From = cq.sql if unique := cq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if cq.path != nil { + _spec.Unique = true } if fields := cq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/hooks/ent/pet_query.go b/entc/integration/hooks/ent/pet_query.go index 623446f967..b260148cc0 100644 --- a/entc/integration/hooks/ent/pet_query.go +++ b/entc/integration/hooks/ent/pet_query.go @@ -455,20 +455,12 @@ func (pq *PetQuery) sqlCount(ctx context.Context) (int, error) { } func (pq *PetQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: pet.Table, - Columns: pet.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: pet.FieldID, - }, - }, - From: pq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(pet.Table, pet.Columns, sqlgraph.NewFieldSpec(pet.FieldID, field.TypeInt)) + _spec.From = pq.sql if unique := pq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if pq.path != nil { + _spec.Unique = true } if fields := pq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/hooks/ent/user_query.go b/entc/integration/hooks/ent/user_query.go index 9be32d9496..31ad24c9ef 100644 --- a/entc/integration/hooks/ent/user_query.go +++ b/entc/integration/hooks/ent/user_query.go @@ -709,20 +709,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/idtype/ent/user_query.go b/entc/integration/idtype/ent/user_query.go index d0f15d4d51..3745413a46 100644 --- a/entc/integration/idtype/ent/user_query.go +++ b/entc/integration/idtype/ent/user_query.go @@ -663,20 +663,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeUint64, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUint64)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/json/ent/user_query.go b/entc/integration/json/ent/user_query.go index bbd7428be0..1c2d1ac3df 100644 --- a/entc/integration/json/ent/user_query.go +++ b/entc/integration/json/ent/user_query.go @@ -375,20 +375,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/migrate/entv1/car_query.go b/entc/integration/migrate/entv1/car_query.go index 0b1daa3d6f..c96dc451f5 100644 --- a/entc/integration/migrate/entv1/car_query.go +++ b/entc/integration/migrate/entv1/car_query.go @@ -433,20 +433,12 @@ func (cq *CarQuery) sqlCount(ctx context.Context) (int, error) { } func (cq *CarQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: car.Table, - Columns: car.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: car.FieldID, - }, - }, - From: cq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(car.Table, car.Columns, sqlgraph.NewFieldSpec(car.FieldID, field.TypeInt)) + _spec.From = cq.sql if unique := cq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if cq.path != nil { + _spec.Unique = true } if fields := cq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/migrate/entv1/conversion_query.go b/entc/integration/migrate/entv1/conversion_query.go index 3e1dd4bdaf..b91805e0f7 100644 --- a/entc/integration/migrate/entv1/conversion_query.go +++ b/entc/integration/migrate/entv1/conversion_query.go @@ -368,20 +368,12 @@ func (cq *ConversionQuery) sqlCount(ctx context.Context) (int, error) { } func (cq *ConversionQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: conversion.Table, - Columns: conversion.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: conversion.FieldID, - }, - }, - From: cq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(conversion.Table, conversion.Columns, sqlgraph.NewFieldSpec(conversion.FieldID, field.TypeInt)) + _spec.From = cq.sql if unique := cq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if cq.path != nil { + _spec.Unique = true } if fields := cq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/migrate/entv1/customtype_query.go b/entc/integration/migrate/entv1/customtype_query.go index 8746a6bc62..5b894fb9ab 100644 --- a/entc/integration/migrate/entv1/customtype_query.go +++ b/entc/integration/migrate/entv1/customtype_query.go @@ -368,20 +368,12 @@ func (ctq *CustomTypeQuery) sqlCount(ctx context.Context) (int, error) { } func (ctq *CustomTypeQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: customtype.Table, - Columns: customtype.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: customtype.FieldID, - }, - }, - From: ctq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(customtype.Table, customtype.Columns, sqlgraph.NewFieldSpec(customtype.FieldID, field.TypeInt)) + _spec.From = ctq.sql if unique := ctq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if ctq.path != nil { + _spec.Unique = true } if fields := ctq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/migrate/entv1/user_query.go b/entc/integration/migrate/entv1/user_query.go index 003411c107..d16b8a456c 100644 --- a/entc/integration/migrate/entv1/user_query.go +++ b/entc/integration/migrate/entv1/user_query.go @@ -674,20 +674,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/migrate/entv2/blog_query.go b/entc/integration/migrate/entv2/blog_query.go index a0c6273390..22b1157179 100644 --- a/entc/integration/migrate/entv2/blog_query.go +++ b/entc/integration/migrate/entv2/blog_query.go @@ -448,20 +448,12 @@ func (bq *BlogQuery) sqlCount(ctx context.Context) (int, error) { } func (bq *BlogQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: blog.Table, - Columns: blog.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: blog.FieldID, - }, - }, - From: bq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(blog.Table, blog.Columns, sqlgraph.NewFieldSpec(blog.FieldID, field.TypeInt)) + _spec.From = bq.sql if unique := bq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if bq.path != nil { + _spec.Unique = true } if fields := bq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/migrate/entv2/car_query.go b/entc/integration/migrate/entv2/car_query.go index 4c2c56e146..88c899c6c8 100644 --- a/entc/integration/migrate/entv2/car_query.go +++ b/entc/integration/migrate/entv2/car_query.go @@ -455,20 +455,12 @@ func (cq *CarQuery) sqlCount(ctx context.Context) (int, error) { } func (cq *CarQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: car.Table, - Columns: car.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: car.FieldID, - }, - }, - From: cq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(car.Table, car.Columns, sqlgraph.NewFieldSpec(car.FieldID, field.TypeInt)) + _spec.From = cq.sql if unique := cq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if cq.path != nil { + _spec.Unique = true } if fields := cq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/migrate/entv2/conversion_query.go b/entc/integration/migrate/entv2/conversion_query.go index a5893646c6..a3f478d5c9 100644 --- a/entc/integration/migrate/entv2/conversion_query.go +++ b/entc/integration/migrate/entv2/conversion_query.go @@ -368,20 +368,12 @@ func (cq *ConversionQuery) sqlCount(ctx context.Context) (int, error) { } func (cq *ConversionQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: conversion.Table, - Columns: conversion.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: conversion.FieldID, - }, - }, - From: cq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(conversion.Table, conversion.Columns, sqlgraph.NewFieldSpec(conversion.FieldID, field.TypeInt)) + _spec.From = cq.sql if unique := cq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if cq.path != nil { + _spec.Unique = true } if fields := cq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/migrate/entv2/customtype_query.go b/entc/integration/migrate/entv2/customtype_query.go index 253f574d4b..a9e9d8e51b 100644 --- a/entc/integration/migrate/entv2/customtype_query.go +++ b/entc/integration/migrate/entv2/customtype_query.go @@ -368,20 +368,12 @@ func (ctq *CustomTypeQuery) sqlCount(ctx context.Context) (int, error) { } func (ctq *CustomTypeQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: customtype.Table, - Columns: customtype.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: customtype.FieldID, - }, - }, - From: ctq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(customtype.Table, customtype.Columns, sqlgraph.NewFieldSpec(customtype.FieldID, field.TypeInt)) + _spec.From = ctq.sql if unique := ctq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if ctq.path != nil { + _spec.Unique = true } if fields := ctq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/migrate/entv2/group_query.go b/entc/integration/migrate/entv2/group_query.go index b580b37af5..39e5981e76 100644 --- a/entc/integration/migrate/entv2/group_query.go +++ b/entc/integration/migrate/entv2/group_query.go @@ -346,20 +346,12 @@ func (gq *GroupQuery) sqlCount(ctx context.Context) (int, error) { } func (gq *GroupQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: group.Table, - Columns: group.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: group.FieldID, - }, - }, - From: gq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt)) + _spec.From = gq.sql if unique := gq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if gq.path != nil { + _spec.Unique = true } if fields := gq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/migrate/entv2/media_query.go b/entc/integration/migrate/entv2/media_query.go index a5f7598fb3..446cce2624 100644 --- a/entc/integration/migrate/entv2/media_query.go +++ b/entc/integration/migrate/entv2/media_query.go @@ -368,20 +368,12 @@ func (mq *MediaQuery) sqlCount(ctx context.Context) (int, error) { } func (mq *MediaQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: media.Table, - Columns: media.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: media.FieldID, - }, - }, - From: mq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(media.Table, media.Columns, sqlgraph.NewFieldSpec(media.FieldID, field.TypeInt)) + _spec.From = mq.sql if unique := mq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if mq.path != nil { + _spec.Unique = true } if fields := mq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/migrate/entv2/pet_query.go b/entc/integration/migrate/entv2/pet_query.go index f7a27945f1..d057ef9f7a 100644 --- a/entc/integration/migrate/entv2/pet_query.go +++ b/entc/integration/migrate/entv2/pet_query.go @@ -455,20 +455,12 @@ func (pq *PetQuery) sqlCount(ctx context.Context) (int, error) { } func (pq *PetQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: pet.Table, - Columns: pet.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: pet.FieldID, - }, - }, - From: pq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(pet.Table, pet.Columns, sqlgraph.NewFieldSpec(pet.FieldID, field.TypeInt)) + _spec.From = pq.sql if unique := pq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if pq.path != nil { + _spec.Unique = true } if fields := pq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/migrate/entv2/user_query.go b/entc/integration/migrate/entv2/user_query.go index dfbd02b1c5..7844a57ad1 100644 --- a/entc/integration/migrate/entv2/user_query.go +++ b/entc/integration/migrate/entv2/user_query.go @@ -628,20 +628,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/migrate/entv2/zoo_query.go b/entc/integration/migrate/entv2/zoo_query.go index 5b8ef1c484..648381e4bf 100644 --- a/entc/integration/migrate/entv2/zoo_query.go +++ b/entc/integration/migrate/entv2/zoo_query.go @@ -346,20 +346,12 @@ func (zq *ZooQuery) sqlCount(ctx context.Context) (int, error) { } func (zq *ZooQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: zoo.Table, - Columns: zoo.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: zoo.FieldID, - }, - }, - From: zq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(zoo.Table, zoo.Columns, sqlgraph.NewFieldSpec(zoo.FieldID, field.TypeInt)) + _spec.From = zq.sql if unique := zq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if zq.path != nil { + _spec.Unique = true } if fields := zq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/migrate/versioned/group_query.go b/entc/integration/migrate/versioned/group_query.go index 1804252ec3..c580019167 100644 --- a/entc/integration/migrate/versioned/group_query.go +++ b/entc/integration/migrate/versioned/group_query.go @@ -368,20 +368,12 @@ func (gq *GroupQuery) sqlCount(ctx context.Context) (int, error) { } func (gq *GroupQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: group.Table, - Columns: group.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: group.FieldID, - }, - }, - From: gq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt)) + _spec.From = gq.sql if unique := gq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if gq.path != nil { + _spec.Unique = true } if fields := gq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/migrate/versioned/user_query.go b/entc/integration/migrate/versioned/user_query.go index c747ead2bf..68d5a097df 100644 --- a/entc/integration/migrate/versioned/user_query.go +++ b/entc/integration/migrate/versioned/user_query.go @@ -368,20 +368,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/multischema/ent/friendship_query.go b/entc/integration/multischema/ent/friendship_query.go index 7299997ce4..25db4e9505 100644 --- a/entc/integration/multischema/ent/friendship_query.go +++ b/entc/integration/multischema/ent/friendship_query.go @@ -533,20 +533,12 @@ func (fq *FriendshipQuery) sqlCount(ctx context.Context) (int, error) { } func (fq *FriendshipQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: friendship.Table, - Columns: friendship.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: friendship.FieldID, - }, - }, - From: fq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(friendship.Table, friendship.Columns, sqlgraph.NewFieldSpec(friendship.FieldID, field.TypeInt)) + _spec.From = fq.sql if unique := fq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if fq.path != nil { + _spec.Unique = true } if fields := fq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/multischema/ent/group_query.go b/entc/integration/multischema/ent/group_query.go index f64cc6c268..44a1eb3d31 100644 --- a/entc/integration/multischema/ent/group_query.go +++ b/entc/integration/multischema/ent/group_query.go @@ -494,20 +494,12 @@ func (gq *GroupQuery) sqlCount(ctx context.Context) (int, error) { } func (gq *GroupQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: group.Table, - Columns: group.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: group.FieldID, - }, - }, - From: gq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt)) + _spec.From = gq.sql if unique := gq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if gq.path != nil { + _spec.Unique = true } if fields := gq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/multischema/ent/pet_query.go b/entc/integration/multischema/ent/pet_query.go index 06213c52e3..ba93b90719 100644 --- a/entc/integration/multischema/ent/pet_query.go +++ b/entc/integration/multischema/ent/pet_query.go @@ -459,20 +459,12 @@ func (pq *PetQuery) sqlCount(ctx context.Context) (int, error) { } func (pq *PetQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: pet.Table, - Columns: pet.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: pet.FieldID, - }, - }, - From: pq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(pet.Table, pet.Columns, sqlgraph.NewFieldSpec(pet.FieldID, field.TypeInt)) + _spec.From = pq.sql if unique := pq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if pq.path != nil { + _spec.Unique = true } if fields := pq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/multischema/ent/user_query.go b/entc/integration/multischema/ent/user_query.go index c620a07d7a..4832194e80 100644 --- a/entc/integration/multischema/ent/user_query.go +++ b/entc/integration/multischema/ent/user_query.go @@ -750,20 +750,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/privacy/ent/task_query.go b/entc/integration/privacy/ent/task_query.go index f641b2d938..36c86d5ce2 100644 --- a/entc/integration/privacy/ent/task_query.go +++ b/entc/integration/privacy/ent/task_query.go @@ -568,20 +568,12 @@ func (tq *TaskQuery) sqlCount(ctx context.Context) (int, error) { } func (tq *TaskQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: task.Table, - Columns: task.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: task.FieldID, - }, - }, - From: tq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(task.Table, task.Columns, sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt)) + _spec.From = tq.sql if unique := tq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if tq.path != nil { + _spec.Unique = true } if fields := tq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/privacy/ent/team_query.go b/entc/integration/privacy/ent/team_query.go index b4f86ca06f..ab8b732216 100644 --- a/entc/integration/privacy/ent/team_query.go +++ b/entc/integration/privacy/ent/team_query.go @@ -590,20 +590,12 @@ func (tq *TeamQuery) sqlCount(ctx context.Context) (int, error) { } func (tq *TeamQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: team.Table, - Columns: team.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: team.FieldID, - }, - }, - From: tq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(team.Table, team.Columns, sqlgraph.NewFieldSpec(team.FieldID, field.TypeInt)) + _spec.From = tq.sql if unique := tq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if tq.path != nil { + _spec.Unique = true } if fields := tq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/privacy/ent/user_query.go b/entc/integration/privacy/ent/user_query.go index 9e8c16c493..43f57138bb 100644 --- a/entc/integration/privacy/ent/user_query.go +++ b/entc/integration/privacy/ent/user_query.go @@ -560,20 +560,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/template/ent/group_query.go b/entc/integration/template/ent/group_query.go index 3f841b8835..dab3942d8c 100644 --- a/entc/integration/template/ent/group_query.go +++ b/entc/integration/template/ent/group_query.go @@ -377,20 +377,12 @@ func (gq *GroupQuery) sqlCount(ctx context.Context) (int, error) { } func (gq *GroupQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: group.Table, - Columns: group.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: group.FieldID, - }, - }, - From: gq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt)) + _spec.From = gq.sql if unique := gq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if gq.path != nil { + _spec.Unique = true } if fields := gq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/template/ent/pet_query.go b/entc/integration/template/ent/pet_query.go index b1859e8006..cc0e317876 100644 --- a/entc/integration/template/ent/pet_query.go +++ b/entc/integration/template/ent/pet_query.go @@ -464,20 +464,12 @@ func (pq *PetQuery) sqlCount(ctx context.Context) (int, error) { } func (pq *PetQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: pet.Table, - Columns: pet.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: pet.FieldID, - }, - }, - From: pq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(pet.Table, pet.Columns, sqlgraph.NewFieldSpec(pet.FieldID, field.TypeInt)) + _spec.From = pq.sql if unique := pq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if pq.path != nil { + _spec.Unique = true } if fields := pq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/entc/integration/template/ent/user_query.go b/entc/integration/template/ent/user_query.go index 519ad5831c..36f6f97560 100644 --- a/entc/integration/template/ent/user_query.go +++ b/entc/integration/template/ent/user_query.go @@ -561,20 +561,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/edgeindex/ent/city_query.go b/examples/edgeindex/ent/city_query.go index 32eba9c06b..0517e66e1c 100644 --- a/examples/edgeindex/ent/city_query.go +++ b/examples/edgeindex/ent/city_query.go @@ -448,20 +448,12 @@ func (cq *CityQuery) sqlCount(ctx context.Context) (int, error) { } func (cq *CityQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: city.Table, - Columns: city.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: city.FieldID, - }, - }, - From: cq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(city.Table, city.Columns, sqlgraph.NewFieldSpec(city.FieldID, field.TypeInt)) + _spec.From = cq.sql if unique := cq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if cq.path != nil { + _spec.Unique = true } if fields := cq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/edgeindex/ent/street_query.go b/examples/edgeindex/ent/street_query.go index 5296cf3d07..a0325b00b0 100644 --- a/examples/edgeindex/ent/street_query.go +++ b/examples/edgeindex/ent/street_query.go @@ -455,20 +455,12 @@ func (sq *StreetQuery) sqlCount(ctx context.Context) (int, error) { } func (sq *StreetQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: street.Table, - Columns: street.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: street.FieldID, - }, - }, - From: sq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(street.Table, street.Columns, sqlgraph.NewFieldSpec(street.FieldID, field.TypeInt)) + _spec.From = sq.sql if unique := sq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if sq.path != nil { + _spec.Unique = true } if fields := sq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/encryptfield/ent/user_query.go b/examples/encryptfield/ent/user_query.go index 74dbc959b0..9b0fed78a9 100644 --- a/examples/encryptfield/ent/user_query.go +++ b/examples/encryptfield/ent/user_query.go @@ -368,20 +368,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/entcpkg/ent/user_query.go b/examples/entcpkg/ent/user_query.go index 98e8becaf2..547457340c 100644 --- a/examples/entcpkg/ent/user_query.go +++ b/examples/entcpkg/ent/user_query.go @@ -368,20 +368,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/fs/ent/file_query.go b/examples/fs/ent/file_query.go index a8d3f2ccb2..47f0989876 100644 --- a/examples/fs/ent/file_query.go +++ b/examples/fs/ent/file_query.go @@ -514,20 +514,12 @@ func (fq *FileQuery) sqlCount(ctx context.Context) (int, error) { } func (fq *FileQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: file.Table, - Columns: file.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: file.FieldID, - }, - }, - From: fq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(file.Table, file.Columns, sqlgraph.NewFieldSpec(file.FieldID, field.TypeInt)) + _spec.From = fq.sql if unique := fq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if fq.path != nil { + _spec.Unique = true } if fields := fq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/jsonencode/ent/card_query.go b/examples/jsonencode/ent/card_query.go index 19289a3688..4cf11d4234 100644 --- a/examples/jsonencode/ent/card_query.go +++ b/examples/jsonencode/ent/card_query.go @@ -368,20 +368,12 @@ func (cq *CardQuery) sqlCount(ctx context.Context) (int, error) { } func (cq *CardQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: card.Table, - Columns: card.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: card.FieldID, - }, - }, - From: cq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(card.Table, card.Columns, sqlgraph.NewFieldSpec(card.FieldID, field.TypeInt)) + _spec.From = cq.sql if unique := cq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if cq.path != nil { + _spec.Unique = true } if fields := cq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/jsonencode/ent/pet_query.go b/examples/jsonencode/ent/pet_query.go index 6deab0cd28..5354e1efb7 100644 --- a/examples/jsonencode/ent/pet_query.go +++ b/examples/jsonencode/ent/pet_query.go @@ -444,20 +444,12 @@ func (pq *PetQuery) sqlCount(ctx context.Context) (int, error) { } func (pq *PetQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: pet.Table, - Columns: pet.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: pet.FieldID, - }, - }, - From: pq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(pet.Table, pet.Columns, sqlgraph.NewFieldSpec(pet.FieldID, field.TypeInt)) + _spec.From = pq.sql if unique := pq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if pq.path != nil { + _spec.Unique = true } if fields := pq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/jsonencode/ent/user_query.go b/examples/jsonencode/ent/user_query.go index fcfedff6e6..c7da2d1473 100644 --- a/examples/jsonencode/ent/user_query.go +++ b/examples/jsonencode/ent/user_query.go @@ -444,20 +444,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/m2m2types/ent/group_query.go b/examples/m2m2types/ent/group_query.go index 121775dc2e..406f44e14b 100644 --- a/examples/m2m2types/ent/group_query.go +++ b/examples/m2m2types/ent/group_query.go @@ -478,20 +478,12 @@ func (gq *GroupQuery) sqlCount(ctx context.Context) (int, error) { } func (gq *GroupQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: group.Table, - Columns: group.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: group.FieldID, - }, - }, - From: gq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt)) + _spec.From = gq.sql if unique := gq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if gq.path != nil { + _spec.Unique = true } if fields := gq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/m2m2types/ent/user_query.go b/examples/m2m2types/ent/user_query.go index a3b476d7f6..5e3b2d1a50 100644 --- a/examples/m2m2types/ent/user_query.go +++ b/examples/m2m2types/ent/user_query.go @@ -478,20 +478,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/m2mbidi/ent/user_query.go b/examples/m2mbidi/ent/user_query.go index 20e0a7e53a..9ac1123564 100644 --- a/examples/m2mbidi/ent/user_query.go +++ b/examples/m2mbidi/ent/user_query.go @@ -477,20 +477,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/m2mrecur/ent/user_query.go b/examples/m2mrecur/ent/user_query.go index 0f8a68f77c..6bdf8357c5 100644 --- a/examples/m2mrecur/ent/user_query.go +++ b/examples/m2mrecur/ent/user_query.go @@ -581,20 +581,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/migration/ent/card_query.go b/examples/migration/ent/card_query.go index dca8be521f..59ddee6dce 100644 --- a/examples/migration/ent/card_query.go +++ b/examples/migration/ent/card_query.go @@ -444,20 +444,12 @@ func (cq *CardQuery) sqlCount(ctx context.Context) (int, error) { } func (cq *CardQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: card.Table, - Columns: card.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: card.FieldID, - }, - }, - From: cq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(card.Table, card.Columns, sqlgraph.NewFieldSpec(card.FieldID, field.TypeInt)) + _spec.From = cq.sql if unique := cq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if cq.path != nil { + _spec.Unique = true } if fields := cq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/migration/ent/pet_query.go b/examples/migration/ent/pet_query.go index 8ebbda75bd..8947f59a1a 100644 --- a/examples/migration/ent/pet_query.go +++ b/examples/migration/ent/pet_query.go @@ -516,20 +516,12 @@ func (pq *PetQuery) sqlCount(ctx context.Context) (int, error) { } func (pq *PetQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: pet.Table, - Columns: pet.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeUUID, - Column: pet.FieldID, - }, - }, - From: pq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(pet.Table, pet.Columns, sqlgraph.NewFieldSpec(pet.FieldID, field.TypeUUID)) + _spec.From = pq.sql if unique := pq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if pq.path != nil { + _spec.Unique = true } if fields := pq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/migration/ent/user_query.go b/examples/migration/ent/user_query.go index 2a9477516d..b02780d673 100644 --- a/examples/migration/ent/user_query.go +++ b/examples/migration/ent/user_query.go @@ -444,20 +444,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/o2m2types/ent/pet_query.go b/examples/o2m2types/ent/pet_query.go index e7dbe1fc1f..675782fd9b 100644 --- a/examples/o2m2types/ent/pet_query.go +++ b/examples/o2m2types/ent/pet_query.go @@ -455,20 +455,12 @@ func (pq *PetQuery) sqlCount(ctx context.Context) (int, error) { } func (pq *PetQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: pet.Table, - Columns: pet.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: pet.FieldID, - }, - }, - From: pq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(pet.Table, pet.Columns, sqlgraph.NewFieldSpec(pet.FieldID, field.TypeInt)) + _spec.From = pq.sql if unique := pq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if pq.path != nil { + _spec.Unique = true } if fields := pq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/o2m2types/ent/user_query.go b/examples/o2m2types/ent/user_query.go index b97be5813b..49e713f64c 100644 --- a/examples/o2m2types/ent/user_query.go +++ b/examples/o2m2types/ent/user_query.go @@ -448,20 +448,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/o2mrecur/ent/node_query.go b/examples/o2mrecur/ent/node_query.go index 43cb318def..7138249244 100644 --- a/examples/o2mrecur/ent/node_query.go +++ b/examples/o2mrecur/ent/node_query.go @@ -514,20 +514,12 @@ func (nq *NodeQuery) sqlCount(ctx context.Context) (int, error) { } func (nq *NodeQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: node.Table, - Columns: node.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: node.FieldID, - }, - }, - From: nq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(node.Table, node.Columns, sqlgraph.NewFieldSpec(node.FieldID, field.TypeInt)) + _spec.From = nq.sql if unique := nq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if nq.path != nil { + _spec.Unique = true } if fields := nq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/o2o2types/ent/card_query.go b/examples/o2o2types/ent/card_query.go index f6f58a2967..ce5c33db63 100644 --- a/examples/o2o2types/ent/card_query.go +++ b/examples/o2o2types/ent/card_query.go @@ -455,20 +455,12 @@ func (cq *CardQuery) sqlCount(ctx context.Context) (int, error) { } func (cq *CardQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: card.Table, - Columns: card.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: card.FieldID, - }, - }, - From: cq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(card.Table, card.Columns, sqlgraph.NewFieldSpec(card.FieldID, field.TypeInt)) + _spec.From = cq.sql if unique := cq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if cq.path != nil { + _spec.Unique = true } if fields := cq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/o2o2types/ent/user_query.go b/examples/o2o2types/ent/user_query.go index 721ab11777..0943c489aa 100644 --- a/examples/o2o2types/ent/user_query.go +++ b/examples/o2o2types/ent/user_query.go @@ -444,20 +444,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/o2obidi/ent/user_query.go b/examples/o2obidi/ent/user_query.go index 14a627318a..d934a61da0 100644 --- a/examples/o2obidi/ent/user_query.go +++ b/examples/o2obidi/ent/user_query.go @@ -454,20 +454,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/o2orecur/ent/node_query.go b/examples/o2orecur/ent/node_query.go index c92be0914d..c893446e8d 100644 --- a/examples/o2orecur/ent/node_query.go +++ b/examples/o2orecur/ent/node_query.go @@ -510,20 +510,12 @@ func (nq *NodeQuery) sqlCount(ctx context.Context) (int, error) { } func (nq *NodeQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: node.Table, - Columns: node.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: node.FieldID, - }, - }, - From: nq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(node.Table, node.Columns, sqlgraph.NewFieldSpec(node.FieldID, field.TypeInt)) + _spec.From = nq.sql if unique := nq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if nq.path != nil { + _spec.Unique = true } if fields := nq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/privacyadmin/ent/user_query.go b/examples/privacyadmin/ent/user_query.go index 2c55dcd3bb..d48dbce699 100644 --- a/examples/privacyadmin/ent/user_query.go +++ b/examples/privacyadmin/ent/user_query.go @@ -375,20 +375,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/privacytenant/ent/group_query.go b/examples/privacytenant/ent/group_query.go index bf0f480a60..9fd408a326 100644 --- a/examples/privacytenant/ent/group_query.go +++ b/examples/privacytenant/ent/group_query.go @@ -557,20 +557,12 @@ func (gq *GroupQuery) sqlCount(ctx context.Context) (int, error) { } func (gq *GroupQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: group.Table, - Columns: group.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: group.FieldID, - }, - }, - From: gq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt)) + _spec.From = gq.sql if unique := gq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if gq.path != nil { + _spec.Unique = true } if fields := gq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/privacytenant/ent/tenant_query.go b/examples/privacytenant/ent/tenant_query.go index d9c20bd24d..29a5c229cb 100644 --- a/examples/privacytenant/ent/tenant_query.go +++ b/examples/privacytenant/ent/tenant_query.go @@ -375,20 +375,12 @@ func (tq *TenantQuery) sqlCount(ctx context.Context) (int, error) { } func (tq *TenantQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: tenant.Table, - Columns: tenant.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: tenant.FieldID, - }, - }, - From: tq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(tenant.Table, tenant.Columns, sqlgraph.NewFieldSpec(tenant.FieldID, field.TypeInt)) + _spec.From = tq.sql if unique := tq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if tq.path != nil { + _spec.Unique = true } if fields := tq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/privacytenant/ent/user_query.go b/examples/privacytenant/ent/user_query.go index cc4d73b453..f3f9ad0a90 100644 --- a/examples/privacytenant/ent/user_query.go +++ b/examples/privacytenant/ent/user_query.go @@ -557,20 +557,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/start/ent/car_query.go b/examples/start/ent/car_query.go index ad1181c022..b35792a5d4 100644 --- a/examples/start/ent/car_query.go +++ b/examples/start/ent/car_query.go @@ -455,20 +455,12 @@ func (cq *CarQuery) sqlCount(ctx context.Context) (int, error) { } func (cq *CarQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: car.Table, - Columns: car.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: car.FieldID, - }, - }, - From: cq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(car.Table, car.Columns, sqlgraph.NewFieldSpec(car.FieldID, field.TypeInt)) + _spec.From = cq.sql if unique := cq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if cq.path != nil { + _spec.Unique = true } if fields := cq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/start/ent/group_query.go b/examples/start/ent/group_query.go index 875af8add8..2ae9d50102 100644 --- a/examples/start/ent/group_query.go +++ b/examples/start/ent/group_query.go @@ -478,20 +478,12 @@ func (gq *GroupQuery) sqlCount(ctx context.Context) (int, error) { } func (gq *GroupQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: group.Table, - Columns: group.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: group.FieldID, - }, - }, - From: gq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt)) + _spec.From = gq.sql if unique := gq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if gq.path != nil { + _spec.Unique = true } if fields := gq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/start/ent/user_query.go b/examples/start/ent/user_query.go index 766566c288..ecfd18c41c 100644 --- a/examples/start/ent/user_query.go +++ b/examples/start/ent/user_query.go @@ -553,20 +553,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/traversal/ent/group_query.go b/examples/traversal/ent/group_query.go index 32c0bb4c47..085b80441c 100644 --- a/examples/traversal/ent/group_query.go +++ b/examples/traversal/ent/group_query.go @@ -560,20 +560,12 @@ func (gq *GroupQuery) sqlCount(ctx context.Context) (int, error) { } func (gq *GroupQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: group.Table, - Columns: group.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: group.FieldID, - }, - }, - From: gq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt)) + _spec.From = gq.sql if unique := gq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if gq.path != nil { + _spec.Unique = true } if fields := gq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/traversal/ent/pet_query.go b/examples/traversal/ent/pet_query.go index 236eab7e77..7c22deaaa5 100644 --- a/examples/traversal/ent/pet_query.go +++ b/examples/traversal/ent/pet_query.go @@ -560,20 +560,12 @@ func (pq *PetQuery) sqlCount(ctx context.Context) (int, error) { } func (pq *PetQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: pet.Table, - Columns: pet.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: pet.FieldID, - }, - }, - From: pq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(pet.Table, pet.Columns, sqlgraph.NewFieldSpec(pet.FieldID, field.TypeInt)) + _spec.From = pq.sql if unique := pq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if pq.path != nil { + _spec.Unique = true } if fields := pq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/traversal/ent/user_query.go b/examples/traversal/ent/user_query.go index df0af0f452..c648e8809b 100644 --- a/examples/traversal/ent/user_query.go +++ b/examples/traversal/ent/user_query.go @@ -731,20 +731,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/examples/version/ent/user_query.go b/examples/version/ent/user_query.go index 5ed0b08a0b..09f018606f 100644 --- a/examples/version/ent/user_query.go +++ b/examples/version/ent/user_query.go @@ -368,20 +368,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { } func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt)) + _spec.From = uq.sql if unique := uq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if uq.path != nil { + _spec.Unique = true } if fields := uq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields))