From 89280cbe031bce8ffa237e3f0845d49b3accc181 Mon Sep 17 00:00:00 2001 From: Kairo Araujo Date: Tue, 20 Aug 2024 15:01:22 +0200 Subject: [PATCH] build: auto-generated ent Signed-off-by: Kairo Araujo --- ent.resolvers.go | 2 +- ent/attestation_create.go | 2 +- ent/attestation_query.go | 21 +++++++++++---------- ent/attestation_update.go | 4 ++-- ent/attestationcollection_create.go | 2 +- ent/attestationcollection_query.go | 21 +++++++++++---------- ent/attestationcollection_update.go | 4 ++-- ent/attestationpolicy_query.go | 21 +++++++++++---------- ent/dsse_query.go | 21 +++++++++++---------- ent/ent.go | 2 +- ent/payloaddigest_query.go | 21 +++++++++++---------- ent/runtime.go | 4 ---- ent/runtime/runtime.go | 4 ++-- ent/signature/signature.go | 2 -- ent/signature_create.go | 5 ----- ent/signature_query.go | 21 +++++++++++---------- ent/signature_update.go | 10 ---------- ent/statement_query.go | 21 +++++++++++---------- ent/subject_query.go | 21 +++++++++++---------- ent/subjectdigest_query.go | 21 +++++++++++---------- ent/timestamp_query.go | 21 +++++++++++---------- 21 files changed, 120 insertions(+), 131 deletions(-) diff --git a/ent.resolvers.go b/ent.resolvers.go index df8beee0..917610ec 100644 --- a/ent.resolvers.go +++ b/ent.resolvers.go @@ -2,7 +2,7 @@ package archivista // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.47 +// Code generated by github.com/99designs/gqlgen version v0.17.49 import ( "context" diff --git a/ent/attestation_create.go b/ent/attestation_create.go index d3233cfd..dcbaf27b 100644 --- a/ent/attestation_create.go +++ b/ent/attestation_create.go @@ -103,7 +103,7 @@ func (ac *AttestationCreate) check() error { return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Attestation.type": %w`, err)} } } - if _, ok := ac.mutation.AttestationCollectionID(); !ok { + if len(ac.mutation.AttestationCollectionIDs()) == 0 { return &ValidationError{Name: "attestation_collection", err: errors.New(`ent: missing required edge "Attestation.attestation_collection"`)} } return nil diff --git a/ent/attestation_query.go b/ent/attestation_query.go index c85b962b..800383b2 100644 --- a/ent/attestation_query.go +++ b/ent/attestation_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -88,7 +89,7 @@ func (aq *AttestationQuery) QueryAttestationCollection() *AttestationCollectionQ // First returns the first Attestation entity from the query. // Returns a *NotFoundError when no Attestation was found. func (aq *AttestationQuery) First(ctx context.Context) (*Attestation, error) { - nodes, err := aq.Limit(1).All(setContextOp(ctx, aq.ctx, "First")) + nodes, err := aq.Limit(1).All(setContextOp(ctx, aq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -111,7 +112,7 @@ func (aq *AttestationQuery) FirstX(ctx context.Context) *Attestation { // Returns a *NotFoundError when no Attestation ID was found. func (aq *AttestationQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = aq.Limit(1).IDs(setContextOp(ctx, aq.ctx, "FirstID")); err != nil { + if ids, err = aq.Limit(1).IDs(setContextOp(ctx, aq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -134,7 +135,7 @@ func (aq *AttestationQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one Attestation entity is found. // Returns a *NotFoundError when no Attestation entities are found. func (aq *AttestationQuery) Only(ctx context.Context) (*Attestation, error) { - nodes, err := aq.Limit(2).All(setContextOp(ctx, aq.ctx, "Only")) + nodes, err := aq.Limit(2).All(setContextOp(ctx, aq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -162,7 +163,7 @@ func (aq *AttestationQuery) OnlyX(ctx context.Context) *Attestation { // Returns a *NotFoundError when no entities are found. func (aq *AttestationQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = aq.Limit(2).IDs(setContextOp(ctx, aq.ctx, "OnlyID")); err != nil { + if ids, err = aq.Limit(2).IDs(setContextOp(ctx, aq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -187,7 +188,7 @@ func (aq *AttestationQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of Attestations. func (aq *AttestationQuery) All(ctx context.Context) ([]*Attestation, error) { - ctx = setContextOp(ctx, aq.ctx, "All") + ctx = setContextOp(ctx, aq.ctx, ent.OpQueryAll) if err := aq.prepareQuery(ctx); err != nil { return nil, err } @@ -209,7 +210,7 @@ func (aq *AttestationQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error if aq.ctx.Unique == nil && aq.path != nil { aq.Unique(true) } - ctx = setContextOp(ctx, aq.ctx, "IDs") + ctx = setContextOp(ctx, aq.ctx, ent.OpQueryIDs) if err = aq.Select(attestation.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -227,7 +228,7 @@ func (aq *AttestationQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (aq *AttestationQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, aq.ctx, "Count") + ctx = setContextOp(ctx, aq.ctx, ent.OpQueryCount) if err := aq.prepareQuery(ctx); err != nil { return 0, err } @@ -245,7 +246,7 @@ func (aq *AttestationQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (aq *AttestationQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, aq.ctx, "Exist") + ctx = setContextOp(ctx, aq.ctx, ent.OpQueryExist) switch _, err := aq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -550,7 +551,7 @@ func (agb *AttestationGroupBy) Aggregate(fns ...AggregateFunc) *AttestationGroup // Scan applies the selector query and scans the result into the given value. func (agb *AttestationGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, agb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, agb.build.ctx, ent.OpQueryGroupBy) if err := agb.build.prepareQuery(ctx); err != nil { return err } @@ -598,7 +599,7 @@ func (as *AttestationSelect) Aggregate(fns ...AggregateFunc) *AttestationSelect // Scan applies the selector query and scans the result into the given value. func (as *AttestationSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, as.ctx, "Select") + ctx = setContextOp(ctx, as.ctx, ent.OpQuerySelect) if err := as.prepareQuery(ctx); err != nil { return err } diff --git a/ent/attestation_update.go b/ent/attestation_update.go index 08d5d1e4..5322da43 100644 --- a/ent/attestation_update.go +++ b/ent/attestation_update.go @@ -99,7 +99,7 @@ func (au *AttestationUpdate) check() error { return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Attestation.type": %w`, err)} } } - if _, ok := au.mutation.AttestationCollectionID(); au.mutation.AttestationCollectionCleared() && !ok { + if au.mutation.AttestationCollectionCleared() && len(au.mutation.AttestationCollectionIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Attestation.attestation_collection"`) } return nil @@ -252,7 +252,7 @@ func (auo *AttestationUpdateOne) check() error { return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Attestation.type": %w`, err)} } } - if _, ok := auo.mutation.AttestationCollectionID(); auo.mutation.AttestationCollectionCleared() && !ok { + if auo.mutation.AttestationCollectionCleared() && len(auo.mutation.AttestationCollectionIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Attestation.attestation_collection"`) } return nil diff --git a/ent/attestationcollection_create.go b/ent/attestationcollection_create.go index 2fa8080e..cc2d119a 100644 --- a/ent/attestationcollection_create.go +++ b/ent/attestationcollection_create.go @@ -119,7 +119,7 @@ func (acc *AttestationCollectionCreate) check() error { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "AttestationCollection.name": %w`, err)} } } - if _, ok := acc.mutation.StatementID(); !ok { + if len(acc.mutation.StatementIDs()) == 0 { return &ValidationError{Name: "statement", err: errors.New(`ent: missing required edge "AttestationCollection.statement"`)} } return nil diff --git a/ent/attestationcollection_query.go b/ent/attestationcollection_query.go index d7ce19dd..4d9a12b5 100644 --- a/ent/attestationcollection_query.go +++ b/ent/attestationcollection_query.go @@ -8,6 +8,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -114,7 +115,7 @@ func (acq *AttestationCollectionQuery) QueryStatement() *StatementQuery { // First returns the first AttestationCollection entity from the query. // Returns a *NotFoundError when no AttestationCollection was found. func (acq *AttestationCollectionQuery) First(ctx context.Context) (*AttestationCollection, error) { - nodes, err := acq.Limit(1).All(setContextOp(ctx, acq.ctx, "First")) + nodes, err := acq.Limit(1).All(setContextOp(ctx, acq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -137,7 +138,7 @@ func (acq *AttestationCollectionQuery) FirstX(ctx context.Context) *AttestationC // Returns a *NotFoundError when no AttestationCollection ID was found. func (acq *AttestationCollectionQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = acq.Limit(1).IDs(setContextOp(ctx, acq.ctx, "FirstID")); err != nil { + if ids, err = acq.Limit(1).IDs(setContextOp(ctx, acq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -160,7 +161,7 @@ func (acq *AttestationCollectionQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one AttestationCollection entity is found. // Returns a *NotFoundError when no AttestationCollection entities are found. func (acq *AttestationCollectionQuery) Only(ctx context.Context) (*AttestationCollection, error) { - nodes, err := acq.Limit(2).All(setContextOp(ctx, acq.ctx, "Only")) + nodes, err := acq.Limit(2).All(setContextOp(ctx, acq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -188,7 +189,7 @@ func (acq *AttestationCollectionQuery) OnlyX(ctx context.Context) *AttestationCo // Returns a *NotFoundError when no entities are found. func (acq *AttestationCollectionQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = acq.Limit(2).IDs(setContextOp(ctx, acq.ctx, "OnlyID")); err != nil { + if ids, err = acq.Limit(2).IDs(setContextOp(ctx, acq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -213,7 +214,7 @@ func (acq *AttestationCollectionQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of AttestationCollections. func (acq *AttestationCollectionQuery) All(ctx context.Context) ([]*AttestationCollection, error) { - ctx = setContextOp(ctx, acq.ctx, "All") + ctx = setContextOp(ctx, acq.ctx, ent.OpQueryAll) if err := acq.prepareQuery(ctx); err != nil { return nil, err } @@ -235,7 +236,7 @@ func (acq *AttestationCollectionQuery) IDs(ctx context.Context) (ids []uuid.UUID if acq.ctx.Unique == nil && acq.path != nil { acq.Unique(true) } - ctx = setContextOp(ctx, acq.ctx, "IDs") + ctx = setContextOp(ctx, acq.ctx, ent.OpQueryIDs) if err = acq.Select(attestationcollection.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -253,7 +254,7 @@ func (acq *AttestationCollectionQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (acq *AttestationCollectionQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, acq.ctx, "Count") + ctx = setContextOp(ctx, acq.ctx, ent.OpQueryCount) if err := acq.prepareQuery(ctx); err != nil { return 0, err } @@ -271,7 +272,7 @@ func (acq *AttestationCollectionQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (acq *AttestationCollectionQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, acq.ctx, "Exist") + ctx = setContextOp(ctx, acq.ctx, ent.OpQueryExist) switch _, err := acq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -648,7 +649,7 @@ func (acgb *AttestationCollectionGroupBy) Aggregate(fns ...AggregateFunc) *Attes // Scan applies the selector query and scans the result into the given value. func (acgb *AttestationCollectionGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, acgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, acgb.build.ctx, ent.OpQueryGroupBy) if err := acgb.build.prepareQuery(ctx); err != nil { return err } @@ -696,7 +697,7 @@ func (acs *AttestationCollectionSelect) Aggregate(fns ...AggregateFunc) *Attesta // Scan applies the selector query and scans the result into the given value. func (acs *AttestationCollectionSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, acs.ctx, "Select") + ctx = setContextOp(ctx, acs.ctx, ent.OpQuerySelect) if err := acs.prepareQuery(ctx); err != nil { return err } diff --git a/ent/attestationcollection_update.go b/ent/attestationcollection_update.go index 7234cf19..8096572c 100644 --- a/ent/attestationcollection_update.go +++ b/ent/attestationcollection_update.go @@ -136,7 +136,7 @@ func (acu *AttestationCollectionUpdate) check() error { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "AttestationCollection.name": %w`, err)} } } - if _, ok := acu.mutation.StatementID(); acu.mutation.StatementCleared() && !ok { + if acu.mutation.StatementCleared() && len(acu.mutation.StatementIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "AttestationCollection.statement"`) } return nil @@ -370,7 +370,7 @@ func (acuo *AttestationCollectionUpdateOne) check() error { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "AttestationCollection.name": %w`, err)} } } - if _, ok := acuo.mutation.StatementID(); acuo.mutation.StatementCleared() && !ok { + if acuo.mutation.StatementCleared() && len(acuo.mutation.StatementIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "AttestationCollection.statement"`) } return nil diff --git a/ent/attestationpolicy_query.go b/ent/attestationpolicy_query.go index eed10743..831cc320 100644 --- a/ent/attestationpolicy_query.go +++ b/ent/attestationpolicy_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -88,7 +89,7 @@ func (apq *AttestationPolicyQuery) QueryStatement() *StatementQuery { // First returns the first AttestationPolicy entity from the query. // Returns a *NotFoundError when no AttestationPolicy was found. func (apq *AttestationPolicyQuery) First(ctx context.Context) (*AttestationPolicy, error) { - nodes, err := apq.Limit(1).All(setContextOp(ctx, apq.ctx, "First")) + nodes, err := apq.Limit(1).All(setContextOp(ctx, apq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -111,7 +112,7 @@ func (apq *AttestationPolicyQuery) FirstX(ctx context.Context) *AttestationPolic // Returns a *NotFoundError when no AttestationPolicy ID was found. func (apq *AttestationPolicyQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = apq.Limit(1).IDs(setContextOp(ctx, apq.ctx, "FirstID")); err != nil { + if ids, err = apq.Limit(1).IDs(setContextOp(ctx, apq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -134,7 +135,7 @@ func (apq *AttestationPolicyQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one AttestationPolicy entity is found. // Returns a *NotFoundError when no AttestationPolicy entities are found. func (apq *AttestationPolicyQuery) Only(ctx context.Context) (*AttestationPolicy, error) { - nodes, err := apq.Limit(2).All(setContextOp(ctx, apq.ctx, "Only")) + nodes, err := apq.Limit(2).All(setContextOp(ctx, apq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -162,7 +163,7 @@ func (apq *AttestationPolicyQuery) OnlyX(ctx context.Context) *AttestationPolicy // Returns a *NotFoundError when no entities are found. func (apq *AttestationPolicyQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = apq.Limit(2).IDs(setContextOp(ctx, apq.ctx, "OnlyID")); err != nil { + if ids, err = apq.Limit(2).IDs(setContextOp(ctx, apq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -187,7 +188,7 @@ func (apq *AttestationPolicyQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of AttestationPolicies. func (apq *AttestationPolicyQuery) All(ctx context.Context) ([]*AttestationPolicy, error) { - ctx = setContextOp(ctx, apq.ctx, "All") + ctx = setContextOp(ctx, apq.ctx, ent.OpQueryAll) if err := apq.prepareQuery(ctx); err != nil { return nil, err } @@ -209,7 +210,7 @@ func (apq *AttestationPolicyQuery) IDs(ctx context.Context) (ids []uuid.UUID, er if apq.ctx.Unique == nil && apq.path != nil { apq.Unique(true) } - ctx = setContextOp(ctx, apq.ctx, "IDs") + ctx = setContextOp(ctx, apq.ctx, ent.OpQueryIDs) if err = apq.Select(attestationpolicy.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -227,7 +228,7 @@ func (apq *AttestationPolicyQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (apq *AttestationPolicyQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, apq.ctx, "Count") + ctx = setContextOp(ctx, apq.ctx, ent.OpQueryCount) if err := apq.prepareQuery(ctx); err != nil { return 0, err } @@ -245,7 +246,7 @@ func (apq *AttestationPolicyQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (apq *AttestationPolicyQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, apq.ctx, "Exist") + ctx = setContextOp(ctx, apq.ctx, ent.OpQueryExist) switch _, err := apq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -550,7 +551,7 @@ func (apgb *AttestationPolicyGroupBy) Aggregate(fns ...AggregateFunc) *Attestati // Scan applies the selector query and scans the result into the given value. func (apgb *AttestationPolicyGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, apgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, apgb.build.ctx, ent.OpQueryGroupBy) if err := apgb.build.prepareQuery(ctx); err != nil { return err } @@ -598,7 +599,7 @@ func (aps *AttestationPolicySelect) Aggregate(fns ...AggregateFunc) *Attestation // Scan applies the selector query and scans the result into the given value. func (aps *AttestationPolicySelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, aps.ctx, "Select") + ctx = setContextOp(ctx, aps.ctx, ent.OpQuerySelect) if err := aps.prepareQuery(ctx); err != nil { return err } diff --git a/ent/dsse_query.go b/ent/dsse_query.go index cc0fd93c..85d348df 100644 --- a/ent/dsse_query.go +++ b/ent/dsse_query.go @@ -8,6 +8,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -139,7 +140,7 @@ func (dq *DsseQuery) QueryPayloadDigests() *PayloadDigestQuery { // First returns the first Dsse entity from the query. // Returns a *NotFoundError when no Dsse was found. func (dq *DsseQuery) First(ctx context.Context) (*Dsse, error) { - nodes, err := dq.Limit(1).All(setContextOp(ctx, dq.ctx, "First")) + nodes, err := dq.Limit(1).All(setContextOp(ctx, dq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -162,7 +163,7 @@ func (dq *DsseQuery) FirstX(ctx context.Context) *Dsse { // Returns a *NotFoundError when no Dsse ID was found. func (dq *DsseQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = dq.Limit(1).IDs(setContextOp(ctx, dq.ctx, "FirstID")); err != nil { + if ids, err = dq.Limit(1).IDs(setContextOp(ctx, dq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -185,7 +186,7 @@ func (dq *DsseQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one Dsse entity is found. // Returns a *NotFoundError when no Dsse entities are found. func (dq *DsseQuery) Only(ctx context.Context) (*Dsse, error) { - nodes, err := dq.Limit(2).All(setContextOp(ctx, dq.ctx, "Only")) + nodes, err := dq.Limit(2).All(setContextOp(ctx, dq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -213,7 +214,7 @@ func (dq *DsseQuery) OnlyX(ctx context.Context) *Dsse { // Returns a *NotFoundError when no entities are found. func (dq *DsseQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = dq.Limit(2).IDs(setContextOp(ctx, dq.ctx, "OnlyID")); err != nil { + if ids, err = dq.Limit(2).IDs(setContextOp(ctx, dq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -238,7 +239,7 @@ func (dq *DsseQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of Dsses. func (dq *DsseQuery) All(ctx context.Context) ([]*Dsse, error) { - ctx = setContextOp(ctx, dq.ctx, "All") + ctx = setContextOp(ctx, dq.ctx, ent.OpQueryAll) if err := dq.prepareQuery(ctx); err != nil { return nil, err } @@ -260,7 +261,7 @@ func (dq *DsseQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if dq.ctx.Unique == nil && dq.path != nil { dq.Unique(true) } - ctx = setContextOp(ctx, dq.ctx, "IDs") + ctx = setContextOp(ctx, dq.ctx, ent.OpQueryIDs) if err = dq.Select(dsse.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -278,7 +279,7 @@ func (dq *DsseQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (dq *DsseQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, dq.ctx, "Count") + ctx = setContextOp(ctx, dq.ctx, ent.OpQueryCount) if err := dq.prepareQuery(ctx); err != nil { return 0, err } @@ -296,7 +297,7 @@ func (dq *DsseQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (dq *DsseQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, dq.ctx, "Exist") + ctx = setContextOp(ctx, dq.ctx, ent.OpQueryExist) switch _, err := dq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -745,7 +746,7 @@ func (dgb *DsseGroupBy) Aggregate(fns ...AggregateFunc) *DsseGroupBy { // Scan applies the selector query and scans the result into the given value. func (dgb *DsseGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, dgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, dgb.build.ctx, ent.OpQueryGroupBy) if err := dgb.build.prepareQuery(ctx); err != nil { return err } @@ -793,7 +794,7 @@ func (ds *DsseSelect) Aggregate(fns ...AggregateFunc) *DsseSelect { // Scan applies the selector query and scans the result into the given value. func (ds *DsseSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ds.ctx, "Select") + ctx = setContextOp(ctx, ds.ctx, ent.OpQuerySelect) if err := ds.prepareQuery(ctx); err != nil { return err } diff --git a/ent/ent.go b/ent/ent.go index a84a145b..693a81c1 100644 --- a/ent/ent.go +++ b/ent/ent.go @@ -78,7 +78,7 @@ var ( columnCheck sql.ColumnCheck ) -// columnChecker checks if the column exists in the given table. +// checkColumn checks if the column exists in the given table. func checkColumn(table, column string) error { initCheck.Do(func() { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ diff --git a/ent/payloaddigest_query.go b/ent/payloaddigest_query.go index ae831ef7..a0bf8ca8 100644 --- a/ent/payloaddigest_query.go +++ b/ent/payloaddigest_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -88,7 +89,7 @@ func (pdq *PayloadDigestQuery) QueryDsse() *DsseQuery { // First returns the first PayloadDigest entity from the query. // Returns a *NotFoundError when no PayloadDigest was found. func (pdq *PayloadDigestQuery) First(ctx context.Context) (*PayloadDigest, error) { - nodes, err := pdq.Limit(1).All(setContextOp(ctx, pdq.ctx, "First")) + nodes, err := pdq.Limit(1).All(setContextOp(ctx, pdq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -111,7 +112,7 @@ func (pdq *PayloadDigestQuery) FirstX(ctx context.Context) *PayloadDigest { // Returns a *NotFoundError when no PayloadDigest ID was found. func (pdq *PayloadDigestQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = pdq.Limit(1).IDs(setContextOp(ctx, pdq.ctx, "FirstID")); err != nil { + if ids, err = pdq.Limit(1).IDs(setContextOp(ctx, pdq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -134,7 +135,7 @@ func (pdq *PayloadDigestQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one PayloadDigest entity is found. // Returns a *NotFoundError when no PayloadDigest entities are found. func (pdq *PayloadDigestQuery) Only(ctx context.Context) (*PayloadDigest, error) { - nodes, err := pdq.Limit(2).All(setContextOp(ctx, pdq.ctx, "Only")) + nodes, err := pdq.Limit(2).All(setContextOp(ctx, pdq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -162,7 +163,7 @@ func (pdq *PayloadDigestQuery) OnlyX(ctx context.Context) *PayloadDigest { // Returns a *NotFoundError when no entities are found. func (pdq *PayloadDigestQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = pdq.Limit(2).IDs(setContextOp(ctx, pdq.ctx, "OnlyID")); err != nil { + if ids, err = pdq.Limit(2).IDs(setContextOp(ctx, pdq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -187,7 +188,7 @@ func (pdq *PayloadDigestQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of PayloadDigests. func (pdq *PayloadDigestQuery) All(ctx context.Context) ([]*PayloadDigest, error) { - ctx = setContextOp(ctx, pdq.ctx, "All") + ctx = setContextOp(ctx, pdq.ctx, ent.OpQueryAll) if err := pdq.prepareQuery(ctx); err != nil { return nil, err } @@ -209,7 +210,7 @@ func (pdq *PayloadDigestQuery) IDs(ctx context.Context) (ids []uuid.UUID, err er if pdq.ctx.Unique == nil && pdq.path != nil { pdq.Unique(true) } - ctx = setContextOp(ctx, pdq.ctx, "IDs") + ctx = setContextOp(ctx, pdq.ctx, ent.OpQueryIDs) if err = pdq.Select(payloaddigest.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -227,7 +228,7 @@ func (pdq *PayloadDigestQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (pdq *PayloadDigestQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, pdq.ctx, "Count") + ctx = setContextOp(ctx, pdq.ctx, ent.OpQueryCount) if err := pdq.prepareQuery(ctx); err != nil { return 0, err } @@ -245,7 +246,7 @@ func (pdq *PayloadDigestQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (pdq *PayloadDigestQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, pdq.ctx, "Exist") + ctx = setContextOp(ctx, pdq.ctx, ent.OpQueryExist) switch _, err := pdq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -550,7 +551,7 @@ func (pdgb *PayloadDigestGroupBy) Aggregate(fns ...AggregateFunc) *PayloadDigest // Scan applies the selector query and scans the result into the given value. func (pdgb *PayloadDigestGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, pdgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, pdgb.build.ctx, ent.OpQueryGroupBy) if err := pdgb.build.prepareQuery(ctx); err != nil { return err } @@ -598,7 +599,7 @@ func (pds *PayloadDigestSelect) Aggregate(fns ...AggregateFunc) *PayloadDigestSe // Scan applies the selector query and scans the result into the given value. func (pds *PayloadDigestSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, pds.ctx, "Select") + ctx = setContextOp(ctx, pds.ctx, ent.OpQuerySelect) if err := pds.prepareQuery(ctx); err != nil { return err } diff --git a/ent/runtime.go b/ent/runtime.go index b8a55dcd..638c2b1d 100644 --- a/ent/runtime.go +++ b/ent/runtime.go @@ -81,10 +81,6 @@ func init() { payloaddigest.DefaultID = payloaddigestDescID.Default.(func() uuid.UUID) signatureFields := schema.Signature{}.Fields() _ = signatureFields - // signatureDescKeyID is the schema descriptor for key_id field. - signatureDescKeyID := signatureFields[1].Descriptor() - // signature.KeyIDValidator is a validator for the "key_id" field. It is called by the builders before save. - signature.KeyIDValidator = signatureDescKeyID.Validators[0].(func(string) error) // signatureDescSignature is the schema descriptor for signature field. signatureDescSignature := signatureFields[2].Descriptor() // signature.SignatureValidator is a validator for the "signature" field. It is called by the builders before save. diff --git a/ent/runtime/runtime.go b/ent/runtime/runtime.go index e1ed00f3..1b363817 100644 --- a/ent/runtime/runtime.go +++ b/ent/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in github.com/in-toto/archivista/ent/runtime.go const ( - Version = "v0.13.1" // Version of ent codegen. - Sum = "h1:uD8QwN1h6SNphdCCzmkMN3feSUzNnVvV/WIkHKMbzOE=" // Sum of ent codegen. + Version = "v0.14.0" // Version of ent codegen. + Sum = "h1:EO3Z9aZ5bXJatJeGqu/EVdnNr6K4mRq3rWe5owt0MC4=" // Sum of ent codegen. ) diff --git a/ent/signature/signature.go b/ent/signature/signature.go index ef7e8ce5..de455ae4 100644 --- a/ent/signature/signature.go +++ b/ent/signature/signature.go @@ -68,8 +68,6 @@ func ValidColumn(column string) bool { } var ( - // KeyIDValidator is a validator for the "key_id" field. It is called by the builders before save. - KeyIDValidator func(string) error // SignatureValidator is a validator for the "signature" field. It is called by the builders before save. SignatureValidator func(string) error // DefaultID holds the default value on creation for the "id" field. diff --git a/ent/signature_create.go b/ent/signature_create.go index 141d3d24..cb35a1b0 100644 --- a/ent/signature_create.go +++ b/ent/signature_create.go @@ -128,11 +128,6 @@ func (sc *SignatureCreate) check() error { if _, ok := sc.mutation.KeyID(); !ok { return &ValidationError{Name: "key_id", err: errors.New(`ent: missing required field "Signature.key_id"`)} } - if v, ok := sc.mutation.KeyID(); ok { - if err := signature.KeyIDValidator(v); err != nil { - return &ValidationError{Name: "key_id", err: fmt.Errorf(`ent: validator failed for field "Signature.key_id": %w`, err)} - } - } if _, ok := sc.mutation.Signature(); !ok { return &ValidationError{Name: "signature", err: errors.New(`ent: missing required field "Signature.signature"`)} } diff --git a/ent/signature_query.go b/ent/signature_query.go index 8ece2a0c..631dee5c 100644 --- a/ent/signature_query.go +++ b/ent/signature_query.go @@ -8,6 +8,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -114,7 +115,7 @@ func (sq *SignatureQuery) QueryTimestamps() *TimestampQuery { // First returns the first Signature entity from the query. // Returns a *NotFoundError when no Signature was found. func (sq *SignatureQuery) First(ctx context.Context) (*Signature, error) { - nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First")) + nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -137,7 +138,7 @@ func (sq *SignatureQuery) FirstX(ctx context.Context) *Signature { // Returns a *NotFoundError when no Signature ID was found. func (sq *SignatureQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, "FirstID")); err != nil { + if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -160,7 +161,7 @@ func (sq *SignatureQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one Signature entity is found. // Returns a *NotFoundError when no Signature entities are found. func (sq *SignatureQuery) Only(ctx context.Context) (*Signature, error) { - nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, "Only")) + nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -188,7 +189,7 @@ func (sq *SignatureQuery) OnlyX(ctx context.Context) *Signature { // Returns a *NotFoundError when no entities are found. func (sq *SignatureQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, "OnlyID")); err != nil { + if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -213,7 +214,7 @@ func (sq *SignatureQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of Signatures. func (sq *SignatureQuery) All(ctx context.Context) ([]*Signature, error) { - ctx = setContextOp(ctx, sq.ctx, "All") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryAll) if err := sq.prepareQuery(ctx); err != nil { return nil, err } @@ -235,7 +236,7 @@ func (sq *SignatureQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) if sq.ctx.Unique == nil && sq.path != nil { sq.Unique(true) } - ctx = setContextOp(ctx, sq.ctx, "IDs") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryIDs) if err = sq.Select(signature.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -253,7 +254,7 @@ func (sq *SignatureQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (sq *SignatureQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, sq.ctx, "Count") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryCount) if err := sq.prepareQuery(ctx); err != nil { return 0, err } @@ -271,7 +272,7 @@ func (sq *SignatureQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (sq *SignatureQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, sq.ctx, "Exist") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryExist) switch _, err := sq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -648,7 +649,7 @@ func (sgb *SignatureGroupBy) Aggregate(fns ...AggregateFunc) *SignatureGroupBy { // Scan applies the selector query and scans the result into the given value. func (sgb *SignatureGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, sgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, sgb.build.ctx, ent.OpQueryGroupBy) if err := sgb.build.prepareQuery(ctx); err != nil { return err } @@ -696,7 +697,7 @@ func (ss *SignatureSelect) Aggregate(fns ...AggregateFunc) *SignatureSelect { // Scan applies the selector query and scans the result into the given value. func (ss *SignatureSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ss.ctx, "Select") + ctx = setContextOp(ctx, ss.ctx, ent.OpQuerySelect) if err := ss.prepareQuery(ctx); err != nil { return err } diff --git a/ent/signature_update.go b/ent/signature_update.go index 9f75f137..d2c53581 100644 --- a/ent/signature_update.go +++ b/ent/signature_update.go @@ -153,11 +153,6 @@ func (su *SignatureUpdate) ExecX(ctx context.Context) { // check runs all checks and user-defined validators on the builder. func (su *SignatureUpdate) check() error { - if v, ok := su.mutation.KeyID(); ok { - if err := signature.KeyIDValidator(v); err != nil { - return &ValidationError{Name: "key_id", err: fmt.Errorf(`ent: validator failed for field "Signature.key_id": %w`, err)} - } - } if v, ok := su.mutation.Signature(); ok { if err := signature.SignatureValidator(v); err != nil { return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "Signature.signature": %w`, err)} @@ -414,11 +409,6 @@ func (suo *SignatureUpdateOne) ExecX(ctx context.Context) { // check runs all checks and user-defined validators on the builder. func (suo *SignatureUpdateOne) check() error { - if v, ok := suo.mutation.KeyID(); ok { - if err := signature.KeyIDValidator(v); err != nil { - return &ValidationError{Name: "key_id", err: fmt.Errorf(`ent: validator failed for field "Signature.key_id": %w`, err)} - } - } if v, ok := suo.mutation.Signature(); ok { if err := signature.SignatureValidator(v); err != nil { return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "Signature.signature": %w`, err)} diff --git a/ent/statement_query.go b/ent/statement_query.go index 520e2928..e1c52f79 100644 --- a/ent/statement_query.go +++ b/ent/statement_query.go @@ -8,6 +8,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -162,7 +163,7 @@ func (sq *StatementQuery) QueryDsse() *DsseQuery { // First returns the first Statement entity from the query. // Returns a *NotFoundError when no Statement was found. func (sq *StatementQuery) First(ctx context.Context) (*Statement, error) { - nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First")) + nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -185,7 +186,7 @@ func (sq *StatementQuery) FirstX(ctx context.Context) *Statement { // Returns a *NotFoundError when no Statement ID was found. func (sq *StatementQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, "FirstID")); err != nil { + if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -208,7 +209,7 @@ func (sq *StatementQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one Statement entity is found. // Returns a *NotFoundError when no Statement entities are found. func (sq *StatementQuery) Only(ctx context.Context) (*Statement, error) { - nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, "Only")) + nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -236,7 +237,7 @@ func (sq *StatementQuery) OnlyX(ctx context.Context) *Statement { // Returns a *NotFoundError when no entities are found. func (sq *StatementQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, "OnlyID")); err != nil { + if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -261,7 +262,7 @@ func (sq *StatementQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of Statements. func (sq *StatementQuery) All(ctx context.Context) ([]*Statement, error) { - ctx = setContextOp(ctx, sq.ctx, "All") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryAll) if err := sq.prepareQuery(ctx); err != nil { return nil, err } @@ -283,7 +284,7 @@ func (sq *StatementQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) if sq.ctx.Unique == nil && sq.path != nil { sq.Unique(true) } - ctx = setContextOp(ctx, sq.ctx, "IDs") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryIDs) if err = sq.Select(statement.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -301,7 +302,7 @@ func (sq *StatementQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (sq *StatementQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, sq.ctx, "Count") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryCount) if err := sq.prepareQuery(ctx); err != nil { return 0, err } @@ -319,7 +320,7 @@ func (sq *StatementQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (sq *StatementQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, sq.ctx, "Exist") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryExist) switch _, err := sq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -804,7 +805,7 @@ func (sgb *StatementGroupBy) Aggregate(fns ...AggregateFunc) *StatementGroupBy { // Scan applies the selector query and scans the result into the given value. func (sgb *StatementGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, sgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, sgb.build.ctx, ent.OpQueryGroupBy) if err := sgb.build.prepareQuery(ctx); err != nil { return err } @@ -852,7 +853,7 @@ func (ss *StatementSelect) Aggregate(fns ...AggregateFunc) *StatementSelect { // Scan applies the selector query and scans the result into the given value. func (ss *StatementSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ss.ctx, "Select") + ctx = setContextOp(ctx, ss.ctx, ent.OpQuerySelect) if err := ss.prepareQuery(ctx); err != nil { return err } diff --git a/ent/subject_query.go b/ent/subject_query.go index 3d180109..f661485c 100644 --- a/ent/subject_query.go +++ b/ent/subject_query.go @@ -8,6 +8,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -114,7 +115,7 @@ func (sq *SubjectQuery) QueryStatement() *StatementQuery { // First returns the first Subject entity from the query. // Returns a *NotFoundError when no Subject was found. func (sq *SubjectQuery) First(ctx context.Context) (*Subject, error) { - nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First")) + nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -137,7 +138,7 @@ func (sq *SubjectQuery) FirstX(ctx context.Context) *Subject { // Returns a *NotFoundError when no Subject ID was found. func (sq *SubjectQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, "FirstID")); err != nil { + if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -160,7 +161,7 @@ func (sq *SubjectQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one Subject entity is found. // Returns a *NotFoundError when no Subject entities are found. func (sq *SubjectQuery) Only(ctx context.Context) (*Subject, error) { - nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, "Only")) + nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -188,7 +189,7 @@ func (sq *SubjectQuery) OnlyX(ctx context.Context) *Subject { // Returns a *NotFoundError when no entities are found. func (sq *SubjectQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, "OnlyID")); err != nil { + if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -213,7 +214,7 @@ func (sq *SubjectQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of Subjects. func (sq *SubjectQuery) All(ctx context.Context) ([]*Subject, error) { - ctx = setContextOp(ctx, sq.ctx, "All") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryAll) if err := sq.prepareQuery(ctx); err != nil { return nil, err } @@ -235,7 +236,7 @@ func (sq *SubjectQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if sq.ctx.Unique == nil && sq.path != nil { sq.Unique(true) } - ctx = setContextOp(ctx, sq.ctx, "IDs") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryIDs) if err = sq.Select(subject.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -253,7 +254,7 @@ func (sq *SubjectQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (sq *SubjectQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, sq.ctx, "Count") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryCount) if err := sq.prepareQuery(ctx); err != nil { return 0, err } @@ -271,7 +272,7 @@ func (sq *SubjectQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (sq *SubjectQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, sq.ctx, "Exist") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryExist) switch _, err := sq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -648,7 +649,7 @@ func (sgb *SubjectGroupBy) Aggregate(fns ...AggregateFunc) *SubjectGroupBy { // Scan applies the selector query and scans the result into the given value. func (sgb *SubjectGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, sgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, sgb.build.ctx, ent.OpQueryGroupBy) if err := sgb.build.prepareQuery(ctx); err != nil { return err } @@ -696,7 +697,7 @@ func (ss *SubjectSelect) Aggregate(fns ...AggregateFunc) *SubjectSelect { // Scan applies the selector query and scans the result into the given value. func (ss *SubjectSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ss.ctx, "Select") + ctx = setContextOp(ctx, ss.ctx, ent.OpQuerySelect) if err := ss.prepareQuery(ctx); err != nil { return err } diff --git a/ent/subjectdigest_query.go b/ent/subjectdigest_query.go index 6f049fd8..bbe44bb6 100644 --- a/ent/subjectdigest_query.go +++ b/ent/subjectdigest_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -88,7 +89,7 @@ func (sdq *SubjectDigestQuery) QuerySubject() *SubjectQuery { // First returns the first SubjectDigest entity from the query. // Returns a *NotFoundError when no SubjectDigest was found. func (sdq *SubjectDigestQuery) First(ctx context.Context) (*SubjectDigest, error) { - nodes, err := sdq.Limit(1).All(setContextOp(ctx, sdq.ctx, "First")) + nodes, err := sdq.Limit(1).All(setContextOp(ctx, sdq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -111,7 +112,7 @@ func (sdq *SubjectDigestQuery) FirstX(ctx context.Context) *SubjectDigest { // Returns a *NotFoundError when no SubjectDigest ID was found. func (sdq *SubjectDigestQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = sdq.Limit(1).IDs(setContextOp(ctx, sdq.ctx, "FirstID")); err != nil { + if ids, err = sdq.Limit(1).IDs(setContextOp(ctx, sdq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -134,7 +135,7 @@ func (sdq *SubjectDigestQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one SubjectDigest entity is found. // Returns a *NotFoundError when no SubjectDigest entities are found. func (sdq *SubjectDigestQuery) Only(ctx context.Context) (*SubjectDigest, error) { - nodes, err := sdq.Limit(2).All(setContextOp(ctx, sdq.ctx, "Only")) + nodes, err := sdq.Limit(2).All(setContextOp(ctx, sdq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -162,7 +163,7 @@ func (sdq *SubjectDigestQuery) OnlyX(ctx context.Context) *SubjectDigest { // Returns a *NotFoundError when no entities are found. func (sdq *SubjectDigestQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = sdq.Limit(2).IDs(setContextOp(ctx, sdq.ctx, "OnlyID")); err != nil { + if ids, err = sdq.Limit(2).IDs(setContextOp(ctx, sdq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -187,7 +188,7 @@ func (sdq *SubjectDigestQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of SubjectDigests. func (sdq *SubjectDigestQuery) All(ctx context.Context) ([]*SubjectDigest, error) { - ctx = setContextOp(ctx, sdq.ctx, "All") + ctx = setContextOp(ctx, sdq.ctx, ent.OpQueryAll) if err := sdq.prepareQuery(ctx); err != nil { return nil, err } @@ -209,7 +210,7 @@ func (sdq *SubjectDigestQuery) IDs(ctx context.Context) (ids []uuid.UUID, err er if sdq.ctx.Unique == nil && sdq.path != nil { sdq.Unique(true) } - ctx = setContextOp(ctx, sdq.ctx, "IDs") + ctx = setContextOp(ctx, sdq.ctx, ent.OpQueryIDs) if err = sdq.Select(subjectdigest.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -227,7 +228,7 @@ func (sdq *SubjectDigestQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (sdq *SubjectDigestQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, sdq.ctx, "Count") + ctx = setContextOp(ctx, sdq.ctx, ent.OpQueryCount) if err := sdq.prepareQuery(ctx); err != nil { return 0, err } @@ -245,7 +246,7 @@ func (sdq *SubjectDigestQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (sdq *SubjectDigestQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, sdq.ctx, "Exist") + ctx = setContextOp(ctx, sdq.ctx, ent.OpQueryExist) switch _, err := sdq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -550,7 +551,7 @@ func (sdgb *SubjectDigestGroupBy) Aggregate(fns ...AggregateFunc) *SubjectDigest // Scan applies the selector query and scans the result into the given value. func (sdgb *SubjectDigestGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, sdgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, sdgb.build.ctx, ent.OpQueryGroupBy) if err := sdgb.build.prepareQuery(ctx); err != nil { return err } @@ -598,7 +599,7 @@ func (sds *SubjectDigestSelect) Aggregate(fns ...AggregateFunc) *SubjectDigestSe // Scan applies the selector query and scans the result into the given value. func (sds *SubjectDigestSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, sds.ctx, "Select") + ctx = setContextOp(ctx, sds.ctx, ent.OpQuerySelect) if err := sds.prepareQuery(ctx); err != nil { return err } diff --git a/ent/timestamp_query.go b/ent/timestamp_query.go index 809250ff..f6cd5da3 100644 --- a/ent/timestamp_query.go +++ b/ent/timestamp_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -88,7 +89,7 @@ func (tq *TimestampQuery) QuerySignature() *SignatureQuery { // First returns the first Timestamp entity from the query. // Returns a *NotFoundError when no Timestamp was found. func (tq *TimestampQuery) First(ctx context.Context) (*Timestamp, error) { - nodes, err := tq.Limit(1).All(setContextOp(ctx, tq.ctx, "First")) + nodes, err := tq.Limit(1).All(setContextOp(ctx, tq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -111,7 +112,7 @@ func (tq *TimestampQuery) FirstX(ctx context.Context) *Timestamp { // Returns a *NotFoundError when no Timestamp ID was found. func (tq *TimestampQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = tq.Limit(1).IDs(setContextOp(ctx, tq.ctx, "FirstID")); err != nil { + if ids, err = tq.Limit(1).IDs(setContextOp(ctx, tq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -134,7 +135,7 @@ func (tq *TimestampQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one Timestamp entity is found. // Returns a *NotFoundError when no Timestamp entities are found. func (tq *TimestampQuery) Only(ctx context.Context) (*Timestamp, error) { - nodes, err := tq.Limit(2).All(setContextOp(ctx, tq.ctx, "Only")) + nodes, err := tq.Limit(2).All(setContextOp(ctx, tq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -162,7 +163,7 @@ func (tq *TimestampQuery) OnlyX(ctx context.Context) *Timestamp { // Returns a *NotFoundError when no entities are found. func (tq *TimestampQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = tq.Limit(2).IDs(setContextOp(ctx, tq.ctx, "OnlyID")); err != nil { + if ids, err = tq.Limit(2).IDs(setContextOp(ctx, tq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -187,7 +188,7 @@ func (tq *TimestampQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of Timestamps. func (tq *TimestampQuery) All(ctx context.Context) ([]*Timestamp, error) { - ctx = setContextOp(ctx, tq.ctx, "All") + ctx = setContextOp(ctx, tq.ctx, ent.OpQueryAll) if err := tq.prepareQuery(ctx); err != nil { return nil, err } @@ -209,7 +210,7 @@ func (tq *TimestampQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) if tq.ctx.Unique == nil && tq.path != nil { tq.Unique(true) } - ctx = setContextOp(ctx, tq.ctx, "IDs") + ctx = setContextOp(ctx, tq.ctx, ent.OpQueryIDs) if err = tq.Select(timestamp.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -227,7 +228,7 @@ func (tq *TimestampQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (tq *TimestampQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, tq.ctx, "Count") + ctx = setContextOp(ctx, tq.ctx, ent.OpQueryCount) if err := tq.prepareQuery(ctx); err != nil { return 0, err } @@ -245,7 +246,7 @@ func (tq *TimestampQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (tq *TimestampQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, tq.ctx, "Exist") + ctx = setContextOp(ctx, tq.ctx, ent.OpQueryExist) switch _, err := tq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -550,7 +551,7 @@ func (tgb *TimestampGroupBy) Aggregate(fns ...AggregateFunc) *TimestampGroupBy { // Scan applies the selector query and scans the result into the given value. func (tgb *TimestampGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, tgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, tgb.build.ctx, ent.OpQueryGroupBy) if err := tgb.build.prepareQuery(ctx); err != nil { return err } @@ -598,7 +599,7 @@ func (ts *TimestampSelect) Aggregate(fns ...AggregateFunc) *TimestampSelect { // Scan applies the selector query and scans the result into the given value. func (ts *TimestampSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ts.ctx, "Select") + ctx = setContextOp(ctx, ts.ctx, ent.OpQuerySelect) if err := ts.prepareQuery(ctx); err != nil { return err }