From 295da10597e4d7179146bf748d6891775d3006a2 Mon Sep 17 00:00:00 2001 From: Kairo Araujo Date: Fri, 24 May 2024 11:40:38 +0200 Subject: [PATCH 1/4] chore: migrate id from bigint to uuid Signed-off-by: Kairo Araujo --- ent/schema/attestation.go | 2 ++ ent/schema/attestationcollection.go | 2 ++ ent/schema/attestationpolicy.go | 2 ++ ent/schema/dsse.go | 2 ++ ent/schema/payloaddigest.go | 2 ++ ent/schema/signature.go | 2 ++ ent/schema/statement.go | 2 ++ ent/schema/subject.go | 2 ++ ent/schema/subjectdigest.go | 2 ++ ent/schema/timestamp.go | 2 ++ ent/schema/uuidgql/uuidgql.go | 38 +++++++++++++++++++++++++++++ go.mod | 2 +- gqlgen.yml | 5 +++- 13 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 ent/schema/uuidgql/uuidgql.go diff --git a/ent/schema/attestation.go b/ent/schema/attestation.go index e9f864b8..285c9896 100644 --- a/ent/schema/attestation.go +++ b/ent/schema/attestation.go @@ -19,6 +19,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + "github.com/google/uuid" ) // Attestation represents an attestation from a witness attestation collection @@ -28,6 +29,7 @@ type Attestation struct { func (Attestation) Fields() []ent.Field { return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New).Immutable().Unique(), field.String("type").NotEmpty(), } } diff --git a/ent/schema/attestationcollection.go b/ent/schema/attestationcollection.go index efd2a60f..2df302e9 100644 --- a/ent/schema/attestationcollection.go +++ b/ent/schema/attestationcollection.go @@ -19,6 +19,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + "github.com/google/uuid" ) // AttestationCollection represents a witness attestation collection @@ -28,6 +29,7 @@ type AttestationCollection struct { func (AttestationCollection) Fields() []ent.Field { return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New).Immutable().Unique(), field.String("name").NotEmpty(), } } diff --git a/ent/schema/attestationpolicy.go b/ent/schema/attestationpolicy.go index ba0eaa02..93bfd515 100644 --- a/ent/schema/attestationpolicy.go +++ b/ent/schema/attestationpolicy.go @@ -21,6 +21,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + "github.com/google/uuid" ) // Attestation represents an attestation from a witness attestation collection @@ -30,6 +31,7 @@ type AttestationPolicy struct { func (AttestationPolicy) Fields() []ent.Field { return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New).Immutable().Unique(), field.String("name").NotEmpty(), } } diff --git a/ent/schema/dsse.go b/ent/schema/dsse.go index 71ed038a..1719d248 100644 --- a/ent/schema/dsse.go +++ b/ent/schema/dsse.go @@ -20,6 +20,7 @@ import ( "entgo.io/ent/schema" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" + "github.com/google/uuid" ) // Dsse represents some metadata about an archived DSSE envelope @@ -30,6 +31,7 @@ type Dsse struct { // Fields of the Statement. func (Dsse) Fields() []ent.Field { return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New).Immutable().Unique(), field.String("gitoid_sha256").NotEmpty().Unique(), field.String("payload_type").NotEmpty(), } diff --git a/ent/schema/payloaddigest.go b/ent/schema/payloaddigest.go index e51bd0c0..d52c7180 100644 --- a/ent/schema/payloaddigest.go +++ b/ent/schema/payloaddigest.go @@ -19,6 +19,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + "github.com/google/uuid" ) // PayloadDigest represents the digest of the payload of a DSSE envelope @@ -29,6 +30,7 @@ type PayloadDigest struct { // Fields of the Digest. func (PayloadDigest) Fields() []ent.Field { return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New).Immutable().Unique(), field.String("algorithm").NotEmpty(), field.String("value").NotEmpty(), } diff --git a/ent/schema/signature.go b/ent/schema/signature.go index 0f246563..79565c5a 100644 --- a/ent/schema/signature.go +++ b/ent/schema/signature.go @@ -20,6 +20,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + "github.com/google/uuid" ) // Signature represents signatures on a DSSE envelope @@ -30,6 +31,7 @@ type Signature struct { // Fields of the Signature. func (Signature) Fields() []ent.Field { return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New).Immutable().Unique(), field.String("key_id").NotEmpty(), field.String("signature").NotEmpty().SchemaType(map[string]string{dialect.MySQL: "text"}), } diff --git a/ent/schema/statement.go b/ent/schema/statement.go index 47cea537..be3f3345 100644 --- a/ent/schema/statement.go +++ b/ent/schema/statement.go @@ -20,6 +20,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + "github.com/google/uuid" ) // Statement represents an in-toto statement from an archived dsse envelope @@ -30,6 +31,7 @@ type Statement struct { // Fields of the Statement. func (Statement) Fields() []ent.Field { return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New).Immutable().Unique(), field.String("predicate").NotEmpty(), } } diff --git a/ent/schema/subject.go b/ent/schema/subject.go index c1ed48ff..72db90c4 100644 --- a/ent/schema/subject.go +++ b/ent/schema/subject.go @@ -21,6 +21,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + "github.com/google/uuid" ) // Subject represents subjects from an in-toto statement. @@ -31,6 +32,7 @@ type Subject struct { // Fields of the Subject. func (Subject) Fields() []ent.Field { return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New).Immutable().Unique(), field.String("name").NotEmpty(), } } diff --git a/ent/schema/subjectdigest.go b/ent/schema/subjectdigest.go index aa0df27f..e1deb03a 100644 --- a/ent/schema/subjectdigest.go +++ b/ent/schema/subjectdigest.go @@ -19,6 +19,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + "github.com/google/uuid" ) // SubjectDigest represents the digests of a subject from an in-toto statement @@ -29,6 +30,7 @@ type SubjectDigest struct { // Fields of the Digest. func (SubjectDigest) Fields() []ent.Field { return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New).Immutable().Unique(), field.String("algorithm").NotEmpty(), field.String("value").NotEmpty(), } diff --git a/ent/schema/timestamp.go b/ent/schema/timestamp.go index 1ac86a9e..7ce2811f 100644 --- a/ent/schema/timestamp.go +++ b/ent/schema/timestamp.go @@ -18,6 +18,7 @@ import ( "entgo.io/ent" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" + "github.com/google/uuid" ) type Timestamp struct { @@ -26,6 +27,7 @@ type Timestamp struct { func (Timestamp) Fields() []ent.Field { return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New).Immutable().Unique(), field.String("type"), field.Time("timestamp"), } diff --git a/ent/schema/uuidgql/uuidgql.go b/ent/schema/uuidgql/uuidgql.go new file mode 100644 index 00000000..2c767f50 --- /dev/null +++ b/ent/schema/uuidgql/uuidgql.go @@ -0,0 +1,38 @@ +// Copyright 2019-present Facebook +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package uuidgql + +import ( + "fmt" + "io" + "strconv" + + "github.com/99designs/gqlgen/graphql" + "github.com/google/uuid" +) + +func MarshalUUID(u uuid.UUID) graphql.Marshaler { + return graphql.WriterFunc(func(w io.Writer) { + _, _ = io.WriteString(w, strconv.Quote(u.String())) + }) +} + +func UnmarshalUUID(v interface{}) (u uuid.UUID, err error) { + s, ok := v.(string) + if !ok { + return u, fmt.Errorf("invalid type %T, expect string", v) + } + return uuid.Parse(s) +} diff --git a/go.mod b/go.mod index d34b7317..fbe6902e 100644 --- a/go.mod +++ b/go.mod @@ -13,6 +13,7 @@ require ( github.com/digitorus/timestamp v0.0.0-20231217203849-220c5c2851b7 github.com/edwarnicke/gitoid v0.0.0-20220710194850-1be5bfda1f9d github.com/go-sql-driver/mysql v1.8.1 + github.com/google/uuid v1.6.0 github.com/gorilla/handlers v1.5.2 github.com/gorilla/mux v1.8.1 github.com/hashicorp/go-multierror v1.1.1 @@ -61,7 +62,6 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/uuid v1.6.0 // indirect github.com/gorilla/websocket v1.5.1 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect diff --git a/gqlgen.yml b/gqlgen.yml index f28a3c1c..c8bc5255 100644 --- a/gqlgen.yml +++ b/gqlgen.yml @@ -29,10 +29,13 @@ autobind: models: ID: model: - - github.com/99designs/gqlgen/graphql.IntID + - github.com/in-toto/archivista/ent/schema/uuidgql.UUID Uint64: model: - github.com/99designs/gqlgen/graphql.Uint64 + UUID: + model: + - github.com/in-toto/archivista/ent/schema/uuidgql.UUID # Node: # model: # # ent.Noder is the new interface generated by the Node template. From 54dabf6b11025a24a1c35853efe257c666a9f542 Mon Sep 17 00:00:00 2001 From: Kairo Araujo Date: Fri, 24 May 2024 13:15:38 +0200 Subject: [PATCH 2/4] chore: update persers to use uuid type Signed-off-by: Kairo Araujo --- internal/metadatastorage/attestationcollection/parserstorer.go | 3 ++- internal/metadatastorage/parser.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/metadatastorage/attestationcollection/parserstorer.go b/internal/metadatastorage/attestationcollection/parserstorer.go index eaab6f5c..3c03b41d 100644 --- a/internal/metadatastorage/attestationcollection/parserstorer.go +++ b/internal/metadatastorage/attestationcollection/parserstorer.go @@ -18,6 +18,7 @@ import ( "context" "encoding/json" + "github.com/google/uuid" "github.com/in-toto/archivista/ent" "github.com/in-toto/archivista/internal/metadatastorage" "github.com/in-toto/go-witness/attestation" @@ -47,7 +48,7 @@ func Parse(data []byte) (metadatastorage.Storer, error) { return parsedCollection, nil } -func (parsedCollection ParsedCollection) Store(ctx context.Context, tx *ent.Tx, stmtID int) error { +func (parsedCollection ParsedCollection) Store(ctx context.Context, tx *ent.Tx, stmtID uuid.UUID) error { collection, err := tx.AttestationCollection.Create(). SetStatementID(stmtID). SetName(parsedCollection.Name). diff --git a/internal/metadatastorage/parser.go b/internal/metadatastorage/parser.go index b8797c95..75d2ceec 100644 --- a/internal/metadatastorage/parser.go +++ b/internal/metadatastorage/parser.go @@ -17,11 +17,12 @@ package metadatastorage import ( "context" + "github.com/google/uuid" "github.com/in-toto/archivista/ent" ) type ParserFunc func([]byte) (Storer, error) type Storer interface { - Store(ctx context.Context, tx *ent.Tx, stmtID int) error + Store(ctx context.Context, tx *ent.Tx, stmtID uuid.UUID) error } From f9c2ee8f81b33974072acc41c35b8a8583676721 Mon Sep 17 00:00:00 2001 From: Kairo Araujo Date: Fri, 24 May 2024 13:25:31 +0200 Subject: [PATCH 3/4] build: ignore auto generated files license check Auto generated by migrations - `./generated.go` - `./ent.resolvers.go` Signed-off-by: Kairo Araujo --- .github/workflows/verify-licence.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify-licence.yml b/.github/workflows/verify-licence.yml index 239db787..721dc737 100644 --- a/.github/workflows/verify-licence.yml +++ b/.github/workflows/verify-licence.yml @@ -40,4 +40,4 @@ jobs: - name: Check license headers run: | set -e - addlicense --check -l apache -c 'The Archivista Contributors' --ignore "ent/migrate/migrations/**" --ignore "docs/**" --ignore "chart/**/*.yaml" -v ./ + addlicense --check -l apache -c 'The Archivista Contributors' --ignore "generated.go" --ignore "ent.resolvers.go" --ignore "ent/migrate/migrations/**" --ignore "docs/**" --ignore "chart/**/*.yaml" -v ./ From 040dd65d7e3a94121d3a0d7a76f3cb154673d062 Mon Sep 17 00:00:00 2001 From: Kairo Araujo Date: Fri, 24 May 2024 13:26:36 +0200 Subject: [PATCH 4/4] BREAKING CHANGE: db-migrations reseted Signed-off-by: Kairo Araujo --- ent.graphql | 4 +- ent.resolvers.go | 27 +- ent/attestation.go | 27 +- ent/attestation/attestation.go | 3 + ent/attestation/where.go | 19 +- ent/attestation_create.go | 48 +- ent/attestation_delete.go | 2 +- ent/attestation_query.go | 23 +- ent/attestation_update.go | 17 +- ent/attestationcollection.go | 27 +- .../attestationcollection.go | 3 + ent/attestationcollection/where.go | 19 +- ent/attestationcollection_create.go | 54 +- ent/attestationcollection_delete.go | 2 +- ent/attestationcollection_query.go | 25 +- ent/attestationcollection_update.go | 45 +- ent/attestationpolicy.go | 27 +- ent/attestationpolicy/attestationpolicy.go | 3 + ent/attestationpolicy/where.go | 19 +- ent/attestationpolicy_create.go | 50 +- ent/attestationpolicy_delete.go | 2 +- ent/attestationpolicy_query.go | 23 +- ent/attestationpolicy_update.go | 21 +- ent/client.go | 83 ++- ent/dsse.go | 27 +- ent/dsse/dsse.go | 3 + ent/dsse/where.go | 19 +- ent/dsse_create.go | 62 +- ent/dsse_delete.go | 2 +- ent/dsse_query.go | 27 +- ent/dsse_update.go | 77 +-- ent/gql_collection.go | 152 ++--- ent/gql_node.go | 273 ++++----- ent/gql_pagination.go | 95 ++- ent/gql_where_input.go | 161 ++--- .../migrations/mysql/20231214165639_mysql.sql | 18 - .../migrations/mysql/20240412085222_mysql.sql | 2 - .../migrations/mysql/20240524112613_mysql.sql | 20 + ent/migrate/migrations/mysql/atlas.sum | 5 +- .../migrations/pgsql/20231214165922_pgsql.sql | 36 -- .../migrations/pgsql/20240412085224_pgsql.sql | 6 - .../migrations/pgsql/20240524112615_pgsql.sql | 42 ++ ent/migrate/migrations/pgsql/atlas.sum | 5 +- ent/migrate/schema.go | 38 +- ent/mutation.go | 361 ++++++----- ent/payloaddigest.go | 27 +- ent/payloaddigest/payloaddigest.go | 3 + ent/payloaddigest/where.go | 19 +- ent/payloaddigest_create.go | 50 +- ent/payloaddigest_delete.go | 2 +- ent/payloaddigest_query.go | 23 +- ent/payloaddigest_update.go | 21 +- ent/runtime.go | 70 ++- ent/signature.go | 27 +- ent/signature/signature.go | 3 + ent/signature/where.go | 19 +- ent/signature_create.go | 56 +- ent/signature_delete.go | 2 +- ent/signature_query.go | 25 +- ent/signature_update.go | 49 +- ent/statement.go | 15 +- ent/statement/statement.go | 3 + ent/statement/where.go | 19 +- ent/statement_create.go | 68 ++- ent/statement_delete.go | 2 +- ent/statement_query.go | 27 +- ent/statement_update.go | 93 +-- ent/subject.go | 27 +- ent/subject/subject.go | 3 + ent/subject/where.go | 19 +- ent/subject_create.go | 56 +- ent/subject_delete.go | 2 +- ent/subject_query.go | 25 +- ent/subject_update.go | 49 +- ent/subjectdigest.go | 27 +- ent/subjectdigest/subjectdigest.go | 3 + ent/subjectdigest/where.go | 19 +- ent/subjectdigest_create.go | 50 +- ent/subjectdigest_delete.go | 2 +- ent/subjectdigest_query.go | 23 +- ent/subjectdigest_update.go | 21 +- ent/timestamp.go | 27 +- ent/timestamp/timestamp.go | 6 + ent/timestamp/where.go | 19 +- ent/timestamp_create.go | 50 +- ent/timestamp_delete.go | 2 +- ent/timestamp_query.go | 23 +- ent/timestamp_update.go | 21 +- generated.go | 570 +++++++++--------- go.mod | 2 +- 90 files changed, 2052 insertions(+), 1621 deletions(-) delete mode 100644 ent/migrate/migrations/mysql/20231214165639_mysql.sql delete mode 100644 ent/migrate/migrations/mysql/20240412085222_mysql.sql create mode 100644 ent/migrate/migrations/mysql/20240524112613_mysql.sql delete mode 100644 ent/migrate/migrations/pgsql/20231214165922_pgsql.sql delete mode 100644 ent/migrate/migrations/pgsql/20240412085224_pgsql.sql create mode 100644 ent/migrate/migrations/pgsql/20240524112615_pgsql.sql diff --git a/ent.graphql b/ent.graphql index bc06dfc8..3c8ffa72 100644 --- a/ent.graphql +++ b/ent.graphql @@ -1,5 +1,5 @@ -directive @goField(forceResolver: Boolean, name: String) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION -directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION +directive @goField(forceResolver: Boolean, name: String, omittable: Boolean) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION +directive @goModel(model: String, models: [String!], forceGenerate: Boolean) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION type Attestation implements Node { id: ID! type: String! diff --git a/ent.resolvers.go b/ent.resolvers.go index 033399fa..df8beee0 100644 --- a/ent.resolvers.go +++ b/ent.resolvers.go @@ -1,53 +1,40 @@ -// Copyright 2024 The Archivista Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - 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.45 +// Code generated by github.com/99designs/gqlgen version v0.17.47 import ( "context" "fmt" "entgo.io/contrib/entgql" + "github.com/google/uuid" "github.com/in-toto/archivista/ent" ) // Node is the resolver for the node field. -func (r *queryResolver) Node(ctx context.Context, id int) (ent.Noder, error) { +func (r *queryResolver) Node(ctx context.Context, id uuid.UUID) (ent.Noder, error) { return r.client.Noder(ctx, id) } // Nodes is the resolver for the nodes field. -func (r *queryResolver) Nodes(ctx context.Context, ids []int) ([]ent.Noder, error) { +func (r *queryResolver) Nodes(ctx context.Context, ids []uuid.UUID) ([]ent.Noder, error) { return r.client.Noders(ctx, ids) } // AttestationPolicies is the resolver for the attestationPolicies field. -func (r *queryResolver) AttestationPolicies(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, where *ent.AttestationPolicyWhereInput) (*ent.AttestationPolicyConnection, error) { +func (r *queryResolver) AttestationPolicies(ctx context.Context, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, where *ent.AttestationPolicyWhereInput) (*ent.AttestationPolicyConnection, error) { panic(fmt.Errorf("not implemented: AttestationPolicies - attestationPolicies")) } // Dsses is the resolver for the dsses field. -func (r *queryResolver) Dsses(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, where *ent.DsseWhereInput) (*ent.DsseConnection, error) { +func (r *queryResolver) Dsses(ctx context.Context, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, where *ent.DsseWhereInput) (*ent.DsseConnection, error) { return r.client.Dsse.Query().Paginate(ctx, after, first, before, last, ent.WithDsseFilter(where.Filter)) } // Subjects is the resolver for the subjects field. -func (r *queryResolver) Subjects(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, where *ent.SubjectWhereInput) (*ent.SubjectConnection, error) { +func (r *queryResolver) Subjects(ctx context.Context, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, where *ent.SubjectWhereInput) (*ent.SubjectConnection, error) { return r.client.Subject.Query().Paginate(ctx, after, first, before, last, ent.WithSubjectFilter(where.Filter)) } diff --git a/ent/attestation.go b/ent/attestation.go index 8be2f157..051fd8f6 100644 --- a/ent/attestation.go +++ b/ent/attestation.go @@ -8,6 +8,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestation" "github.com/in-toto/archivista/ent/attestationcollection" ) @@ -16,13 +17,13 @@ import ( type Attestation struct { config `json:"-"` // ID of the ent. - ID int `json:"id,omitempty"` + ID uuid.UUID `json:"id,omitempty"` // Type holds the value of the "type" field. Type string `json:"type,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the AttestationQuery when eager-loading is set. Edges AttestationEdges `json:"edges"` - attestation_collection_attestations *int + attestation_collection_attestations *uuid.UUID selectValues sql.SelectValues } @@ -53,12 +54,12 @@ func (*Attestation) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case attestation.FieldID: - values[i] = new(sql.NullInt64) case attestation.FieldType: values[i] = new(sql.NullString) + case attestation.FieldID: + values[i] = new(uuid.UUID) case attestation.ForeignKeys[0]: // attestation_collection_attestations - values[i] = new(sql.NullInt64) + values[i] = &sql.NullScanner{S: new(uuid.UUID)} default: values[i] = new(sql.UnknownType) } @@ -75,11 +76,11 @@ func (a *Attestation) assignValues(columns []string, values []any) error { for i := range columns { switch columns[i] { case attestation.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + a.ID = *value } - a.ID = int(value.Int64) case attestation.FieldType: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field type", values[i]) @@ -87,11 +88,11 @@ func (a *Attestation) assignValues(columns []string, values []any) error { a.Type = value.String } case attestation.ForeignKeys[0]: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field attestation_collection_attestations", value) + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field attestation_collection_attestations", values[i]) } else if value.Valid { - a.attestation_collection_attestations = new(int) - *a.attestation_collection_attestations = int(value.Int64) + a.attestation_collection_attestations = new(uuid.UUID) + *a.attestation_collection_attestations = *value.S.(*uuid.UUID) } default: a.selectValues.Set(columns[i], values[i]) diff --git a/ent/attestation/attestation.go b/ent/attestation/attestation.go index ad3226ba..916d0d8b 100644 --- a/ent/attestation/attestation.go +++ b/ent/attestation/attestation.go @@ -5,6 +5,7 @@ package attestation import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" ) const ( @@ -57,6 +58,8 @@ func ValidColumn(column string) bool { var ( // TypeValidator is a validator for the "type" field. It is called by the builders before save. TypeValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID ) // OrderOption defines the ordering options for the Attestation queries. diff --git a/ent/attestation/where.go b/ent/attestation/where.go index 5f3a1172..be3532c1 100644 --- a/ent/attestation/where.go +++ b/ent/attestation/where.go @@ -5,51 +5,52 @@ package attestation import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/predicate" ) // ID filters vertices based on their ID field. -func ID(id int) predicate.Attestation { +func ID(id uuid.UUID) predicate.Attestation { return predicate.Attestation(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.Attestation { +func IDEQ(id uuid.UUID) predicate.Attestation { return predicate.Attestation(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.Attestation { +func IDNEQ(id uuid.UUID) predicate.Attestation { return predicate.Attestation(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.Attestation { +func IDIn(ids ...uuid.UUID) predicate.Attestation { return predicate.Attestation(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.Attestation { +func IDNotIn(ids ...uuid.UUID) predicate.Attestation { return predicate.Attestation(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.Attestation { +func IDGT(id uuid.UUID) predicate.Attestation { return predicate.Attestation(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.Attestation { +func IDGTE(id uuid.UUID) predicate.Attestation { return predicate.Attestation(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.Attestation { +func IDLT(id uuid.UUID) predicate.Attestation { return predicate.Attestation(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.Attestation { +func IDLTE(id uuid.UUID) predicate.Attestation { return predicate.Attestation(sql.FieldLTE(FieldID, id)) } diff --git a/ent/attestation_create.go b/ent/attestation_create.go index f38aa1ff..d3233cfd 100644 --- a/ent/attestation_create.go +++ b/ent/attestation_create.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestation" "github.com/in-toto/archivista/ent/attestationcollection" ) @@ -26,8 +27,22 @@ func (ac *AttestationCreate) SetType(s string) *AttestationCreate { return ac } +// SetID sets the "id" field. +func (ac *AttestationCreate) SetID(u uuid.UUID) *AttestationCreate { + ac.mutation.SetID(u) + return ac +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (ac *AttestationCreate) SetNillableID(u *uuid.UUID) *AttestationCreate { + if u != nil { + ac.SetID(*u) + } + return ac +} + // SetAttestationCollectionID sets the "attestation_collection" edge to the AttestationCollection entity by ID. -func (ac *AttestationCreate) SetAttestationCollectionID(id int) *AttestationCreate { +func (ac *AttestationCreate) SetAttestationCollectionID(id uuid.UUID) *AttestationCreate { ac.mutation.SetAttestationCollectionID(id) return ac } @@ -44,6 +59,7 @@ func (ac *AttestationCreate) Mutation() *AttestationMutation { // Save creates the Attestation in the database. func (ac *AttestationCreate) Save(ctx context.Context) (*Attestation, error) { + ac.defaults() return withHooks(ctx, ac.sqlSave, ac.mutation, ac.hooks) } @@ -69,6 +85,14 @@ func (ac *AttestationCreate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (ac *AttestationCreate) defaults() { + if _, ok := ac.mutation.ID(); !ok { + v := attestation.DefaultID() + ac.mutation.SetID(v) + } +} + // check runs all checks and user-defined validators on the builder. func (ac *AttestationCreate) check() error { if _, ok := ac.mutation.GetType(); !ok { @@ -96,8 +120,13 @@ func (ac *AttestationCreate) sqlSave(ctx context.Context) (*Attestation, error) } return nil, err } - id := _spec.ID.Value.(int64) - _node.ID = int(id) + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } ac.mutation.id = &_node.ID ac.mutation.done = true return _node, nil @@ -106,8 +135,12 @@ func (ac *AttestationCreate) sqlSave(ctx context.Context) (*Attestation, error) func (ac *AttestationCreate) createSpec() (*Attestation, *sqlgraph.CreateSpec) { var ( _node = &Attestation{config: ac.config} - _spec = sqlgraph.NewCreateSpec(attestation.Table, sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeInt)) + _spec = sqlgraph.NewCreateSpec(attestation.Table, sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeUUID)) ) + if id, ok := ac.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } if value, ok := ac.mutation.GetType(); ok { _spec.SetField(attestation.FieldType, field.TypeString, value) _node.Type = value @@ -120,7 +153,7 @@ func (ac *AttestationCreate) createSpec() (*Attestation, *sqlgraph.CreateSpec) { Columns: []string{attestation.AttestationCollectionColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -150,6 +183,7 @@ func (acb *AttestationCreateBulk) Save(ctx context.Context) ([]*Attestation, err for i := range acb.builders { func(i int, root context.Context) { builder := acb.builders[i] + builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*AttestationMutation) if !ok { @@ -176,10 +210,6 @@ func (acb *AttestationCreateBulk) Save(ctx context.Context) ([]*Attestation, err return nil, err } mutation.id = &nodes[i].ID - if specs[i].ID.Value != nil { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int(id) - } mutation.done = true return nodes[i], nil }) diff --git a/ent/attestation_delete.go b/ent/attestation_delete.go index 121b9df2..551ee427 100644 --- a/ent/attestation_delete.go +++ b/ent/attestation_delete.go @@ -40,7 +40,7 @@ func (ad *AttestationDelete) ExecX(ctx context.Context) int { } func (ad *AttestationDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(attestation.Table, sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeInt)) + _spec := sqlgraph.NewDeleteSpec(attestation.Table, sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeUUID)) if ps := ad.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { diff --git a/ent/attestation_query.go b/ent/attestation_query.go index 765b8981..c85b962b 100644 --- a/ent/attestation_query.go +++ b/ent/attestation_query.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestation" "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/predicate" @@ -108,8 +109,8 @@ func (aq *AttestationQuery) FirstX(ctx context.Context) *Attestation { // FirstID returns the first Attestation ID from the query. // Returns a *NotFoundError when no Attestation ID was found. -func (aq *AttestationQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -121,7 +122,7 @@ func (aq *AttestationQuery) FirstID(ctx context.Context) (id int, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (aq *AttestationQuery) FirstIDX(ctx context.Context) int { +func (aq *AttestationQuery) FirstIDX(ctx context.Context) uuid.UUID { id, err := aq.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) @@ -159,8 +160,8 @@ func (aq *AttestationQuery) OnlyX(ctx context.Context) *Attestation { // OnlyID is like Only, but returns the only Attestation ID in the query. // Returns a *NotSingularError when more than one Attestation ID is found. // Returns a *NotFoundError when no entities are found. -func (aq *AttestationQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -176,7 +177,7 @@ func (aq *AttestationQuery) OnlyID(ctx context.Context) (id int, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (aq *AttestationQuery) OnlyIDX(ctx context.Context) int { +func (aq *AttestationQuery) OnlyIDX(ctx context.Context) uuid.UUID { id, err := aq.OnlyID(ctx) if err != nil { panic(err) @@ -204,7 +205,7 @@ func (aq *AttestationQuery) AllX(ctx context.Context) []*Attestation { } // IDs executes the query and returns a list of Attestation IDs. -func (aq *AttestationQuery) IDs(ctx context.Context) (ids []int, err error) { +func (aq *AttestationQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if aq.ctx.Unique == nil && aq.path != nil { aq.Unique(true) } @@ -216,7 +217,7 @@ func (aq *AttestationQuery) IDs(ctx context.Context) (ids []int, err error) { } // IDsX is like IDs, but panics if an error occurs. -func (aq *AttestationQuery) IDsX(ctx context.Context) []int { +func (aq *AttestationQuery) IDsX(ctx context.Context) []uuid.UUID { ids, err := aq.IDs(ctx) if err != nil { panic(err) @@ -419,8 +420,8 @@ func (aq *AttestationQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]* } func (aq *AttestationQuery) loadAttestationCollection(ctx context.Context, query *AttestationCollectionQuery, nodes []*Attestation, init func(*Attestation), assign func(*Attestation, *AttestationCollection)) error { - ids := make([]int, 0, len(nodes)) - nodeids := make(map[int][]*Attestation) + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*Attestation) for i := range nodes { if nodes[i].attestation_collection_attestations == nil { continue @@ -464,7 +465,7 @@ func (aq *AttestationQuery) sqlCount(ctx context.Context) (int, error) { } func (aq *AttestationQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(attestation.Table, attestation.Columns, sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeInt)) + _spec := sqlgraph.NewQuerySpec(attestation.Table, attestation.Columns, sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeUUID)) _spec.From = aq.sql if unique := aq.ctx.Unique; unique != nil { _spec.Unique = *unique diff --git a/ent/attestation_update.go b/ent/attestation_update.go index 821ad10a..08d5d1e4 100644 --- a/ent/attestation_update.go +++ b/ent/attestation_update.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestation" "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/predicate" @@ -43,7 +44,7 @@ func (au *AttestationUpdate) SetNillableType(s *string) *AttestationUpdate { } // SetAttestationCollectionID sets the "attestation_collection" edge to the AttestationCollection entity by ID. -func (au *AttestationUpdate) SetAttestationCollectionID(id int) *AttestationUpdate { +func (au *AttestationUpdate) SetAttestationCollectionID(id uuid.UUID) *AttestationUpdate { au.mutation.SetAttestationCollectionID(id) return au } @@ -108,7 +109,7 @@ func (au *AttestationUpdate) sqlSave(ctx context.Context) (n int, err error) { if err := au.check(); err != nil { return n, err } - _spec := sqlgraph.NewUpdateSpec(attestation.Table, attestation.Columns, sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(attestation.Table, attestation.Columns, sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeUUID)) if ps := au.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -127,7 +128,7 @@ func (au *AttestationUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{attestation.AttestationCollectionColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -140,7 +141,7 @@ func (au *AttestationUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{attestation.AttestationCollectionColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -183,7 +184,7 @@ func (auo *AttestationUpdateOne) SetNillableType(s *string) *AttestationUpdateOn } // SetAttestationCollectionID sets the "attestation_collection" edge to the AttestationCollection entity by ID. -func (auo *AttestationUpdateOne) SetAttestationCollectionID(id int) *AttestationUpdateOne { +func (auo *AttestationUpdateOne) SetAttestationCollectionID(id uuid.UUID) *AttestationUpdateOne { auo.mutation.SetAttestationCollectionID(id) return auo } @@ -261,7 +262,7 @@ func (auo *AttestationUpdateOne) sqlSave(ctx context.Context) (_node *Attestatio if err := auo.check(); err != nil { return _node, err } - _spec := sqlgraph.NewUpdateSpec(attestation.Table, attestation.Columns, sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(attestation.Table, attestation.Columns, sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeUUID)) id, ok := auo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Attestation.id" for update`)} @@ -297,7 +298,7 @@ func (auo *AttestationUpdateOne) sqlSave(ctx context.Context) (_node *Attestatio Columns: []string{attestation.AttestationCollectionColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -310,7 +311,7 @@ func (auo *AttestationUpdateOne) sqlSave(ctx context.Context) (_node *Attestatio Columns: []string{attestation.AttestationCollectionColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/ent/attestationcollection.go b/ent/attestationcollection.go index bd1181ef..5a10c896 100644 --- a/ent/attestationcollection.go +++ b/ent/attestationcollection.go @@ -8,6 +8,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/statement" ) @@ -16,13 +17,13 @@ import ( type AttestationCollection struct { config `json:"-"` // ID of the ent. - ID int `json:"id,omitempty"` + ID uuid.UUID `json:"id,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the AttestationCollectionQuery when eager-loading is set. Edges AttestationCollectionEdges `json:"edges"` - statement_attestation_collections *int + statement_attestation_collections *uuid.UUID selectValues sql.SelectValues } @@ -66,12 +67,12 @@ func (*AttestationCollection) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case attestationcollection.FieldID: - values[i] = new(sql.NullInt64) case attestationcollection.FieldName: values[i] = new(sql.NullString) + case attestationcollection.FieldID: + values[i] = new(uuid.UUID) case attestationcollection.ForeignKeys[0]: // statement_attestation_collections - values[i] = new(sql.NullInt64) + values[i] = &sql.NullScanner{S: new(uuid.UUID)} default: values[i] = new(sql.UnknownType) } @@ -88,11 +89,11 @@ func (ac *AttestationCollection) assignValues(columns []string, values []any) er for i := range columns { switch columns[i] { case attestationcollection.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + ac.ID = *value } - ac.ID = int(value.Int64) case attestationcollection.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) @@ -100,11 +101,11 @@ func (ac *AttestationCollection) assignValues(columns []string, values []any) er ac.Name = value.String } case attestationcollection.ForeignKeys[0]: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field statement_attestation_collections", value) + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field statement_attestation_collections", values[i]) } else if value.Valid { - ac.statement_attestation_collections = new(int) - *ac.statement_attestation_collections = int(value.Int64) + ac.statement_attestation_collections = new(uuid.UUID) + *ac.statement_attestation_collections = *value.S.(*uuid.UUID) } default: ac.selectValues.Set(columns[i], values[i]) diff --git a/ent/attestationcollection/attestationcollection.go b/ent/attestationcollection/attestationcollection.go index 8b509f8b..71b31782 100644 --- a/ent/attestationcollection/attestationcollection.go +++ b/ent/attestationcollection/attestationcollection.go @@ -5,6 +5,7 @@ package attestationcollection import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" ) const ( @@ -66,6 +67,8 @@ func ValidColumn(column string) bool { var ( // NameValidator is a validator for the "name" field. It is called by the builders before save. NameValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID ) // OrderOption defines the ordering options for the AttestationCollection queries. diff --git a/ent/attestationcollection/where.go b/ent/attestationcollection/where.go index 3cc1cd16..5fae485c 100644 --- a/ent/attestationcollection/where.go +++ b/ent/attestationcollection/where.go @@ -5,51 +5,52 @@ package attestationcollection import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/predicate" ) // ID filters vertices based on their ID field. -func ID(id int) predicate.AttestationCollection { +func ID(id uuid.UUID) predicate.AttestationCollection { return predicate.AttestationCollection(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.AttestationCollection { +func IDEQ(id uuid.UUID) predicate.AttestationCollection { return predicate.AttestationCollection(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.AttestationCollection { +func IDNEQ(id uuid.UUID) predicate.AttestationCollection { return predicate.AttestationCollection(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.AttestationCollection { +func IDIn(ids ...uuid.UUID) predicate.AttestationCollection { return predicate.AttestationCollection(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.AttestationCollection { +func IDNotIn(ids ...uuid.UUID) predicate.AttestationCollection { return predicate.AttestationCollection(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.AttestationCollection { +func IDGT(id uuid.UUID) predicate.AttestationCollection { return predicate.AttestationCollection(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.AttestationCollection { +func IDGTE(id uuid.UUID) predicate.AttestationCollection { return predicate.AttestationCollection(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.AttestationCollection { +func IDLT(id uuid.UUID) predicate.AttestationCollection { return predicate.AttestationCollection(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.AttestationCollection { +func IDLTE(id uuid.UUID) predicate.AttestationCollection { return predicate.AttestationCollection(sql.FieldLTE(FieldID, id)) } diff --git a/ent/attestationcollection_create.go b/ent/attestationcollection_create.go index e3236f40..2fa8080e 100644 --- a/ent/attestationcollection_create.go +++ b/ent/attestationcollection_create.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestation" "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/statement" @@ -27,15 +28,29 @@ func (acc *AttestationCollectionCreate) SetName(s string) *AttestationCollection return acc } +// SetID sets the "id" field. +func (acc *AttestationCollectionCreate) SetID(u uuid.UUID) *AttestationCollectionCreate { + acc.mutation.SetID(u) + return acc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (acc *AttestationCollectionCreate) SetNillableID(u *uuid.UUID) *AttestationCollectionCreate { + if u != nil { + acc.SetID(*u) + } + return acc +} + // AddAttestationIDs adds the "attestations" edge to the Attestation entity by IDs. -func (acc *AttestationCollectionCreate) AddAttestationIDs(ids ...int) *AttestationCollectionCreate { +func (acc *AttestationCollectionCreate) AddAttestationIDs(ids ...uuid.UUID) *AttestationCollectionCreate { acc.mutation.AddAttestationIDs(ids...) return acc } // AddAttestations adds the "attestations" edges to the Attestation entity. func (acc *AttestationCollectionCreate) AddAttestations(a ...*Attestation) *AttestationCollectionCreate { - ids := make([]int, len(a)) + ids := make([]uuid.UUID, len(a)) for i := range a { ids[i] = a[i].ID } @@ -43,7 +58,7 @@ func (acc *AttestationCollectionCreate) AddAttestations(a ...*Attestation) *Atte } // SetStatementID sets the "statement" edge to the Statement entity by ID. -func (acc *AttestationCollectionCreate) SetStatementID(id int) *AttestationCollectionCreate { +func (acc *AttestationCollectionCreate) SetStatementID(id uuid.UUID) *AttestationCollectionCreate { acc.mutation.SetStatementID(id) return acc } @@ -60,6 +75,7 @@ func (acc *AttestationCollectionCreate) Mutation() *AttestationCollectionMutatio // Save creates the AttestationCollection in the database. func (acc *AttestationCollectionCreate) Save(ctx context.Context) (*AttestationCollection, error) { + acc.defaults() return withHooks(ctx, acc.sqlSave, acc.mutation, acc.hooks) } @@ -85,6 +101,14 @@ func (acc *AttestationCollectionCreate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (acc *AttestationCollectionCreate) defaults() { + if _, ok := acc.mutation.ID(); !ok { + v := attestationcollection.DefaultID() + acc.mutation.SetID(v) + } +} + // check runs all checks and user-defined validators on the builder. func (acc *AttestationCollectionCreate) check() error { if _, ok := acc.mutation.Name(); !ok { @@ -112,8 +136,13 @@ func (acc *AttestationCollectionCreate) sqlSave(ctx context.Context) (*Attestati } return nil, err } - id := _spec.ID.Value.(int64) - _node.ID = int(id) + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } acc.mutation.id = &_node.ID acc.mutation.done = true return _node, nil @@ -122,8 +151,12 @@ func (acc *AttestationCollectionCreate) sqlSave(ctx context.Context) (*Attestati func (acc *AttestationCollectionCreate) createSpec() (*AttestationCollection, *sqlgraph.CreateSpec) { var ( _node = &AttestationCollection{config: acc.config} - _spec = sqlgraph.NewCreateSpec(attestationcollection.Table, sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeInt)) + _spec = sqlgraph.NewCreateSpec(attestationcollection.Table, sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeUUID)) ) + if id, ok := acc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } if value, ok := acc.mutation.Name(); ok { _spec.SetField(attestationcollection.FieldName, field.TypeString, value) _node.Name = value @@ -136,7 +169,7 @@ func (acc *AttestationCollectionCreate) createSpec() (*AttestationCollection, *s Columns: []string{attestationcollection.AttestationsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -152,7 +185,7 @@ func (acc *AttestationCollectionCreate) createSpec() (*AttestationCollection, *s Columns: []string{attestationcollection.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -182,6 +215,7 @@ func (accb *AttestationCollectionCreateBulk) Save(ctx context.Context) ([]*Attes for i := range accb.builders { func(i int, root context.Context) { builder := accb.builders[i] + builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*AttestationCollectionMutation) if !ok { @@ -208,10 +242,6 @@ func (accb *AttestationCollectionCreateBulk) Save(ctx context.Context) ([]*Attes return nil, err } mutation.id = &nodes[i].ID - if specs[i].ID.Value != nil { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int(id) - } mutation.done = true return nodes[i], nil }) diff --git a/ent/attestationcollection_delete.go b/ent/attestationcollection_delete.go index 478886dc..c95146a2 100644 --- a/ent/attestationcollection_delete.go +++ b/ent/attestationcollection_delete.go @@ -40,7 +40,7 @@ func (acd *AttestationCollectionDelete) ExecX(ctx context.Context) int { } func (acd *AttestationCollectionDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(attestationcollection.Table, sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeInt)) + _spec := sqlgraph.NewDeleteSpec(attestationcollection.Table, sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeUUID)) if ps := acd.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { diff --git a/ent/attestationcollection_query.go b/ent/attestationcollection_query.go index c21ea7e8..d7ce19dd 100644 --- a/ent/attestationcollection_query.go +++ b/ent/attestationcollection_query.go @@ -11,6 +11,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestation" "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/predicate" @@ -134,8 +135,8 @@ func (acq *AttestationCollectionQuery) FirstX(ctx context.Context) *AttestationC // FirstID returns the first AttestationCollection ID from the query. // Returns a *NotFoundError when no AttestationCollection ID was found. -func (acq *AttestationCollectionQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -147,7 +148,7 @@ func (acq *AttestationCollectionQuery) FirstID(ctx context.Context) (id int, err } // FirstIDX is like FirstID, but panics if an error occurs. -func (acq *AttestationCollectionQuery) FirstIDX(ctx context.Context) int { +func (acq *AttestationCollectionQuery) FirstIDX(ctx context.Context) uuid.UUID { id, err := acq.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) @@ -185,8 +186,8 @@ func (acq *AttestationCollectionQuery) OnlyX(ctx context.Context) *AttestationCo // OnlyID is like Only, but returns the only AttestationCollection ID in the query. // Returns a *NotSingularError when more than one AttestationCollection ID is found. // Returns a *NotFoundError when no entities are found. -func (acq *AttestationCollectionQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -202,7 +203,7 @@ func (acq *AttestationCollectionQuery) OnlyID(ctx context.Context) (id int, err } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (acq *AttestationCollectionQuery) OnlyIDX(ctx context.Context) int { +func (acq *AttestationCollectionQuery) OnlyIDX(ctx context.Context) uuid.UUID { id, err := acq.OnlyID(ctx) if err != nil { panic(err) @@ -230,7 +231,7 @@ func (acq *AttestationCollectionQuery) AllX(ctx context.Context) []*AttestationC } // IDs executes the query and returns a list of AttestationCollection IDs. -func (acq *AttestationCollectionQuery) IDs(ctx context.Context) (ids []int, err error) { +func (acq *AttestationCollectionQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if acq.ctx.Unique == nil && acq.path != nil { acq.Unique(true) } @@ -242,7 +243,7 @@ func (acq *AttestationCollectionQuery) IDs(ctx context.Context) (ids []int, err } // IDsX is like IDs, but panics if an error occurs. -func (acq *AttestationCollectionQuery) IDsX(ctx context.Context) []int { +func (acq *AttestationCollectionQuery) IDsX(ctx context.Context) []uuid.UUID { ids, err := acq.IDs(ctx) if err != nil { panic(err) @@ -473,7 +474,7 @@ func (acq *AttestationCollectionQuery) sqlAll(ctx context.Context, hooks ...quer func (acq *AttestationCollectionQuery) loadAttestations(ctx context.Context, query *AttestationQuery, nodes []*AttestationCollection, init func(*AttestationCollection), assign func(*AttestationCollection, *Attestation)) error { fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int]*AttestationCollection) + nodeids := make(map[uuid.UUID]*AttestationCollection) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] @@ -503,8 +504,8 @@ func (acq *AttestationCollectionQuery) loadAttestations(ctx context.Context, que return nil } func (acq *AttestationCollectionQuery) loadStatement(ctx context.Context, query *StatementQuery, nodes []*AttestationCollection, init func(*AttestationCollection), assign func(*AttestationCollection, *Statement)) error { - ids := make([]int, 0, len(nodes)) - nodeids := make(map[int][]*AttestationCollection) + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*AttestationCollection) for i := range nodes { if nodes[i].statement_attestation_collections == nil { continue @@ -548,7 +549,7 @@ func (acq *AttestationCollectionQuery) sqlCount(ctx context.Context) (int, error } func (acq *AttestationCollectionQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(attestationcollection.Table, attestationcollection.Columns, sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeInt)) + _spec := sqlgraph.NewQuerySpec(attestationcollection.Table, attestationcollection.Columns, sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeUUID)) _spec.From = acq.sql if unique := acq.ctx.Unique; unique != nil { _spec.Unique = *unique diff --git a/ent/attestationcollection_update.go b/ent/attestationcollection_update.go index 53eb3983..7234cf19 100644 --- a/ent/attestationcollection_update.go +++ b/ent/attestationcollection_update.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestation" "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/predicate" @@ -44,14 +45,14 @@ func (acu *AttestationCollectionUpdate) SetNillableName(s *string) *AttestationC } // AddAttestationIDs adds the "attestations" edge to the Attestation entity by IDs. -func (acu *AttestationCollectionUpdate) AddAttestationIDs(ids ...int) *AttestationCollectionUpdate { +func (acu *AttestationCollectionUpdate) AddAttestationIDs(ids ...uuid.UUID) *AttestationCollectionUpdate { acu.mutation.AddAttestationIDs(ids...) return acu } // AddAttestations adds the "attestations" edges to the Attestation entity. func (acu *AttestationCollectionUpdate) AddAttestations(a ...*Attestation) *AttestationCollectionUpdate { - ids := make([]int, len(a)) + ids := make([]uuid.UUID, len(a)) for i := range a { ids[i] = a[i].ID } @@ -59,7 +60,7 @@ func (acu *AttestationCollectionUpdate) AddAttestations(a ...*Attestation) *Atte } // SetStatementID sets the "statement" edge to the Statement entity by ID. -func (acu *AttestationCollectionUpdate) SetStatementID(id int) *AttestationCollectionUpdate { +func (acu *AttestationCollectionUpdate) SetStatementID(id uuid.UUID) *AttestationCollectionUpdate { acu.mutation.SetStatementID(id) return acu } @@ -81,14 +82,14 @@ func (acu *AttestationCollectionUpdate) ClearAttestations() *AttestationCollecti } // RemoveAttestationIDs removes the "attestations" edge to Attestation entities by IDs. -func (acu *AttestationCollectionUpdate) RemoveAttestationIDs(ids ...int) *AttestationCollectionUpdate { +func (acu *AttestationCollectionUpdate) RemoveAttestationIDs(ids ...uuid.UUID) *AttestationCollectionUpdate { acu.mutation.RemoveAttestationIDs(ids...) return acu } // RemoveAttestations removes "attestations" edges to Attestation entities. func (acu *AttestationCollectionUpdate) RemoveAttestations(a ...*Attestation) *AttestationCollectionUpdate { - ids := make([]int, len(a)) + ids := make([]uuid.UUID, len(a)) for i := range a { ids[i] = a[i].ID } @@ -145,7 +146,7 @@ func (acu *AttestationCollectionUpdate) sqlSave(ctx context.Context) (n int, err if err := acu.check(); err != nil { return n, err } - _spec := sqlgraph.NewUpdateSpec(attestationcollection.Table, attestationcollection.Columns, sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(attestationcollection.Table, attestationcollection.Columns, sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeUUID)) if ps := acu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -164,7 +165,7 @@ func (acu *AttestationCollectionUpdate) sqlSave(ctx context.Context) (n int, err Columns: []string{attestationcollection.AttestationsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -177,7 +178,7 @@ func (acu *AttestationCollectionUpdate) sqlSave(ctx context.Context) (n int, err Columns: []string{attestationcollection.AttestationsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -193,7 +194,7 @@ func (acu *AttestationCollectionUpdate) sqlSave(ctx context.Context) (n int, err Columns: []string{attestationcollection.AttestationsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -209,7 +210,7 @@ func (acu *AttestationCollectionUpdate) sqlSave(ctx context.Context) (n int, err Columns: []string{attestationcollection.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -222,7 +223,7 @@ func (acu *AttestationCollectionUpdate) sqlSave(ctx context.Context) (n int, err Columns: []string{attestationcollection.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -265,14 +266,14 @@ func (acuo *AttestationCollectionUpdateOne) SetNillableName(s *string) *Attestat } // AddAttestationIDs adds the "attestations" edge to the Attestation entity by IDs. -func (acuo *AttestationCollectionUpdateOne) AddAttestationIDs(ids ...int) *AttestationCollectionUpdateOne { +func (acuo *AttestationCollectionUpdateOne) AddAttestationIDs(ids ...uuid.UUID) *AttestationCollectionUpdateOne { acuo.mutation.AddAttestationIDs(ids...) return acuo } // AddAttestations adds the "attestations" edges to the Attestation entity. func (acuo *AttestationCollectionUpdateOne) AddAttestations(a ...*Attestation) *AttestationCollectionUpdateOne { - ids := make([]int, len(a)) + ids := make([]uuid.UUID, len(a)) for i := range a { ids[i] = a[i].ID } @@ -280,7 +281,7 @@ func (acuo *AttestationCollectionUpdateOne) AddAttestations(a ...*Attestation) * } // SetStatementID sets the "statement" edge to the Statement entity by ID. -func (acuo *AttestationCollectionUpdateOne) SetStatementID(id int) *AttestationCollectionUpdateOne { +func (acuo *AttestationCollectionUpdateOne) SetStatementID(id uuid.UUID) *AttestationCollectionUpdateOne { acuo.mutation.SetStatementID(id) return acuo } @@ -302,14 +303,14 @@ func (acuo *AttestationCollectionUpdateOne) ClearAttestations() *AttestationColl } // RemoveAttestationIDs removes the "attestations" edge to Attestation entities by IDs. -func (acuo *AttestationCollectionUpdateOne) RemoveAttestationIDs(ids ...int) *AttestationCollectionUpdateOne { +func (acuo *AttestationCollectionUpdateOne) RemoveAttestationIDs(ids ...uuid.UUID) *AttestationCollectionUpdateOne { acuo.mutation.RemoveAttestationIDs(ids...) return acuo } // RemoveAttestations removes "attestations" edges to Attestation entities. func (acuo *AttestationCollectionUpdateOne) RemoveAttestations(a ...*Attestation) *AttestationCollectionUpdateOne { - ids := make([]int, len(a)) + ids := make([]uuid.UUID, len(a)) for i := range a { ids[i] = a[i].ID } @@ -379,7 +380,7 @@ func (acuo *AttestationCollectionUpdateOne) sqlSave(ctx context.Context) (_node if err := acuo.check(); err != nil { return _node, err } - _spec := sqlgraph.NewUpdateSpec(attestationcollection.Table, attestationcollection.Columns, sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(attestationcollection.Table, attestationcollection.Columns, sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeUUID)) id, ok := acuo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AttestationCollection.id" for update`)} @@ -415,7 +416,7 @@ func (acuo *AttestationCollectionUpdateOne) sqlSave(ctx context.Context) (_node Columns: []string{attestationcollection.AttestationsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -428,7 +429,7 @@ func (acuo *AttestationCollectionUpdateOne) sqlSave(ctx context.Context) (_node Columns: []string{attestationcollection.AttestationsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -444,7 +445,7 @@ func (acuo *AttestationCollectionUpdateOne) sqlSave(ctx context.Context) (_node Columns: []string{attestationcollection.AttestationsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestation.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -460,7 +461,7 @@ func (acuo *AttestationCollectionUpdateOne) sqlSave(ctx context.Context) (_node Columns: []string{attestationcollection.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -473,7 +474,7 @@ func (acuo *AttestationCollectionUpdateOne) sqlSave(ctx context.Context) (_node Columns: []string{attestationcollection.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/ent/attestationpolicy.go b/ent/attestationpolicy.go index ed653e31..017640f9 100644 --- a/ent/attestationpolicy.go +++ b/ent/attestationpolicy.go @@ -8,6 +8,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestationpolicy" "github.com/in-toto/archivista/ent/statement" ) @@ -16,13 +17,13 @@ import ( type AttestationPolicy struct { config `json:"-"` // ID of the ent. - ID int `json:"id,omitempty"` + ID uuid.UUID `json:"id,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the AttestationPolicyQuery when eager-loading is set. Edges AttestationPolicyEdges `json:"edges"` - statement_policy *int + statement_policy *uuid.UUID selectValues sql.SelectValues } @@ -53,12 +54,12 @@ func (*AttestationPolicy) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case attestationpolicy.FieldID: - values[i] = new(sql.NullInt64) case attestationpolicy.FieldName: values[i] = new(sql.NullString) + case attestationpolicy.FieldID: + values[i] = new(uuid.UUID) case attestationpolicy.ForeignKeys[0]: // statement_policy - values[i] = new(sql.NullInt64) + values[i] = &sql.NullScanner{S: new(uuid.UUID)} default: values[i] = new(sql.UnknownType) } @@ -75,11 +76,11 @@ func (ap *AttestationPolicy) assignValues(columns []string, values []any) error for i := range columns { switch columns[i] { case attestationpolicy.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + ap.ID = *value } - ap.ID = int(value.Int64) case attestationpolicy.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) @@ -87,11 +88,11 @@ func (ap *AttestationPolicy) assignValues(columns []string, values []any) error ap.Name = value.String } case attestationpolicy.ForeignKeys[0]: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field statement_policy", value) + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field statement_policy", values[i]) } else if value.Valid { - ap.statement_policy = new(int) - *ap.statement_policy = int(value.Int64) + ap.statement_policy = new(uuid.UUID) + *ap.statement_policy = *value.S.(*uuid.UUID) } default: ap.selectValues.Set(columns[i], values[i]) diff --git a/ent/attestationpolicy/attestationpolicy.go b/ent/attestationpolicy/attestationpolicy.go index 005fb2a3..0ef11122 100644 --- a/ent/attestationpolicy/attestationpolicy.go +++ b/ent/attestationpolicy/attestationpolicy.go @@ -5,6 +5,7 @@ package attestationpolicy import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" ) const ( @@ -57,6 +58,8 @@ func ValidColumn(column string) bool { var ( // NameValidator is a validator for the "name" field. It is called by the builders before save. NameValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID ) // OrderOption defines the ordering options for the AttestationPolicy queries. diff --git a/ent/attestationpolicy/where.go b/ent/attestationpolicy/where.go index a9124fa7..a43c3980 100644 --- a/ent/attestationpolicy/where.go +++ b/ent/attestationpolicy/where.go @@ -5,51 +5,52 @@ package attestationpolicy import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/predicate" ) // ID filters vertices based on their ID field. -func ID(id int) predicate.AttestationPolicy { +func ID(id uuid.UUID) predicate.AttestationPolicy { return predicate.AttestationPolicy(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.AttestationPolicy { +func IDEQ(id uuid.UUID) predicate.AttestationPolicy { return predicate.AttestationPolicy(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.AttestationPolicy { +func IDNEQ(id uuid.UUID) predicate.AttestationPolicy { return predicate.AttestationPolicy(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.AttestationPolicy { +func IDIn(ids ...uuid.UUID) predicate.AttestationPolicy { return predicate.AttestationPolicy(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.AttestationPolicy { +func IDNotIn(ids ...uuid.UUID) predicate.AttestationPolicy { return predicate.AttestationPolicy(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.AttestationPolicy { +func IDGT(id uuid.UUID) predicate.AttestationPolicy { return predicate.AttestationPolicy(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.AttestationPolicy { +func IDGTE(id uuid.UUID) predicate.AttestationPolicy { return predicate.AttestationPolicy(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.AttestationPolicy { +func IDLT(id uuid.UUID) predicate.AttestationPolicy { return predicate.AttestationPolicy(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.AttestationPolicy { +func IDLTE(id uuid.UUID) predicate.AttestationPolicy { return predicate.AttestationPolicy(sql.FieldLTE(FieldID, id)) } diff --git a/ent/attestationpolicy_create.go b/ent/attestationpolicy_create.go index 830efea6..4e12eb1a 100644 --- a/ent/attestationpolicy_create.go +++ b/ent/attestationpolicy_create.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestationpolicy" "github.com/in-toto/archivista/ent/statement" ) @@ -26,14 +27,28 @@ func (apc *AttestationPolicyCreate) SetName(s string) *AttestationPolicyCreate { return apc } +// SetID sets the "id" field. +func (apc *AttestationPolicyCreate) SetID(u uuid.UUID) *AttestationPolicyCreate { + apc.mutation.SetID(u) + return apc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (apc *AttestationPolicyCreate) SetNillableID(u *uuid.UUID) *AttestationPolicyCreate { + if u != nil { + apc.SetID(*u) + } + return apc +} + // SetStatementID sets the "statement" edge to the Statement entity by ID. -func (apc *AttestationPolicyCreate) SetStatementID(id int) *AttestationPolicyCreate { +func (apc *AttestationPolicyCreate) SetStatementID(id uuid.UUID) *AttestationPolicyCreate { apc.mutation.SetStatementID(id) return apc } // SetNillableStatementID sets the "statement" edge to the Statement entity by ID if the given value is not nil. -func (apc *AttestationPolicyCreate) SetNillableStatementID(id *int) *AttestationPolicyCreate { +func (apc *AttestationPolicyCreate) SetNillableStatementID(id *uuid.UUID) *AttestationPolicyCreate { if id != nil { apc = apc.SetStatementID(*id) } @@ -52,6 +67,7 @@ func (apc *AttestationPolicyCreate) Mutation() *AttestationPolicyMutation { // Save creates the AttestationPolicy in the database. func (apc *AttestationPolicyCreate) Save(ctx context.Context) (*AttestationPolicy, error) { + apc.defaults() return withHooks(ctx, apc.sqlSave, apc.mutation, apc.hooks) } @@ -77,6 +93,14 @@ func (apc *AttestationPolicyCreate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (apc *AttestationPolicyCreate) defaults() { + if _, ok := apc.mutation.ID(); !ok { + v := attestationpolicy.DefaultID() + apc.mutation.SetID(v) + } +} + // check runs all checks and user-defined validators on the builder. func (apc *AttestationPolicyCreate) check() error { if _, ok := apc.mutation.Name(); !ok { @@ -101,8 +125,13 @@ func (apc *AttestationPolicyCreate) sqlSave(ctx context.Context) (*AttestationPo } return nil, err } - id := _spec.ID.Value.(int64) - _node.ID = int(id) + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } apc.mutation.id = &_node.ID apc.mutation.done = true return _node, nil @@ -111,8 +140,12 @@ func (apc *AttestationPolicyCreate) sqlSave(ctx context.Context) (*AttestationPo func (apc *AttestationPolicyCreate) createSpec() (*AttestationPolicy, *sqlgraph.CreateSpec) { var ( _node = &AttestationPolicy{config: apc.config} - _spec = sqlgraph.NewCreateSpec(attestationpolicy.Table, sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeInt)) + _spec = sqlgraph.NewCreateSpec(attestationpolicy.Table, sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeUUID)) ) + if id, ok := apc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } if value, ok := apc.mutation.Name(); ok { _spec.SetField(attestationpolicy.FieldName, field.TypeString, value) _node.Name = value @@ -125,7 +158,7 @@ func (apc *AttestationPolicyCreate) createSpec() (*AttestationPolicy, *sqlgraph. Columns: []string{attestationpolicy.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -155,6 +188,7 @@ func (apcb *AttestationPolicyCreateBulk) Save(ctx context.Context) ([]*Attestati for i := range apcb.builders { func(i int, root context.Context) { builder := apcb.builders[i] + builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*AttestationPolicyMutation) if !ok { @@ -181,10 +215,6 @@ func (apcb *AttestationPolicyCreateBulk) Save(ctx context.Context) ([]*Attestati return nil, err } mutation.id = &nodes[i].ID - if specs[i].ID.Value != nil { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int(id) - } mutation.done = true return nodes[i], nil }) diff --git a/ent/attestationpolicy_delete.go b/ent/attestationpolicy_delete.go index def7c519..d5757346 100644 --- a/ent/attestationpolicy_delete.go +++ b/ent/attestationpolicy_delete.go @@ -40,7 +40,7 @@ func (apd *AttestationPolicyDelete) ExecX(ctx context.Context) int { } func (apd *AttestationPolicyDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(attestationpolicy.Table, sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeInt)) + _spec := sqlgraph.NewDeleteSpec(attestationpolicy.Table, sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeUUID)) if ps := apd.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { diff --git a/ent/attestationpolicy_query.go b/ent/attestationpolicy_query.go index dfa2c4ff..eed10743 100644 --- a/ent/attestationpolicy_query.go +++ b/ent/attestationpolicy_query.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestationpolicy" "github.com/in-toto/archivista/ent/predicate" "github.com/in-toto/archivista/ent/statement" @@ -108,8 +109,8 @@ func (apq *AttestationPolicyQuery) FirstX(ctx context.Context) *AttestationPolic // FirstID returns the first AttestationPolicy ID from the query. // Returns a *NotFoundError when no AttestationPolicy ID was found. -func (apq *AttestationPolicyQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -121,7 +122,7 @@ func (apq *AttestationPolicyQuery) FirstID(ctx context.Context) (id int, err err } // FirstIDX is like FirstID, but panics if an error occurs. -func (apq *AttestationPolicyQuery) FirstIDX(ctx context.Context) int { +func (apq *AttestationPolicyQuery) FirstIDX(ctx context.Context) uuid.UUID { id, err := apq.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) @@ -159,8 +160,8 @@ func (apq *AttestationPolicyQuery) OnlyX(ctx context.Context) *AttestationPolicy // OnlyID is like Only, but returns the only AttestationPolicy ID in the query. // Returns a *NotSingularError when more than one AttestationPolicy ID is found. // Returns a *NotFoundError when no entities are found. -func (apq *AttestationPolicyQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -176,7 +177,7 @@ func (apq *AttestationPolicyQuery) OnlyID(ctx context.Context) (id int, err erro } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (apq *AttestationPolicyQuery) OnlyIDX(ctx context.Context) int { +func (apq *AttestationPolicyQuery) OnlyIDX(ctx context.Context) uuid.UUID { id, err := apq.OnlyID(ctx) if err != nil { panic(err) @@ -204,7 +205,7 @@ func (apq *AttestationPolicyQuery) AllX(ctx context.Context) []*AttestationPolic } // IDs executes the query and returns a list of AttestationPolicy IDs. -func (apq *AttestationPolicyQuery) IDs(ctx context.Context) (ids []int, err error) { +func (apq *AttestationPolicyQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if apq.ctx.Unique == nil && apq.path != nil { apq.Unique(true) } @@ -216,7 +217,7 @@ func (apq *AttestationPolicyQuery) IDs(ctx context.Context) (ids []int, err erro } // IDsX is like IDs, but panics if an error occurs. -func (apq *AttestationPolicyQuery) IDsX(ctx context.Context) []int { +func (apq *AttestationPolicyQuery) IDsX(ctx context.Context) []uuid.UUID { ids, err := apq.IDs(ctx) if err != nil { panic(err) @@ -419,8 +420,8 @@ func (apq *AttestationPolicyQuery) sqlAll(ctx context.Context, hooks ...queryHoo } func (apq *AttestationPolicyQuery) loadStatement(ctx context.Context, query *StatementQuery, nodes []*AttestationPolicy, init func(*AttestationPolicy), assign func(*AttestationPolicy, *Statement)) error { - ids := make([]int, 0, len(nodes)) - nodeids := make(map[int][]*AttestationPolicy) + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*AttestationPolicy) for i := range nodes { if nodes[i].statement_policy == nil { continue @@ -464,7 +465,7 @@ func (apq *AttestationPolicyQuery) sqlCount(ctx context.Context) (int, error) { } func (apq *AttestationPolicyQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(attestationpolicy.Table, attestationpolicy.Columns, sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeInt)) + _spec := sqlgraph.NewQuerySpec(attestationpolicy.Table, attestationpolicy.Columns, sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeUUID)) _spec.From = apq.sql if unique := apq.ctx.Unique; unique != nil { _spec.Unique = *unique diff --git a/ent/attestationpolicy_update.go b/ent/attestationpolicy_update.go index 3443d551..39f84447 100644 --- a/ent/attestationpolicy_update.go +++ b/ent/attestationpolicy_update.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestationpolicy" "github.com/in-toto/archivista/ent/predicate" "github.com/in-toto/archivista/ent/statement" @@ -43,13 +44,13 @@ func (apu *AttestationPolicyUpdate) SetNillableName(s *string) *AttestationPolic } // SetStatementID sets the "statement" edge to the Statement entity by ID. -func (apu *AttestationPolicyUpdate) SetStatementID(id int) *AttestationPolicyUpdate { +func (apu *AttestationPolicyUpdate) SetStatementID(id uuid.UUID) *AttestationPolicyUpdate { apu.mutation.SetStatementID(id) return apu } // SetNillableStatementID sets the "statement" edge to the Statement entity by ID if the given value is not nil. -func (apu *AttestationPolicyUpdate) SetNillableStatementID(id *int) *AttestationPolicyUpdate { +func (apu *AttestationPolicyUpdate) SetNillableStatementID(id *uuid.UUID) *AttestationPolicyUpdate { if id != nil { apu = apu.SetStatementID(*id) } @@ -113,7 +114,7 @@ func (apu *AttestationPolicyUpdate) sqlSave(ctx context.Context) (n int, err err if err := apu.check(); err != nil { return n, err } - _spec := sqlgraph.NewUpdateSpec(attestationpolicy.Table, attestationpolicy.Columns, sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(attestationpolicy.Table, attestationpolicy.Columns, sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeUUID)) if ps := apu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -132,7 +133,7 @@ func (apu *AttestationPolicyUpdate) sqlSave(ctx context.Context) (n int, err err Columns: []string{attestationpolicy.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -145,7 +146,7 @@ func (apu *AttestationPolicyUpdate) sqlSave(ctx context.Context) (n int, err err Columns: []string{attestationpolicy.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -188,13 +189,13 @@ func (apuo *AttestationPolicyUpdateOne) SetNillableName(s *string) *AttestationP } // SetStatementID sets the "statement" edge to the Statement entity by ID. -func (apuo *AttestationPolicyUpdateOne) SetStatementID(id int) *AttestationPolicyUpdateOne { +func (apuo *AttestationPolicyUpdateOne) SetStatementID(id uuid.UUID) *AttestationPolicyUpdateOne { apuo.mutation.SetStatementID(id) return apuo } // SetNillableStatementID sets the "statement" edge to the Statement entity by ID if the given value is not nil. -func (apuo *AttestationPolicyUpdateOne) SetNillableStatementID(id *int) *AttestationPolicyUpdateOne { +func (apuo *AttestationPolicyUpdateOne) SetNillableStatementID(id *uuid.UUID) *AttestationPolicyUpdateOne { if id != nil { apuo = apuo.SetStatementID(*id) } @@ -271,7 +272,7 @@ func (apuo *AttestationPolicyUpdateOne) sqlSave(ctx context.Context) (_node *Att if err := apuo.check(); err != nil { return _node, err } - _spec := sqlgraph.NewUpdateSpec(attestationpolicy.Table, attestationpolicy.Columns, sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(attestationpolicy.Table, attestationpolicy.Columns, sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeUUID)) id, ok := apuo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AttestationPolicy.id" for update`)} @@ -307,7 +308,7 @@ func (apuo *AttestationPolicyUpdateOne) sqlSave(ctx context.Context) (_node *Att Columns: []string{attestationpolicy.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -320,7 +321,7 @@ func (apuo *AttestationPolicyUpdateOne) sqlSave(ctx context.Context) (_node *Att Columns: []string{attestationpolicy.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/ent/client.go b/ent/client.go index 81c42fdf..3fde0f77 100644 --- a/ent/client.go +++ b/ent/client.go @@ -9,6 +9,7 @@ import ( "log" "reflect" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/migrate" "entgo.io/ent" @@ -52,8 +53,6 @@ type Client struct { SubjectDigest *SubjectDigestClient // Timestamp is the client for interacting with the Timestamp builders. Timestamp *TimestampClient - // additional fields for node api - tables tables } // NewClient creates a new client configured with the given options. @@ -344,7 +343,7 @@ func (c *AttestationClient) UpdateOne(a *Attestation) *AttestationUpdateOne { } // UpdateOneID returns an update builder for the given id. -func (c *AttestationClient) UpdateOneID(id int) *AttestationUpdateOne { +func (c *AttestationClient) UpdateOneID(id uuid.UUID) *AttestationUpdateOne { mutation := newAttestationMutation(c.config, OpUpdateOne, withAttestationID(id)) return &AttestationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -361,7 +360,7 @@ func (c *AttestationClient) DeleteOne(a *Attestation) *AttestationDeleteOne { } // DeleteOneID returns a builder for deleting the given entity by its id. -func (c *AttestationClient) DeleteOneID(id int) *AttestationDeleteOne { +func (c *AttestationClient) DeleteOneID(id uuid.UUID) *AttestationDeleteOne { builder := c.Delete().Where(attestation.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne @@ -378,12 +377,12 @@ func (c *AttestationClient) Query() *AttestationQuery { } // Get returns a Attestation entity by its id. -func (c *AttestationClient) Get(ctx context.Context, id int) (*Attestation, error) { +func (c *AttestationClient) Get(ctx context.Context, id uuid.UUID) (*Attestation, error) { return c.Query().Where(attestation.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. -func (c *AttestationClient) GetX(ctx context.Context, id int) *Attestation { +func (c *AttestationClient) GetX(ctx context.Context, id uuid.UUID) *Attestation { obj, err := c.Get(ctx, id) if err != nil { panic(err) @@ -493,7 +492,7 @@ func (c *AttestationCollectionClient) UpdateOne(ac *AttestationCollection) *Atte } // UpdateOneID returns an update builder for the given id. -func (c *AttestationCollectionClient) UpdateOneID(id int) *AttestationCollectionUpdateOne { +func (c *AttestationCollectionClient) UpdateOneID(id uuid.UUID) *AttestationCollectionUpdateOne { mutation := newAttestationCollectionMutation(c.config, OpUpdateOne, withAttestationCollectionID(id)) return &AttestationCollectionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -510,7 +509,7 @@ func (c *AttestationCollectionClient) DeleteOne(ac *AttestationCollection) *Atte } // DeleteOneID returns a builder for deleting the given entity by its id. -func (c *AttestationCollectionClient) DeleteOneID(id int) *AttestationCollectionDeleteOne { +func (c *AttestationCollectionClient) DeleteOneID(id uuid.UUID) *AttestationCollectionDeleteOne { builder := c.Delete().Where(attestationcollection.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne @@ -527,12 +526,12 @@ func (c *AttestationCollectionClient) Query() *AttestationCollectionQuery { } // Get returns a AttestationCollection entity by its id. -func (c *AttestationCollectionClient) Get(ctx context.Context, id int) (*AttestationCollection, error) { +func (c *AttestationCollectionClient) Get(ctx context.Context, id uuid.UUID) (*AttestationCollection, error) { return c.Query().Where(attestationcollection.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. -func (c *AttestationCollectionClient) GetX(ctx context.Context, id int) *AttestationCollection { +func (c *AttestationCollectionClient) GetX(ctx context.Context, id uuid.UUID) *AttestationCollection { obj, err := c.Get(ctx, id) if err != nil { panic(err) @@ -658,7 +657,7 @@ func (c *AttestationPolicyClient) UpdateOne(ap *AttestationPolicy) *AttestationP } // UpdateOneID returns an update builder for the given id. -func (c *AttestationPolicyClient) UpdateOneID(id int) *AttestationPolicyUpdateOne { +func (c *AttestationPolicyClient) UpdateOneID(id uuid.UUID) *AttestationPolicyUpdateOne { mutation := newAttestationPolicyMutation(c.config, OpUpdateOne, withAttestationPolicyID(id)) return &AttestationPolicyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -675,7 +674,7 @@ func (c *AttestationPolicyClient) DeleteOne(ap *AttestationPolicy) *AttestationP } // DeleteOneID returns a builder for deleting the given entity by its id. -func (c *AttestationPolicyClient) DeleteOneID(id int) *AttestationPolicyDeleteOne { +func (c *AttestationPolicyClient) DeleteOneID(id uuid.UUID) *AttestationPolicyDeleteOne { builder := c.Delete().Where(attestationpolicy.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne @@ -692,12 +691,12 @@ func (c *AttestationPolicyClient) Query() *AttestationPolicyQuery { } // Get returns a AttestationPolicy entity by its id. -func (c *AttestationPolicyClient) Get(ctx context.Context, id int) (*AttestationPolicy, error) { +func (c *AttestationPolicyClient) Get(ctx context.Context, id uuid.UUID) (*AttestationPolicy, error) { return c.Query().Where(attestationpolicy.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. -func (c *AttestationPolicyClient) GetX(ctx context.Context, id int) *AttestationPolicy { +func (c *AttestationPolicyClient) GetX(ctx context.Context, id uuid.UUID) *AttestationPolicy { obj, err := c.Get(ctx, id) if err != nil { panic(err) @@ -807,7 +806,7 @@ func (c *DsseClient) UpdateOne(d *Dsse) *DsseUpdateOne { } // UpdateOneID returns an update builder for the given id. -func (c *DsseClient) UpdateOneID(id int) *DsseUpdateOne { +func (c *DsseClient) UpdateOneID(id uuid.UUID) *DsseUpdateOne { mutation := newDsseMutation(c.config, OpUpdateOne, withDsseID(id)) return &DsseUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -824,7 +823,7 @@ func (c *DsseClient) DeleteOne(d *Dsse) *DsseDeleteOne { } // DeleteOneID returns a builder for deleting the given entity by its id. -func (c *DsseClient) DeleteOneID(id int) *DsseDeleteOne { +func (c *DsseClient) DeleteOneID(id uuid.UUID) *DsseDeleteOne { builder := c.Delete().Where(dsse.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne @@ -841,12 +840,12 @@ func (c *DsseClient) Query() *DsseQuery { } // Get returns a Dsse entity by its id. -func (c *DsseClient) Get(ctx context.Context, id int) (*Dsse, error) { +func (c *DsseClient) Get(ctx context.Context, id uuid.UUID) (*Dsse, error) { return c.Query().Where(dsse.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. -func (c *DsseClient) GetX(ctx context.Context, id int) *Dsse { +func (c *DsseClient) GetX(ctx context.Context, id uuid.UUID) *Dsse { obj, err := c.Get(ctx, id) if err != nil { panic(err) @@ -988,7 +987,7 @@ func (c *PayloadDigestClient) UpdateOne(pd *PayloadDigest) *PayloadDigestUpdateO } // UpdateOneID returns an update builder for the given id. -func (c *PayloadDigestClient) UpdateOneID(id int) *PayloadDigestUpdateOne { +func (c *PayloadDigestClient) UpdateOneID(id uuid.UUID) *PayloadDigestUpdateOne { mutation := newPayloadDigestMutation(c.config, OpUpdateOne, withPayloadDigestID(id)) return &PayloadDigestUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -1005,7 +1004,7 @@ func (c *PayloadDigestClient) DeleteOne(pd *PayloadDigest) *PayloadDigestDeleteO } // DeleteOneID returns a builder for deleting the given entity by its id. -func (c *PayloadDigestClient) DeleteOneID(id int) *PayloadDigestDeleteOne { +func (c *PayloadDigestClient) DeleteOneID(id uuid.UUID) *PayloadDigestDeleteOne { builder := c.Delete().Where(payloaddigest.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne @@ -1022,12 +1021,12 @@ func (c *PayloadDigestClient) Query() *PayloadDigestQuery { } // Get returns a PayloadDigest entity by its id. -func (c *PayloadDigestClient) Get(ctx context.Context, id int) (*PayloadDigest, error) { +func (c *PayloadDigestClient) Get(ctx context.Context, id uuid.UUID) (*PayloadDigest, error) { return c.Query().Where(payloaddigest.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. -func (c *PayloadDigestClient) GetX(ctx context.Context, id int) *PayloadDigest { +func (c *PayloadDigestClient) GetX(ctx context.Context, id uuid.UUID) *PayloadDigest { obj, err := c.Get(ctx, id) if err != nil { panic(err) @@ -1137,7 +1136,7 @@ func (c *SignatureClient) UpdateOne(s *Signature) *SignatureUpdateOne { } // UpdateOneID returns an update builder for the given id. -func (c *SignatureClient) UpdateOneID(id int) *SignatureUpdateOne { +func (c *SignatureClient) UpdateOneID(id uuid.UUID) *SignatureUpdateOne { mutation := newSignatureMutation(c.config, OpUpdateOne, withSignatureID(id)) return &SignatureUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -1154,7 +1153,7 @@ func (c *SignatureClient) DeleteOne(s *Signature) *SignatureDeleteOne { } // DeleteOneID returns a builder for deleting the given entity by its id. -func (c *SignatureClient) DeleteOneID(id int) *SignatureDeleteOne { +func (c *SignatureClient) DeleteOneID(id uuid.UUID) *SignatureDeleteOne { builder := c.Delete().Where(signature.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne @@ -1171,12 +1170,12 @@ func (c *SignatureClient) Query() *SignatureQuery { } // Get returns a Signature entity by its id. -func (c *SignatureClient) Get(ctx context.Context, id int) (*Signature, error) { +func (c *SignatureClient) Get(ctx context.Context, id uuid.UUID) (*Signature, error) { return c.Query().Where(signature.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. -func (c *SignatureClient) GetX(ctx context.Context, id int) *Signature { +func (c *SignatureClient) GetX(ctx context.Context, id uuid.UUID) *Signature { obj, err := c.Get(ctx, id) if err != nil { panic(err) @@ -1302,7 +1301,7 @@ func (c *StatementClient) UpdateOne(s *Statement) *StatementUpdateOne { } // UpdateOneID returns an update builder for the given id. -func (c *StatementClient) UpdateOneID(id int) *StatementUpdateOne { +func (c *StatementClient) UpdateOneID(id uuid.UUID) *StatementUpdateOne { mutation := newStatementMutation(c.config, OpUpdateOne, withStatementID(id)) return &StatementUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -1319,7 +1318,7 @@ func (c *StatementClient) DeleteOne(s *Statement) *StatementDeleteOne { } // DeleteOneID returns a builder for deleting the given entity by its id. -func (c *StatementClient) DeleteOneID(id int) *StatementDeleteOne { +func (c *StatementClient) DeleteOneID(id uuid.UUID) *StatementDeleteOne { builder := c.Delete().Where(statement.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne @@ -1336,12 +1335,12 @@ func (c *StatementClient) Query() *StatementQuery { } // Get returns a Statement entity by its id. -func (c *StatementClient) Get(ctx context.Context, id int) (*Statement, error) { +func (c *StatementClient) Get(ctx context.Context, id uuid.UUID) (*Statement, error) { return c.Query().Where(statement.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. -func (c *StatementClient) GetX(ctx context.Context, id int) *Statement { +func (c *StatementClient) GetX(ctx context.Context, id uuid.UUID) *Statement { obj, err := c.Get(ctx, id) if err != nil { panic(err) @@ -1499,7 +1498,7 @@ func (c *SubjectClient) UpdateOne(s *Subject) *SubjectUpdateOne { } // UpdateOneID returns an update builder for the given id. -func (c *SubjectClient) UpdateOneID(id int) *SubjectUpdateOne { +func (c *SubjectClient) UpdateOneID(id uuid.UUID) *SubjectUpdateOne { mutation := newSubjectMutation(c.config, OpUpdateOne, withSubjectID(id)) return &SubjectUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -1516,7 +1515,7 @@ func (c *SubjectClient) DeleteOne(s *Subject) *SubjectDeleteOne { } // DeleteOneID returns a builder for deleting the given entity by its id. -func (c *SubjectClient) DeleteOneID(id int) *SubjectDeleteOne { +func (c *SubjectClient) DeleteOneID(id uuid.UUID) *SubjectDeleteOne { builder := c.Delete().Where(subject.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne @@ -1533,12 +1532,12 @@ func (c *SubjectClient) Query() *SubjectQuery { } // Get returns a Subject entity by its id. -func (c *SubjectClient) Get(ctx context.Context, id int) (*Subject, error) { +func (c *SubjectClient) Get(ctx context.Context, id uuid.UUID) (*Subject, error) { return c.Query().Where(subject.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. -func (c *SubjectClient) GetX(ctx context.Context, id int) *Subject { +func (c *SubjectClient) GetX(ctx context.Context, id uuid.UUID) *Subject { obj, err := c.Get(ctx, id) if err != nil { panic(err) @@ -1664,7 +1663,7 @@ func (c *SubjectDigestClient) UpdateOne(sd *SubjectDigest) *SubjectDigestUpdateO } // UpdateOneID returns an update builder for the given id. -func (c *SubjectDigestClient) UpdateOneID(id int) *SubjectDigestUpdateOne { +func (c *SubjectDigestClient) UpdateOneID(id uuid.UUID) *SubjectDigestUpdateOne { mutation := newSubjectDigestMutation(c.config, OpUpdateOne, withSubjectDigestID(id)) return &SubjectDigestUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -1681,7 +1680,7 @@ func (c *SubjectDigestClient) DeleteOne(sd *SubjectDigest) *SubjectDigestDeleteO } // DeleteOneID returns a builder for deleting the given entity by its id. -func (c *SubjectDigestClient) DeleteOneID(id int) *SubjectDigestDeleteOne { +func (c *SubjectDigestClient) DeleteOneID(id uuid.UUID) *SubjectDigestDeleteOne { builder := c.Delete().Where(subjectdigest.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne @@ -1698,12 +1697,12 @@ func (c *SubjectDigestClient) Query() *SubjectDigestQuery { } // Get returns a SubjectDigest entity by its id. -func (c *SubjectDigestClient) Get(ctx context.Context, id int) (*SubjectDigest, error) { +func (c *SubjectDigestClient) Get(ctx context.Context, id uuid.UUID) (*SubjectDigest, error) { return c.Query().Where(subjectdigest.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. -func (c *SubjectDigestClient) GetX(ctx context.Context, id int) *SubjectDigest { +func (c *SubjectDigestClient) GetX(ctx context.Context, id uuid.UUID) *SubjectDigest { obj, err := c.Get(ctx, id) if err != nil { panic(err) @@ -1813,7 +1812,7 @@ func (c *TimestampClient) UpdateOne(t *Timestamp) *TimestampUpdateOne { } // UpdateOneID returns an update builder for the given id. -func (c *TimestampClient) UpdateOneID(id int) *TimestampUpdateOne { +func (c *TimestampClient) UpdateOneID(id uuid.UUID) *TimestampUpdateOne { mutation := newTimestampMutation(c.config, OpUpdateOne, withTimestampID(id)) return &TimestampUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -1830,7 +1829,7 @@ func (c *TimestampClient) DeleteOne(t *Timestamp) *TimestampDeleteOne { } // DeleteOneID returns a builder for deleting the given entity by its id. -func (c *TimestampClient) DeleteOneID(id int) *TimestampDeleteOne { +func (c *TimestampClient) DeleteOneID(id uuid.UUID) *TimestampDeleteOne { builder := c.Delete().Where(timestamp.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne @@ -1847,12 +1846,12 @@ func (c *TimestampClient) Query() *TimestampQuery { } // Get returns a Timestamp entity by its id. -func (c *TimestampClient) Get(ctx context.Context, id int) (*Timestamp, error) { +func (c *TimestampClient) Get(ctx context.Context, id uuid.UUID) (*Timestamp, error) { return c.Query().Where(timestamp.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. -func (c *TimestampClient) GetX(ctx context.Context, id int) *Timestamp { +func (c *TimestampClient) GetX(ctx context.Context, id uuid.UUID) *Timestamp { obj, err := c.Get(ctx, id) if err != nil { panic(err) diff --git a/ent/dsse.go b/ent/dsse.go index 402e71fe..12b143a4 100644 --- a/ent/dsse.go +++ b/ent/dsse.go @@ -8,6 +8,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/dsse" "github.com/in-toto/archivista/ent/statement" ) @@ -16,7 +17,7 @@ import ( type Dsse struct { config `json:"-"` // ID of the ent. - ID int `json:"id,omitempty"` + ID uuid.UUID `json:"id,omitempty"` // GitoidSha256 holds the value of the "gitoid_sha256" field. GitoidSha256 string `json:"gitoid_sha256,omitempty"` // PayloadType holds the value of the "payload_type" field. @@ -24,7 +25,7 @@ type Dsse struct { // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the DsseQuery when eager-loading is set. Edges DsseEdges `json:"edges"` - dsse_statement *int + dsse_statement *uuid.UUID selectValues sql.SelectValues } @@ -80,12 +81,12 @@ func (*Dsse) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case dsse.FieldID: - values[i] = new(sql.NullInt64) case dsse.FieldGitoidSha256, dsse.FieldPayloadType: values[i] = new(sql.NullString) + case dsse.FieldID: + values[i] = new(uuid.UUID) case dsse.ForeignKeys[0]: // dsse_statement - values[i] = new(sql.NullInt64) + values[i] = &sql.NullScanner{S: new(uuid.UUID)} default: values[i] = new(sql.UnknownType) } @@ -102,11 +103,11 @@ func (d *Dsse) assignValues(columns []string, values []any) error { for i := range columns { switch columns[i] { case dsse.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + d.ID = *value } - d.ID = int(value.Int64) case dsse.FieldGitoidSha256: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field gitoid_sha256", values[i]) @@ -120,11 +121,11 @@ func (d *Dsse) assignValues(columns []string, values []any) error { d.PayloadType = value.String } case dsse.ForeignKeys[0]: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field dsse_statement", value) + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field dsse_statement", values[i]) } else if value.Valid { - d.dsse_statement = new(int) - *d.dsse_statement = int(value.Int64) + d.dsse_statement = new(uuid.UUID) + *d.dsse_statement = *value.S.(*uuid.UUID) } default: d.selectValues.Set(columns[i], values[i]) diff --git a/ent/dsse/dsse.go b/ent/dsse/dsse.go index 41c063ce..2e705f92 100644 --- a/ent/dsse/dsse.go +++ b/ent/dsse/dsse.go @@ -5,6 +5,7 @@ package dsse import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" ) const ( @@ -80,6 +81,8 @@ var ( GitoidSha256Validator func(string) error // PayloadTypeValidator is a validator for the "payload_type" field. It is called by the builders before save. PayloadTypeValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID ) // OrderOption defines the ordering options for the Dsse queries. diff --git a/ent/dsse/where.go b/ent/dsse/where.go index 20f207ab..ec38598f 100644 --- a/ent/dsse/where.go +++ b/ent/dsse/where.go @@ -5,51 +5,52 @@ package dsse import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/predicate" ) // ID filters vertices based on their ID field. -func ID(id int) predicate.Dsse { +func ID(id uuid.UUID) predicate.Dsse { return predicate.Dsse(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.Dsse { +func IDEQ(id uuid.UUID) predicate.Dsse { return predicate.Dsse(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.Dsse { +func IDNEQ(id uuid.UUID) predicate.Dsse { return predicate.Dsse(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.Dsse { +func IDIn(ids ...uuid.UUID) predicate.Dsse { return predicate.Dsse(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.Dsse { +func IDNotIn(ids ...uuid.UUID) predicate.Dsse { return predicate.Dsse(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.Dsse { +func IDGT(id uuid.UUID) predicate.Dsse { return predicate.Dsse(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.Dsse { +func IDGTE(id uuid.UUID) predicate.Dsse { return predicate.Dsse(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.Dsse { +func IDLT(id uuid.UUID) predicate.Dsse { return predicate.Dsse(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.Dsse { +func IDLTE(id uuid.UUID) predicate.Dsse { return predicate.Dsse(sql.FieldLTE(FieldID, id)) } diff --git a/ent/dsse_create.go b/ent/dsse_create.go index dbd38fe3..dd642ca7 100644 --- a/ent/dsse_create.go +++ b/ent/dsse_create.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/dsse" "github.com/in-toto/archivista/ent/payloaddigest" "github.com/in-toto/archivista/ent/signature" @@ -34,14 +35,28 @@ func (dc *DsseCreate) SetPayloadType(s string) *DsseCreate { return dc } +// SetID sets the "id" field. +func (dc *DsseCreate) SetID(u uuid.UUID) *DsseCreate { + dc.mutation.SetID(u) + return dc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (dc *DsseCreate) SetNillableID(u *uuid.UUID) *DsseCreate { + if u != nil { + dc.SetID(*u) + } + return dc +} + // SetStatementID sets the "statement" edge to the Statement entity by ID. -func (dc *DsseCreate) SetStatementID(id int) *DsseCreate { +func (dc *DsseCreate) SetStatementID(id uuid.UUID) *DsseCreate { dc.mutation.SetStatementID(id) return dc } // SetNillableStatementID sets the "statement" edge to the Statement entity by ID if the given value is not nil. -func (dc *DsseCreate) SetNillableStatementID(id *int) *DsseCreate { +func (dc *DsseCreate) SetNillableStatementID(id *uuid.UUID) *DsseCreate { if id != nil { dc = dc.SetStatementID(*id) } @@ -54,14 +69,14 @@ func (dc *DsseCreate) SetStatement(s *Statement) *DsseCreate { } // AddSignatureIDs adds the "signatures" edge to the Signature entity by IDs. -func (dc *DsseCreate) AddSignatureIDs(ids ...int) *DsseCreate { +func (dc *DsseCreate) AddSignatureIDs(ids ...uuid.UUID) *DsseCreate { dc.mutation.AddSignatureIDs(ids...) return dc } // AddSignatures adds the "signatures" edges to the Signature entity. func (dc *DsseCreate) AddSignatures(s ...*Signature) *DsseCreate { - ids := make([]int, len(s)) + ids := make([]uuid.UUID, len(s)) for i := range s { ids[i] = s[i].ID } @@ -69,14 +84,14 @@ func (dc *DsseCreate) AddSignatures(s ...*Signature) *DsseCreate { } // AddPayloadDigestIDs adds the "payload_digests" edge to the PayloadDigest entity by IDs. -func (dc *DsseCreate) AddPayloadDigestIDs(ids ...int) *DsseCreate { +func (dc *DsseCreate) AddPayloadDigestIDs(ids ...uuid.UUID) *DsseCreate { dc.mutation.AddPayloadDigestIDs(ids...) return dc } // AddPayloadDigests adds the "payload_digests" edges to the PayloadDigest entity. func (dc *DsseCreate) AddPayloadDigests(p ...*PayloadDigest) *DsseCreate { - ids := make([]int, len(p)) + ids := make([]uuid.UUID, len(p)) for i := range p { ids[i] = p[i].ID } @@ -90,6 +105,7 @@ func (dc *DsseCreate) Mutation() *DsseMutation { // Save creates the Dsse in the database. func (dc *DsseCreate) Save(ctx context.Context) (*Dsse, error) { + dc.defaults() return withHooks(ctx, dc.sqlSave, dc.mutation, dc.hooks) } @@ -115,6 +131,14 @@ func (dc *DsseCreate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (dc *DsseCreate) defaults() { + if _, ok := dc.mutation.ID(); !ok { + v := dsse.DefaultID() + dc.mutation.SetID(v) + } +} + // check runs all checks and user-defined validators on the builder. func (dc *DsseCreate) check() error { if _, ok := dc.mutation.GitoidSha256(); !ok { @@ -147,8 +171,13 @@ func (dc *DsseCreate) sqlSave(ctx context.Context) (*Dsse, error) { } return nil, err } - id := _spec.ID.Value.(int64) - _node.ID = int(id) + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } dc.mutation.id = &_node.ID dc.mutation.done = true return _node, nil @@ -157,8 +186,12 @@ func (dc *DsseCreate) sqlSave(ctx context.Context) (*Dsse, error) { func (dc *DsseCreate) createSpec() (*Dsse, *sqlgraph.CreateSpec) { var ( _node = &Dsse{config: dc.config} - _spec = sqlgraph.NewCreateSpec(dsse.Table, sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt)) + _spec = sqlgraph.NewCreateSpec(dsse.Table, sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID)) ) + if id, ok := dc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } if value, ok := dc.mutation.GitoidSha256(); ok { _spec.SetField(dsse.FieldGitoidSha256, field.TypeString, value) _node.GitoidSha256 = value @@ -175,7 +208,7 @@ func (dc *DsseCreate) createSpec() (*Dsse, *sqlgraph.CreateSpec) { Columns: []string{dsse.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -192,7 +225,7 @@ func (dc *DsseCreate) createSpec() (*Dsse, *sqlgraph.CreateSpec) { Columns: []string{dsse.SignaturesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -208,7 +241,7 @@ func (dc *DsseCreate) createSpec() (*Dsse, *sqlgraph.CreateSpec) { Columns: []string{dsse.PayloadDigestsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -237,6 +270,7 @@ func (dcb *DsseCreateBulk) Save(ctx context.Context) ([]*Dsse, error) { for i := range dcb.builders { func(i int, root context.Context) { builder := dcb.builders[i] + builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*DsseMutation) if !ok { @@ -263,10 +297,6 @@ func (dcb *DsseCreateBulk) Save(ctx context.Context) ([]*Dsse, error) { return nil, err } mutation.id = &nodes[i].ID - if specs[i].ID.Value != nil { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int(id) - } mutation.done = true return nodes[i], nil }) diff --git a/ent/dsse_delete.go b/ent/dsse_delete.go index d1d38030..59bbe0c8 100644 --- a/ent/dsse_delete.go +++ b/ent/dsse_delete.go @@ -40,7 +40,7 @@ func (dd *DsseDelete) ExecX(ctx context.Context) int { } func (dd *DsseDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(dsse.Table, sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt)) + _spec := sqlgraph.NewDeleteSpec(dsse.Table, sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID)) if ps := dd.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { diff --git a/ent/dsse_query.go b/ent/dsse_query.go index c639b715..cc0fd93c 100644 --- a/ent/dsse_query.go +++ b/ent/dsse_query.go @@ -11,6 +11,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/dsse" "github.com/in-toto/archivista/ent/payloaddigest" "github.com/in-toto/archivista/ent/predicate" @@ -159,8 +160,8 @@ func (dq *DsseQuery) FirstX(ctx context.Context) *Dsse { // FirstID returns the first Dsse ID from the query. // Returns a *NotFoundError when no Dsse ID was found. -func (dq *DsseQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -172,7 +173,7 @@ func (dq *DsseQuery) FirstID(ctx context.Context) (id int, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (dq *DsseQuery) FirstIDX(ctx context.Context) int { +func (dq *DsseQuery) FirstIDX(ctx context.Context) uuid.UUID { id, err := dq.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) @@ -210,8 +211,8 @@ func (dq *DsseQuery) OnlyX(ctx context.Context) *Dsse { // OnlyID is like Only, but returns the only Dsse ID in the query. // Returns a *NotSingularError when more than one Dsse ID is found. // Returns a *NotFoundError when no entities are found. -func (dq *DsseQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -227,7 +228,7 @@ func (dq *DsseQuery) OnlyID(ctx context.Context) (id int, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (dq *DsseQuery) OnlyIDX(ctx context.Context) int { +func (dq *DsseQuery) OnlyIDX(ctx context.Context) uuid.UUID { id, err := dq.OnlyID(ctx) if err != nil { panic(err) @@ -255,7 +256,7 @@ func (dq *DsseQuery) AllX(ctx context.Context) []*Dsse { } // IDs executes the query and returns a list of Dsse IDs. -func (dq *DsseQuery) IDs(ctx context.Context) (ids []int, err error) { +func (dq *DsseQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if dq.ctx.Unique == nil && dq.path != nil { dq.Unique(true) } @@ -267,7 +268,7 @@ func (dq *DsseQuery) IDs(ctx context.Context) (ids []int, err error) { } // IDsX is like IDs, but panics if an error occurs. -func (dq *DsseQuery) IDsX(ctx context.Context) []int { +func (dq *DsseQuery) IDsX(ctx context.Context) []uuid.UUID { ids, err := dq.IDs(ctx) if err != nil { panic(err) @@ -524,8 +525,8 @@ func (dq *DsseQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Dsse, e } func (dq *DsseQuery) loadStatement(ctx context.Context, query *StatementQuery, nodes []*Dsse, init func(*Dsse), assign func(*Dsse, *Statement)) error { - ids := make([]int, 0, len(nodes)) - nodeids := make(map[int][]*Dsse) + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*Dsse) for i := range nodes { if nodes[i].dsse_statement == nil { continue @@ -557,7 +558,7 @@ func (dq *DsseQuery) loadStatement(ctx context.Context, query *StatementQuery, n } func (dq *DsseQuery) loadSignatures(ctx context.Context, query *SignatureQuery, nodes []*Dsse, init func(*Dsse), assign func(*Dsse, *Signature)) error { fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int]*Dsse) + nodeids := make(map[uuid.UUID]*Dsse) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] @@ -588,7 +589,7 @@ func (dq *DsseQuery) loadSignatures(ctx context.Context, query *SignatureQuery, } func (dq *DsseQuery) loadPayloadDigests(ctx context.Context, query *PayloadDigestQuery, nodes []*Dsse, init func(*Dsse), assign func(*Dsse, *PayloadDigest)) error { fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int]*Dsse) + nodeids := make(map[uuid.UUID]*Dsse) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] @@ -631,7 +632,7 @@ func (dq *DsseQuery) sqlCount(ctx context.Context) (int, error) { } func (dq *DsseQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(dsse.Table, dsse.Columns, sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt)) + _spec := sqlgraph.NewQuerySpec(dsse.Table, dsse.Columns, sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID)) _spec.From = dq.sql if unique := dq.ctx.Unique; unique != nil { _spec.Unique = *unique diff --git a/ent/dsse_update.go b/ent/dsse_update.go index e025033f..ee61d6df 100644 --- a/ent/dsse_update.go +++ b/ent/dsse_update.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/dsse" "github.com/in-toto/archivista/ent/payloaddigest" "github.com/in-toto/archivista/ent/predicate" @@ -59,13 +60,13 @@ func (du *DsseUpdate) SetNillablePayloadType(s *string) *DsseUpdate { } // SetStatementID sets the "statement" edge to the Statement entity by ID. -func (du *DsseUpdate) SetStatementID(id int) *DsseUpdate { +func (du *DsseUpdate) SetStatementID(id uuid.UUID) *DsseUpdate { du.mutation.SetStatementID(id) return du } // SetNillableStatementID sets the "statement" edge to the Statement entity by ID if the given value is not nil. -func (du *DsseUpdate) SetNillableStatementID(id *int) *DsseUpdate { +func (du *DsseUpdate) SetNillableStatementID(id *uuid.UUID) *DsseUpdate { if id != nil { du = du.SetStatementID(*id) } @@ -78,14 +79,14 @@ func (du *DsseUpdate) SetStatement(s *Statement) *DsseUpdate { } // AddSignatureIDs adds the "signatures" edge to the Signature entity by IDs. -func (du *DsseUpdate) AddSignatureIDs(ids ...int) *DsseUpdate { +func (du *DsseUpdate) AddSignatureIDs(ids ...uuid.UUID) *DsseUpdate { du.mutation.AddSignatureIDs(ids...) return du } // AddSignatures adds the "signatures" edges to the Signature entity. func (du *DsseUpdate) AddSignatures(s ...*Signature) *DsseUpdate { - ids := make([]int, len(s)) + ids := make([]uuid.UUID, len(s)) for i := range s { ids[i] = s[i].ID } @@ -93,14 +94,14 @@ func (du *DsseUpdate) AddSignatures(s ...*Signature) *DsseUpdate { } // AddPayloadDigestIDs adds the "payload_digests" edge to the PayloadDigest entity by IDs. -func (du *DsseUpdate) AddPayloadDigestIDs(ids ...int) *DsseUpdate { +func (du *DsseUpdate) AddPayloadDigestIDs(ids ...uuid.UUID) *DsseUpdate { du.mutation.AddPayloadDigestIDs(ids...) return du } // AddPayloadDigests adds the "payload_digests" edges to the PayloadDigest entity. func (du *DsseUpdate) AddPayloadDigests(p ...*PayloadDigest) *DsseUpdate { - ids := make([]int, len(p)) + ids := make([]uuid.UUID, len(p)) for i := range p { ids[i] = p[i].ID } @@ -125,14 +126,14 @@ func (du *DsseUpdate) ClearSignatures() *DsseUpdate { } // RemoveSignatureIDs removes the "signatures" edge to Signature entities by IDs. -func (du *DsseUpdate) RemoveSignatureIDs(ids ...int) *DsseUpdate { +func (du *DsseUpdate) RemoveSignatureIDs(ids ...uuid.UUID) *DsseUpdate { du.mutation.RemoveSignatureIDs(ids...) return du } // RemoveSignatures removes "signatures" edges to Signature entities. func (du *DsseUpdate) RemoveSignatures(s ...*Signature) *DsseUpdate { - ids := make([]int, len(s)) + ids := make([]uuid.UUID, len(s)) for i := range s { ids[i] = s[i].ID } @@ -146,14 +147,14 @@ func (du *DsseUpdate) ClearPayloadDigests() *DsseUpdate { } // RemovePayloadDigestIDs removes the "payload_digests" edge to PayloadDigest entities by IDs. -func (du *DsseUpdate) RemovePayloadDigestIDs(ids ...int) *DsseUpdate { +func (du *DsseUpdate) RemovePayloadDigestIDs(ids ...uuid.UUID) *DsseUpdate { du.mutation.RemovePayloadDigestIDs(ids...) return du } // RemovePayloadDigests removes "payload_digests" edges to PayloadDigest entities. func (du *DsseUpdate) RemovePayloadDigests(p ...*PayloadDigest) *DsseUpdate { - ids := make([]int, len(p)) + ids := make([]uuid.UUID, len(p)) for i := range p { ids[i] = p[i].ID } @@ -206,7 +207,7 @@ func (du *DsseUpdate) sqlSave(ctx context.Context) (n int, err error) { if err := du.check(); err != nil { return n, err } - _spec := sqlgraph.NewUpdateSpec(dsse.Table, dsse.Columns, sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(dsse.Table, dsse.Columns, sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID)) if ps := du.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -228,7 +229,7 @@ func (du *DsseUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{dsse.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -241,7 +242,7 @@ func (du *DsseUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{dsse.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -257,7 +258,7 @@ func (du *DsseUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{dsse.SignaturesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -270,7 +271,7 @@ func (du *DsseUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{dsse.SignaturesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -286,7 +287,7 @@ func (du *DsseUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{dsse.SignaturesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -302,7 +303,7 @@ func (du *DsseUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{dsse.PayloadDigestsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -315,7 +316,7 @@ func (du *DsseUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{dsse.PayloadDigestsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -331,7 +332,7 @@ func (du *DsseUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{dsse.PayloadDigestsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -388,13 +389,13 @@ func (duo *DsseUpdateOne) SetNillablePayloadType(s *string) *DsseUpdateOne { } // SetStatementID sets the "statement" edge to the Statement entity by ID. -func (duo *DsseUpdateOne) SetStatementID(id int) *DsseUpdateOne { +func (duo *DsseUpdateOne) SetStatementID(id uuid.UUID) *DsseUpdateOne { duo.mutation.SetStatementID(id) return duo } // SetNillableStatementID sets the "statement" edge to the Statement entity by ID if the given value is not nil. -func (duo *DsseUpdateOne) SetNillableStatementID(id *int) *DsseUpdateOne { +func (duo *DsseUpdateOne) SetNillableStatementID(id *uuid.UUID) *DsseUpdateOne { if id != nil { duo = duo.SetStatementID(*id) } @@ -407,14 +408,14 @@ func (duo *DsseUpdateOne) SetStatement(s *Statement) *DsseUpdateOne { } // AddSignatureIDs adds the "signatures" edge to the Signature entity by IDs. -func (duo *DsseUpdateOne) AddSignatureIDs(ids ...int) *DsseUpdateOne { +func (duo *DsseUpdateOne) AddSignatureIDs(ids ...uuid.UUID) *DsseUpdateOne { duo.mutation.AddSignatureIDs(ids...) return duo } // AddSignatures adds the "signatures" edges to the Signature entity. func (duo *DsseUpdateOne) AddSignatures(s ...*Signature) *DsseUpdateOne { - ids := make([]int, len(s)) + ids := make([]uuid.UUID, len(s)) for i := range s { ids[i] = s[i].ID } @@ -422,14 +423,14 @@ func (duo *DsseUpdateOne) AddSignatures(s ...*Signature) *DsseUpdateOne { } // AddPayloadDigestIDs adds the "payload_digests" edge to the PayloadDigest entity by IDs. -func (duo *DsseUpdateOne) AddPayloadDigestIDs(ids ...int) *DsseUpdateOne { +func (duo *DsseUpdateOne) AddPayloadDigestIDs(ids ...uuid.UUID) *DsseUpdateOne { duo.mutation.AddPayloadDigestIDs(ids...) return duo } // AddPayloadDigests adds the "payload_digests" edges to the PayloadDigest entity. func (duo *DsseUpdateOne) AddPayloadDigests(p ...*PayloadDigest) *DsseUpdateOne { - ids := make([]int, len(p)) + ids := make([]uuid.UUID, len(p)) for i := range p { ids[i] = p[i].ID } @@ -454,14 +455,14 @@ func (duo *DsseUpdateOne) ClearSignatures() *DsseUpdateOne { } // RemoveSignatureIDs removes the "signatures" edge to Signature entities by IDs. -func (duo *DsseUpdateOne) RemoveSignatureIDs(ids ...int) *DsseUpdateOne { +func (duo *DsseUpdateOne) RemoveSignatureIDs(ids ...uuid.UUID) *DsseUpdateOne { duo.mutation.RemoveSignatureIDs(ids...) return duo } // RemoveSignatures removes "signatures" edges to Signature entities. func (duo *DsseUpdateOne) RemoveSignatures(s ...*Signature) *DsseUpdateOne { - ids := make([]int, len(s)) + ids := make([]uuid.UUID, len(s)) for i := range s { ids[i] = s[i].ID } @@ -475,14 +476,14 @@ func (duo *DsseUpdateOne) ClearPayloadDigests() *DsseUpdateOne { } // RemovePayloadDigestIDs removes the "payload_digests" edge to PayloadDigest entities by IDs. -func (duo *DsseUpdateOne) RemovePayloadDigestIDs(ids ...int) *DsseUpdateOne { +func (duo *DsseUpdateOne) RemovePayloadDigestIDs(ids ...uuid.UUID) *DsseUpdateOne { duo.mutation.RemovePayloadDigestIDs(ids...) return duo } // RemovePayloadDigests removes "payload_digests" edges to PayloadDigest entities. func (duo *DsseUpdateOne) RemovePayloadDigests(p ...*PayloadDigest) *DsseUpdateOne { - ids := make([]int, len(p)) + ids := make([]uuid.UUID, len(p)) for i := range p { ids[i] = p[i].ID } @@ -548,7 +549,7 @@ func (duo *DsseUpdateOne) sqlSave(ctx context.Context) (_node *Dsse, err error) if err := duo.check(); err != nil { return _node, err } - _spec := sqlgraph.NewUpdateSpec(dsse.Table, dsse.Columns, sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(dsse.Table, dsse.Columns, sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID)) id, ok := duo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Dsse.id" for update`)} @@ -587,7 +588,7 @@ func (duo *DsseUpdateOne) sqlSave(ctx context.Context) (_node *Dsse, err error) Columns: []string{dsse.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -600,7 +601,7 @@ func (duo *DsseUpdateOne) sqlSave(ctx context.Context) (_node *Dsse, err error) Columns: []string{dsse.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -616,7 +617,7 @@ func (duo *DsseUpdateOne) sqlSave(ctx context.Context) (_node *Dsse, err error) Columns: []string{dsse.SignaturesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -629,7 +630,7 @@ func (duo *DsseUpdateOne) sqlSave(ctx context.Context) (_node *Dsse, err error) Columns: []string{dsse.SignaturesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -645,7 +646,7 @@ func (duo *DsseUpdateOne) sqlSave(ctx context.Context) (_node *Dsse, err error) Columns: []string{dsse.SignaturesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -661,7 +662,7 @@ func (duo *DsseUpdateOne) sqlSave(ctx context.Context) (_node *Dsse, err error) Columns: []string{dsse.PayloadDigestsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -674,7 +675,7 @@ func (duo *DsseUpdateOne) sqlSave(ctx context.Context) (_node *Dsse, err error) Columns: []string{dsse.PayloadDigestsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -690,7 +691,7 @@ func (duo *DsseUpdateOne) sqlSave(ctx context.Context) (_node *Dsse, err error) Columns: []string{dsse.PayloadDigestsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/ent/gql_collection.go b/ent/gql_collection.go index 282c69f5..3e298c66 100644 --- a/ent/gql_collection.go +++ b/ent/gql_collection.go @@ -7,8 +7,10 @@ import ( "database/sql/driver" "fmt" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/99designs/gqlgen/graphql" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestation" "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/attestationpolicy" @@ -27,13 +29,13 @@ func (a *AttestationQuery) CollectFields(ctx context.Context, satisfies ...strin if fc == nil { return a, nil } - if err := a.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := a.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return a, nil } -func (a *AttestationQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (a *AttestationQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -42,13 +44,14 @@ func (a *AttestationQuery) collectField(ctx context.Context, opCtx *graphql.Oper ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "attestationCollection": var ( alias = field.Alias path = append(path, alias) query = (&AttestationCollectionClient{config: a.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, attestationcollectionImplementors)...); err != nil { return err } a.withAttestationCollection = query @@ -104,13 +107,13 @@ func (ac *AttestationCollectionQuery) CollectFields(ctx context.Context, satisfi if fc == nil { return ac, nil } - if err := ac.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := ac.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return ac, nil } -func (ac *AttestationCollectionQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (ac *AttestationCollectionQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -119,25 +122,27 @@ func (ac *AttestationCollectionQuery) collectField(ctx context.Context, opCtx *g ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "attestations": var ( alias = field.Alias path = append(path, alias) query = (&AttestationClient{config: ac.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, attestationImplementors)...); err != nil { return err } ac.WithNamedAttestations(alias, func(wq *AttestationQuery) { *wq = *query }) + case "statement": var ( alias = field.Alias path = append(path, alias) query = (&StatementClient{config: ac.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, statementImplementors)...); err != nil { return err } ac.withStatement = query @@ -193,13 +198,13 @@ func (ap *AttestationPolicyQuery) CollectFields(ctx context.Context, satisfies . if fc == nil { return ap, nil } - if err := ap.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := ap.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return ap, nil } -func (ap *AttestationPolicyQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (ap *AttestationPolicyQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -208,13 +213,14 @@ func (ap *AttestationPolicyQuery) collectField(ctx context.Context, opCtx *graph ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "statement": var ( alias = field.Alias path = append(path, alias) query = (&StatementClient{config: ap.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, statementImplementors)...); err != nil { return err } ap.withStatement = query @@ -270,13 +276,13 @@ func (d *DsseQuery) CollectFields(ctx context.Context, satisfies ...string) (*Ds if fc == nil { return d, nil } - if err := d.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := d.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return d, nil } -func (d *DsseQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (d *DsseQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -285,35 +291,38 @@ func (d *DsseQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "statement": var ( alias = field.Alias path = append(path, alias) query = (&StatementClient{config: d.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, statementImplementors)...); err != nil { return err } d.withStatement = query + case "signatures": var ( alias = field.Alias path = append(path, alias) query = (&SignatureClient{config: d.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, signatureImplementors)...); err != nil { return err } d.WithNamedSignatures(alias, func(wq *SignatureQuery) { *wq = *query }) + case "payloadDigests": var ( alias = field.Alias path = append(path, alias) query = (&PayloadDigestClient{config: d.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, payloaddigestImplementors)...); err != nil { return err } d.WithNamedPayloadDigests(alias, func(wq *PayloadDigestQuery) { @@ -376,13 +385,13 @@ func (pd *PayloadDigestQuery) CollectFields(ctx context.Context, satisfies ...st if fc == nil { return pd, nil } - if err := pd.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := pd.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return pd, nil } -func (pd *PayloadDigestQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (pd *PayloadDigestQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -391,13 +400,14 @@ func (pd *PayloadDigestQuery) collectField(ctx context.Context, opCtx *graphql.O ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "dsse": var ( alias = field.Alias path = append(path, alias) query = (&DsseClient{config: pd.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, dsseImplementors)...); err != nil { return err } pd.withDsse = query @@ -458,13 +468,13 @@ func (s *SignatureQuery) CollectFields(ctx context.Context, satisfies ...string) if fc == nil { return s, nil } - if err := s.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := s.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return s, nil } -func (s *SignatureQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (s *SignatureQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -473,23 +483,25 @@ func (s *SignatureQuery) collectField(ctx context.Context, opCtx *graphql.Operat ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "dsse": var ( alias = field.Alias path = append(path, alias) query = (&DsseClient{config: s.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, dsseImplementors)...); err != nil { return err } s.withDsse = query + case "timestamps": var ( alias = field.Alias path = append(path, alias) query = (&TimestampClient{config: s.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, timestampImplementors)...); err != nil { return err } s.WithNamedTimestamps(alias, func(wq *TimestampQuery) { @@ -552,13 +564,13 @@ func (s *StatementQuery) CollectFields(ctx context.Context, satisfies ...string) if fc == nil { return s, nil } - if err := s.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := s.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return s, nil } -func (s *StatementQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (s *StatementQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -567,6 +579,7 @@ func (s *StatementQuery) collectField(ctx context.Context, opCtx *graphql.Operat ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "subjects": var ( alias = field.Alias @@ -595,8 +608,8 @@ func (s *StatementQuery) collectField(ctx context.Context, opCtx *graphql.Operat ids[i] = nodes[i].ID } var v []struct { - NodeID int `sql:"statement_subjects"` - Count int `sql:"count"` + NodeID uuid.UUID `sql:"statement_subjects"` + Count int `sql:"count"` } query.Where(func(s *sql.Selector) { s.Where(sql.InValues(s.C(statement.SubjectsColumn), ids...)) @@ -604,7 +617,7 @@ func (s *StatementQuery) collectField(ctx context.Context, opCtx *graphql.Operat if err := query.GroupBy(statement.SubjectsColumn).Aggregate(Count()).Scan(ctx, &v); err != nil { return err } - m := make(map[int]int, len(v)) + m := make(map[uuid.UUID]int, len(v)) for i := range v { m[v[i].NodeID] = v[i].Count } @@ -638,46 +651,53 @@ func (s *StatementQuery) collectField(ctx context.Context, opCtx *graphql.Operat } path = append(path, edgesField, nodeField) if field := collectedField(ctx, path...); field != nil { - if err := query.collectField(ctx, opCtx, *field, path, mayAddCondition(satisfies, "Subject")...); err != nil { + if err := query.collectField(ctx, false, opCtx, *field, path, mayAddCondition(satisfies, subjectImplementors)...); err != nil { return err } } if limit := paginateLimit(args.first, args.last); limit > 0 { - modify := limitRows(statement.SubjectsColumn, limit, pager.orderExpr(query)) - query.modifiers = append(query.modifiers, modify) + if oneNode { + pager.applyOrder(query.Limit(limit)) + } else { + modify := entgql.LimitPerRow(statement.SubjectsColumn, limit, pager.orderExpr(query)) + query.modifiers = append(query.modifiers, modify) + } } else { query = pager.applyOrder(query) } s.WithNamedSubjects(alias, func(wq *SubjectQuery) { *wq = *query }) + case "policy": var ( alias = field.Alias path = append(path, alias) query = (&AttestationPolicyClient{config: s.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, attestationpolicyImplementors)...); err != nil { return err } s.withPolicy = query + case "attestationCollections": var ( alias = field.Alias path = append(path, alias) query = (&AttestationCollectionClient{config: s.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, attestationcollectionImplementors)...); err != nil { return err } s.withAttestationCollections = query + case "dsse": var ( alias = field.Alias path = append(path, alias) query = (&DsseClient{config: s.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, dsseImplementors)...); err != nil { return err } s.WithNamedDsse(alias, func(wq *DsseQuery) { @@ -735,13 +755,13 @@ func (s *SubjectQuery) CollectFields(ctx context.Context, satisfies ...string) ( if fc == nil { return s, nil } - if err := s.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := s.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return s, nil } -func (s *SubjectQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (s *SubjectQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -750,25 +770,27 @@ func (s *SubjectQuery) collectField(ctx context.Context, opCtx *graphql.Operatio ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "subjectDigests": var ( alias = field.Alias path = append(path, alias) query = (&SubjectDigestClient{config: s.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, subjectdigestImplementors)...); err != nil { return err } s.WithNamedSubjectDigests(alias, func(wq *SubjectDigestQuery) { *wq = *query }) + case "statement": var ( alias = field.Alias path = append(path, alias) query = (&StatementClient{config: s.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, statementImplementors)...); err != nil { return err } s.withStatement = query @@ -824,13 +846,13 @@ func (sd *SubjectDigestQuery) CollectFields(ctx context.Context, satisfies ...st if fc == nil { return sd, nil } - if err := sd.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := sd.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return sd, nil } -func (sd *SubjectDigestQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (sd *SubjectDigestQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -839,13 +861,14 @@ func (sd *SubjectDigestQuery) collectField(ctx context.Context, opCtx *graphql.O ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "subject": var ( alias = field.Alias path = append(path, alias) query = (&SubjectClient{config: sd.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, subjectImplementors)...); err != nil { return err } sd.withSubject = query @@ -906,13 +929,13 @@ func (t *TimestampQuery) CollectFields(ctx context.Context, satisfies ...string) if fc == nil { return t, nil } - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := t.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return t, nil } -func (t *TimestampQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (t *TimestampQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -921,13 +944,14 @@ func (t *TimestampQuery) collectField(ctx context.Context, opCtx *graphql.Operat ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "signature": var ( alias = field.Alias path = append(path, alias) query = (&SignatureClient{config: t.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, signatureImplementors)...); err != nil { return err } t.withSignature = query @@ -1034,39 +1058,17 @@ func unmarshalArgs(ctx context.Context, whereInput any, args map[string]any) map return args } -func limitRows(partitionBy string, limit int, orderBy ...sql.Querier) func(s *sql.Selector) { - return func(s *sql.Selector) { - d := sql.Dialect(s.Dialect()) - s.SetDistinct(false) - with := d.With("src_query"). - As(s.Clone()). - With("limited_query"). - As( - d.Select("*"). - AppendSelectExprAs( - sql.RowNumber().PartitionBy(partitionBy).OrderExpr(orderBy...), - "row_number", - ). - From(d.Table("src_query")), - ) - t := d.Table("limited_query").As(s.TableName()) - *s = *d.Select(s.UnqualifiedColumns()...). - From(t). - Where(sql.LTE(t.C("row_number"), limit)). - Prefix(with) - } -} - // mayAddCondition appends another type condition to the satisfies list -// if condition is enabled (Node/Nodes) and it does not exist in the list. -func mayAddCondition(satisfies []string, typeCond string) []string { - if len(satisfies) == 0 { - return satisfies - } - for _, s := range satisfies { - if typeCond == s { - return satisfies +// if it does not exist in the list. +func mayAddCondition(satisfies []string, typeCond []string) []string { +Cond: + for _, c := range typeCond { + for _, s := range satisfies { + if c == s { + continue Cond + } } + satisfies = append(satisfies, c) } - return append(satisfies, typeCond) + return satisfies } diff --git a/ent/gql_node.go b/ent/gql_node.go index fa4943fa..3010c131 100644 --- a/ent/gql_node.go +++ b/ent/gql_node.go @@ -5,14 +5,10 @@ package ent import ( "context" "fmt" - "sync" - "sync/atomic" "entgo.io/contrib/entgql" - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/schema" "github.com/99designs/gqlgen/graphql" + "github.com/google/uuid" "github.com/hashicorp/go-multierror" "github.com/in-toto/archivista/ent/attestation" "github.com/in-toto/archivista/ent/attestationcollection" @@ -24,7 +20,6 @@ import ( "github.com/in-toto/archivista/ent/subject" "github.com/in-toto/archivista/ent/subjectdigest" "github.com/in-toto/archivista/ent/timestamp" - "golang.org/x/sync/semaphore" ) // Noder wraps the basic Node method. @@ -32,35 +27,55 @@ type Noder interface { IsNode() } +var attestationImplementors = []string{"Attestation", "Node"} + // IsNode implements the Node interface check for GQLGen. -func (n *Attestation) IsNode() {} +func (*Attestation) IsNode() {} + +var attestationcollectionImplementors = []string{"AttestationCollection", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *AttestationCollection) IsNode() {} +func (*AttestationCollection) IsNode() {} + +var attestationpolicyImplementors = []string{"AttestationPolicy", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *AttestationPolicy) IsNode() {} +func (*AttestationPolicy) IsNode() {} + +var dsseImplementors = []string{"Dsse", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Dsse) IsNode() {} +func (*Dsse) IsNode() {} + +var payloaddigestImplementors = []string{"PayloadDigest", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *PayloadDigest) IsNode() {} +func (*PayloadDigest) IsNode() {} + +var signatureImplementors = []string{"Signature", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Signature) IsNode() {} +func (*Signature) IsNode() {} + +var statementImplementors = []string{"Statement", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Statement) IsNode() {} +func (*Statement) IsNode() {} + +var subjectImplementors = []string{"Subject", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Subject) IsNode() {} +func (*Subject) IsNode() {} + +var subjectdigestImplementors = []string{"SubjectDigest", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *SubjectDigest) IsNode() {} +func (*SubjectDigest) IsNode() {} + +var timestampImplementors = []string{"Timestamp", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Timestamp) IsNode() {} +func (*Timestamp) IsNode() {} var errNodeInvalidID = &NotFoundError{"node"} @@ -70,7 +85,7 @@ type NodeOption func(*nodeOptions) // WithNodeType sets the node Type resolver function (i.e. the table to query). // If was not provided, the table will be derived from the universal-id // configuration as described in: https://entgo.io/docs/migrate/#universal-ids. -func WithNodeType(f func(context.Context, int) (string, error)) NodeOption { +func WithNodeType(f func(context.Context, uuid.UUID) (string, error)) NodeOption { return func(o *nodeOptions) { o.nodeType = f } @@ -78,13 +93,13 @@ func WithNodeType(f func(context.Context, int) (string, error)) NodeOption { // WithFixedNodeType sets the Type of the node to a fixed value. func WithFixedNodeType(t string) NodeOption { - return WithNodeType(func(context.Context, int) (string, error) { + return WithNodeType(func(context.Context, uuid.UUID) (string, error) { return t, nil }) } type nodeOptions struct { - nodeType func(context.Context, int) (string, error) + nodeType func(context.Context, uuid.UUID) (string, error) } func (c *Client) newNodeOpts(opts []NodeOption) *nodeOptions { @@ -93,8 +108,8 @@ func (c *Client) newNodeOpts(opts []NodeOption) *nodeOptions { opt(nopts) } if nopts.nodeType == nil { - nopts.nodeType = func(ctx context.Context, id int) (string, error) { - return c.tables.nodeType(ctx, c.driver, id) + nopts.nodeType = func(ctx context.Context, id uuid.UUID) (string, error) { + return "", fmt.Errorf("cannot resolve noder (%v) without its type", id) } } return nopts @@ -105,7 +120,7 @@ func (c *Client) newNodeOpts(opts []NodeOption) *nodeOptions { // // c.Noder(ctx, id) // c.Noder(ctx, id, ent.WithNodeType(typeResolver)) -func (c *Client) Noder(ctx context.Context, id int, opts ...NodeOption) (_ Noder, err error) { +func (c *Client) Noder(ctx context.Context, id uuid.UUID, opts ...NodeOption) (_ Noder, err error) { defer func() { if IsNotFound(err) { err = multierror.Append(err, entgql.ErrNodeNotFound(id)) @@ -118,134 +133,104 @@ func (c *Client) Noder(ctx context.Context, id int, opts ...NodeOption) (_ Noder return c.noder(ctx, table, id) } -func (c *Client) noder(ctx context.Context, table string, id int) (Noder, error) { +func (c *Client) noder(ctx context.Context, table string, id uuid.UUID) (Noder, error) { switch table { case attestation.Table: query := c.Attestation.Query(). Where(attestation.ID(id)) - query, err := query.CollectFields(ctx, "Attestation") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, attestationImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case attestationcollection.Table: query := c.AttestationCollection.Query(). Where(attestationcollection.ID(id)) - query, err := query.CollectFields(ctx, "AttestationCollection") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, attestationcollectionImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case attestationpolicy.Table: query := c.AttestationPolicy.Query(). Where(attestationpolicy.ID(id)) - query, err := query.CollectFields(ctx, "AttestationPolicy") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, attestationpolicyImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case dsse.Table: query := c.Dsse.Query(). Where(dsse.ID(id)) - query, err := query.CollectFields(ctx, "Dsse") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, dsseImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case payloaddigest.Table: query := c.PayloadDigest.Query(). Where(payloaddigest.ID(id)) - query, err := query.CollectFields(ctx, "PayloadDigest") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, payloaddigestImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case signature.Table: query := c.Signature.Query(). Where(signature.ID(id)) - query, err := query.CollectFields(ctx, "Signature") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, signatureImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case statement.Table: query := c.Statement.Query(). Where(statement.ID(id)) - query, err := query.CollectFields(ctx, "Statement") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, statementImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case subject.Table: query := c.Subject.Query(). Where(subject.ID(id)) - query, err := query.CollectFields(ctx, "Subject") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, subjectImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case subjectdigest.Table: query := c.SubjectDigest.Query(). Where(subjectdigest.ID(id)) - query, err := query.CollectFields(ctx, "SubjectDigest") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, subjectdigestImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case timestamp.Table: query := c.Timestamp.Query(). Where(timestamp.ID(id)) - query, err := query.CollectFields(ctx, "Timestamp") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, timestampImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) default: return nil, fmt.Errorf("cannot resolve noder from table %q: %w", table, errNodeInvalidID) } } -func (c *Client) Noders(ctx context.Context, ids []int, opts ...NodeOption) ([]Noder, error) { +func (c *Client) Noders(ctx context.Context, ids []uuid.UUID, opts ...NodeOption) ([]Noder, error) { switch len(ids) { case 1: noder, err := c.Noder(ctx, ids[0], opts...) @@ -259,8 +244,8 @@ func (c *Client) Noders(ctx context.Context, ids []int, opts ...NodeOption) ([]N noders := make([]Noder, len(ids)) errors := make([]error, len(ids)) - tables := make(map[string][]int) - id2idx := make(map[int][]int, len(ids)) + tables := make(map[string][]uuid.UUID) + id2idx := make(map[uuid.UUID][]int, len(ids)) nopts := c.newNodeOpts(opts) for i, id := range ids { table, err := nopts.nodeType(ctx, id) @@ -306,9 +291,9 @@ func (c *Client) Noders(ctx context.Context, ids []int, opts ...NodeOption) ([]N return noders, nil } -func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, error) { +func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]Noder, error) { noders := make([]Noder, len(ids)) - idmap := make(map[int][]*Noder, len(ids)) + idmap := make(map[uuid.UUID][]*Noder, len(ids)) for i, id := range ids { idmap[id] = append(idmap[id], &noders[i]) } @@ -316,7 +301,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case attestation.Table: query := c.Attestation.Query(). Where(attestation.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Attestation") + query, err := query.CollectFields(ctx, attestationImplementors...) if err != nil { return nil, err } @@ -332,7 +317,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case attestationcollection.Table: query := c.AttestationCollection.Query(). Where(attestationcollection.IDIn(ids...)) - query, err := query.CollectFields(ctx, "AttestationCollection") + query, err := query.CollectFields(ctx, attestationcollectionImplementors...) if err != nil { return nil, err } @@ -348,7 +333,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case attestationpolicy.Table: query := c.AttestationPolicy.Query(). Where(attestationpolicy.IDIn(ids...)) - query, err := query.CollectFields(ctx, "AttestationPolicy") + query, err := query.CollectFields(ctx, attestationpolicyImplementors...) if err != nil { return nil, err } @@ -364,7 +349,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case dsse.Table: query := c.Dsse.Query(). Where(dsse.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Dsse") + query, err := query.CollectFields(ctx, dsseImplementors...) if err != nil { return nil, err } @@ -380,7 +365,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case payloaddigest.Table: query := c.PayloadDigest.Query(). Where(payloaddigest.IDIn(ids...)) - query, err := query.CollectFields(ctx, "PayloadDigest") + query, err := query.CollectFields(ctx, payloaddigestImplementors...) if err != nil { return nil, err } @@ -396,7 +381,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case signature.Table: query := c.Signature.Query(). Where(signature.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Signature") + query, err := query.CollectFields(ctx, signatureImplementors...) if err != nil { return nil, err } @@ -412,7 +397,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case statement.Table: query := c.Statement.Query(). Where(statement.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Statement") + query, err := query.CollectFields(ctx, statementImplementors...) if err != nil { return nil, err } @@ -428,7 +413,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case subject.Table: query := c.Subject.Query(). Where(subject.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Subject") + query, err := query.CollectFields(ctx, subjectImplementors...) if err != nil { return nil, err } @@ -444,7 +429,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case subjectdigest.Table: query := c.SubjectDigest.Query(). Where(subjectdigest.IDIn(ids...)) - query, err := query.CollectFields(ctx, "SubjectDigest") + query, err := query.CollectFields(ctx, subjectdigestImplementors...) if err != nil { return nil, err } @@ -460,7 +445,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, case timestamp.Table: query := c.Timestamp.Query(). Where(timestamp.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Timestamp") + query, err := query.CollectFields(ctx, timestampImplementors...) if err != nil { return nil, err } @@ -478,55 +463,3 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, } return noders, nil } - -type tables struct { - once sync.Once - sem *semaphore.Weighted - value atomic.Value -} - -func (t *tables) nodeType(ctx context.Context, drv dialect.Driver, id int) (string, error) { - tables, err := t.Load(ctx, drv) - if err != nil { - return "", err - } - idx := int(id / (1<<32 - 1)) - if idx < 0 || idx >= len(tables) { - return "", fmt.Errorf("cannot resolve table from id %v: %w", id, errNodeInvalidID) - } - return tables[idx], nil -} - -func (t *tables) Load(ctx context.Context, drv dialect.Driver) ([]string, error) { - if tables := t.value.Load(); tables != nil { - return tables.([]string), nil - } - t.once.Do(func() { t.sem = semaphore.NewWeighted(1) }) - if err := t.sem.Acquire(ctx, 1); err != nil { - return nil, err - } - defer t.sem.Release(1) - if tables := t.value.Load(); tables != nil { - return tables.([]string), nil - } - tables, err := t.load(ctx, drv) - if err == nil { - t.value.Store(tables) - } - return tables, err -} - -func (*tables) load(ctx context.Context, drv dialect.Driver) ([]string, error) { - rows := &sql.Rows{} - query, args := sql.Dialect(drv.Dialect()). - Select("type"). - From(sql.Table(schema.TypeTable)). - OrderBy(sql.Asc("id")). - Query() - if err := drv.Query(ctx, query, args, rows); err != nil { - return nil, err - } - defer rows.Close() - var tables []string - return tables, sql.ScanSlice(rows, &tables) -} diff --git a/ent/gql_pagination.go b/ent/gql_pagination.go index 28104ef8..b710cac8 100644 --- a/ent/gql_pagination.go +++ b/ent/gql_pagination.go @@ -11,6 +11,7 @@ import ( "entgo.io/ent/dialect/sql" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/errcode" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestation" "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/attestationpolicy" @@ -26,8 +27,8 @@ import ( // Common entgql types. type ( - Cursor = entgql.Cursor[int] - PageInfo = entgql.PageInfo[int] + Cursor = entgql.Cursor[uuid.UUID] + PageInfo = entgql.PageInfo[uuid.UUID] OrderDirection = entgql.OrderDirection ) @@ -279,7 +280,9 @@ func (a *AttestationQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = a.Clone().Count(ctx); err != nil { + c := a.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -292,11 +295,12 @@ func (a *AttestationQuery) Paginate( if a, err = pager.applyCursors(a, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { a.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := a.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := a.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -525,7 +529,9 @@ func (ac *AttestationCollectionQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = ac.Clone().Count(ctx); err != nil { + c := ac.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -538,11 +544,12 @@ func (ac *AttestationCollectionQuery) Paginate( if ac, err = pager.applyCursors(ac, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { ac.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := ac.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := ac.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -771,7 +778,9 @@ func (ap *AttestationPolicyQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = ap.Clone().Count(ctx); err != nil { + c := ap.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -784,11 +793,12 @@ func (ap *AttestationPolicyQuery) Paginate( if ap, err = pager.applyCursors(ap, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { ap.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := ap.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := ap.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -1017,7 +1027,9 @@ func (d *DsseQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = d.Clone().Count(ctx); err != nil { + c := d.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1030,11 +1042,12 @@ func (d *DsseQuery) Paginate( if d, err = pager.applyCursors(d, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { d.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := d.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := d.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -1263,7 +1276,9 @@ func (pd *PayloadDigestQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = pd.Clone().Count(ctx); err != nil { + c := pd.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1276,11 +1291,12 @@ func (pd *PayloadDigestQuery) Paginate( if pd, err = pager.applyCursors(pd, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { pd.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := pd.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := pd.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -1509,7 +1525,9 @@ func (s *SignatureQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = s.Clone().Count(ctx); err != nil { + c := s.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1522,11 +1540,12 @@ func (s *SignatureQuery) Paginate( if s, err = pager.applyCursors(s, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { s.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := s.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := s.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -1755,7 +1774,9 @@ func (s *StatementQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = s.Clone().Count(ctx); err != nil { + c := s.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1768,11 +1789,12 @@ func (s *StatementQuery) Paginate( if s, err = pager.applyCursors(s, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { s.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := s.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := s.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -2001,7 +2023,9 @@ func (s *SubjectQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = s.Clone().Count(ctx); err != nil { + c := s.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -2014,11 +2038,12 @@ func (s *SubjectQuery) Paginate( if s, err = pager.applyCursors(s, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { s.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := s.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := s.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -2247,7 +2272,9 @@ func (sd *SubjectDigestQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = sd.Clone().Count(ctx); err != nil { + c := sd.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -2260,11 +2287,12 @@ func (sd *SubjectDigestQuery) Paginate( if sd, err = pager.applyCursors(sd, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { sd.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := sd.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := sd.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -2493,7 +2521,9 @@ func (t *TimestampQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = t.Clone().Count(ctx); err != nil { + c := t.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -2506,11 +2536,12 @@ func (t *TimestampQuery) Paginate( if t, err = pager.applyCursors(t, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { t.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := t.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := t.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } diff --git a/ent/gql_where_input.go b/ent/gql_where_input.go index 4e511031..7f1b1135 100644 --- a/ent/gql_where_input.go +++ b/ent/gql_where_input.go @@ -7,6 +7,7 @@ import ( "fmt" "time" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestation" "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/attestationpolicy" @@ -28,14 +29,14 @@ type AttestationWhereInput struct { And []*AttestationWhereInput `json:"and,omitempty"` // "id" field predicates. - ID *int `json:"id,omitempty"` - IDNEQ *int `json:"idNEQ,omitempty"` - IDIn []int `json:"idIn,omitempty"` - IDNotIn []int `json:"idNotIn,omitempty"` - IDGT *int `json:"idGT,omitempty"` - IDGTE *int `json:"idGTE,omitempty"` - IDLT *int `json:"idLT,omitempty"` - IDLTE *int `json:"idLTE,omitempty"` + ID *uuid.UUID `json:"id,omitempty"` + IDNEQ *uuid.UUID `json:"idNEQ,omitempty"` + IDIn []uuid.UUID `json:"idIn,omitempty"` + IDNotIn []uuid.UUID `json:"idNotIn,omitempty"` + IDGT *uuid.UUID `json:"idGT,omitempty"` + IDGTE *uuid.UUID `json:"idGTE,omitempty"` + IDLT *uuid.UUID `json:"idLT,omitempty"` + IDLTE *uuid.UUID `json:"idLTE,omitempty"` // "type" field predicates. Type *string `json:"type,omitempty"` @@ -228,14 +229,14 @@ type AttestationCollectionWhereInput struct { And []*AttestationCollectionWhereInput `json:"and,omitempty"` // "id" field predicates. - ID *int `json:"id,omitempty"` - IDNEQ *int `json:"idNEQ,omitempty"` - IDIn []int `json:"idIn,omitempty"` - IDNotIn []int `json:"idNotIn,omitempty"` - IDGT *int `json:"idGT,omitempty"` - IDGTE *int `json:"idGTE,omitempty"` - IDLT *int `json:"idLT,omitempty"` - IDLTE *int `json:"idLTE,omitempty"` + ID *uuid.UUID `json:"id,omitempty"` + IDNEQ *uuid.UUID `json:"idNEQ,omitempty"` + IDIn []uuid.UUID `json:"idIn,omitempty"` + IDNotIn []uuid.UUID `json:"idNotIn,omitempty"` + IDGT *uuid.UUID `json:"idGT,omitempty"` + IDGTE *uuid.UUID `json:"idGTE,omitempty"` + IDLT *uuid.UUID `json:"idLT,omitempty"` + IDLTE *uuid.UUID `json:"idLTE,omitempty"` // "name" field predicates. Name *string `json:"name,omitempty"` @@ -450,14 +451,14 @@ type AttestationPolicyWhereInput struct { And []*AttestationPolicyWhereInput `json:"and,omitempty"` // "id" field predicates. - ID *int `json:"id,omitempty"` - IDNEQ *int `json:"idNEQ,omitempty"` - IDIn []int `json:"idIn,omitempty"` - IDNotIn []int `json:"idNotIn,omitempty"` - IDGT *int `json:"idGT,omitempty"` - IDGTE *int `json:"idGTE,omitempty"` - IDLT *int `json:"idLT,omitempty"` - IDLTE *int `json:"idLTE,omitempty"` + ID *uuid.UUID `json:"id,omitempty"` + IDNEQ *uuid.UUID `json:"idNEQ,omitempty"` + IDIn []uuid.UUID `json:"idIn,omitempty"` + IDNotIn []uuid.UUID `json:"idNotIn,omitempty"` + IDGT *uuid.UUID `json:"idGT,omitempty"` + IDGTE *uuid.UUID `json:"idGTE,omitempty"` + IDLT *uuid.UUID `json:"idLT,omitempty"` + IDLTE *uuid.UUID `json:"idLTE,omitempty"` // "name" field predicates. Name *string `json:"name,omitempty"` @@ -650,14 +651,14 @@ type DsseWhereInput struct { And []*DsseWhereInput `json:"and,omitempty"` // "id" field predicates. - ID *int `json:"id,omitempty"` - IDNEQ *int `json:"idNEQ,omitempty"` - IDIn []int `json:"idIn,omitempty"` - IDNotIn []int `json:"idNotIn,omitempty"` - IDGT *int `json:"idGT,omitempty"` - IDGTE *int `json:"idGTE,omitempty"` - IDLT *int `json:"idLT,omitempty"` - IDLTE *int `json:"idLTE,omitempty"` + ID *uuid.UUID `json:"id,omitempty"` + IDNEQ *uuid.UUID `json:"idNEQ,omitempty"` + IDIn []uuid.UUID `json:"idIn,omitempty"` + IDNotIn []uuid.UUID `json:"idNotIn,omitempty"` + IDGT *uuid.UUID `json:"idGT,omitempty"` + IDGTE *uuid.UUID `json:"idGTE,omitempty"` + IDLT *uuid.UUID `json:"idLT,omitempty"` + IDLTE *uuid.UUID `json:"idLTE,omitempty"` // "gitoid_sha256" field predicates. GitoidSha256 *string `json:"gitoidSha256,omitempty"` @@ -948,14 +949,14 @@ type PayloadDigestWhereInput struct { And []*PayloadDigestWhereInput `json:"and,omitempty"` // "id" field predicates. - ID *int `json:"id,omitempty"` - IDNEQ *int `json:"idNEQ,omitempty"` - IDIn []int `json:"idIn,omitempty"` - IDNotIn []int `json:"idNotIn,omitempty"` - IDGT *int `json:"idGT,omitempty"` - IDGTE *int `json:"idGTE,omitempty"` - IDLT *int `json:"idLT,omitempty"` - IDLTE *int `json:"idLTE,omitempty"` + ID *uuid.UUID `json:"id,omitempty"` + IDNEQ *uuid.UUID `json:"idNEQ,omitempty"` + IDIn []uuid.UUID `json:"idIn,omitempty"` + IDNotIn []uuid.UUID `json:"idNotIn,omitempty"` + IDGT *uuid.UUID `json:"idGT,omitempty"` + IDGTE *uuid.UUID `json:"idGTE,omitempty"` + IDLT *uuid.UUID `json:"idLT,omitempty"` + IDLTE *uuid.UUID `json:"idLTE,omitempty"` // "algorithm" field predicates. Algorithm *string `json:"algorithm,omitempty"` @@ -1202,14 +1203,14 @@ type SignatureWhereInput struct { And []*SignatureWhereInput `json:"and,omitempty"` // "id" field predicates. - ID *int `json:"id,omitempty"` - IDNEQ *int `json:"idNEQ,omitempty"` - IDIn []int `json:"idIn,omitempty"` - IDNotIn []int `json:"idNotIn,omitempty"` - IDGT *int `json:"idGT,omitempty"` - IDGTE *int `json:"idGTE,omitempty"` - IDLT *int `json:"idLT,omitempty"` - IDLTE *int `json:"idLTE,omitempty"` + ID *uuid.UUID `json:"id,omitempty"` + IDNEQ *uuid.UUID `json:"idNEQ,omitempty"` + IDIn []uuid.UUID `json:"idIn,omitempty"` + IDNotIn []uuid.UUID `json:"idNotIn,omitempty"` + IDGT *uuid.UUID `json:"idGT,omitempty"` + IDGTE *uuid.UUID `json:"idGTE,omitempty"` + IDLT *uuid.UUID `json:"idLT,omitempty"` + IDLTE *uuid.UUID `json:"idLTE,omitempty"` // "key_id" field predicates. KeyID *string `json:"keyID,omitempty"` @@ -1478,14 +1479,14 @@ type StatementWhereInput struct { And []*StatementWhereInput `json:"and,omitempty"` // "id" field predicates. - ID *int `json:"id,omitempty"` - IDNEQ *int `json:"idNEQ,omitempty"` - IDIn []int `json:"idIn,omitempty"` - IDNotIn []int `json:"idNotIn,omitempty"` - IDGT *int `json:"idGT,omitempty"` - IDGTE *int `json:"idGTE,omitempty"` - IDLT *int `json:"idLT,omitempty"` - IDLTE *int `json:"idLTE,omitempty"` + ID *uuid.UUID `json:"id,omitempty"` + IDNEQ *uuid.UUID `json:"idNEQ,omitempty"` + IDIn []uuid.UUID `json:"idIn,omitempty"` + IDNotIn []uuid.UUID `json:"idNotIn,omitempty"` + IDGT *uuid.UUID `json:"idGT,omitempty"` + IDGTE *uuid.UUID `json:"idGTE,omitempty"` + IDLT *uuid.UUID `json:"idLT,omitempty"` + IDLTE *uuid.UUID `json:"idLTE,omitempty"` // "predicate" field predicates. Predicate *string `json:"predicate,omitempty"` @@ -1744,14 +1745,14 @@ type SubjectWhereInput struct { And []*SubjectWhereInput `json:"and,omitempty"` // "id" field predicates. - ID *int `json:"id,omitempty"` - IDNEQ *int `json:"idNEQ,omitempty"` - IDIn []int `json:"idIn,omitempty"` - IDNotIn []int `json:"idNotIn,omitempty"` - IDGT *int `json:"idGT,omitempty"` - IDGTE *int `json:"idGTE,omitempty"` - IDLT *int `json:"idLT,omitempty"` - IDLTE *int `json:"idLTE,omitempty"` + ID *uuid.UUID `json:"id,omitempty"` + IDNEQ *uuid.UUID `json:"idNEQ,omitempty"` + IDIn []uuid.UUID `json:"idIn,omitempty"` + IDNotIn []uuid.UUID `json:"idNotIn,omitempty"` + IDGT *uuid.UUID `json:"idGT,omitempty"` + IDGTE *uuid.UUID `json:"idGTE,omitempty"` + IDLT *uuid.UUID `json:"idLT,omitempty"` + IDLTE *uuid.UUID `json:"idLTE,omitempty"` // "name" field predicates. Name *string `json:"name,omitempty"` @@ -1966,14 +1967,14 @@ type SubjectDigestWhereInput struct { And []*SubjectDigestWhereInput `json:"and,omitempty"` // "id" field predicates. - ID *int `json:"id,omitempty"` - IDNEQ *int `json:"idNEQ,omitempty"` - IDIn []int `json:"idIn,omitempty"` - IDNotIn []int `json:"idNotIn,omitempty"` - IDGT *int `json:"idGT,omitempty"` - IDGTE *int `json:"idGTE,omitempty"` - IDLT *int `json:"idLT,omitempty"` - IDLTE *int `json:"idLTE,omitempty"` + ID *uuid.UUID `json:"id,omitempty"` + IDNEQ *uuid.UUID `json:"idNEQ,omitempty"` + IDIn []uuid.UUID `json:"idIn,omitempty"` + IDNotIn []uuid.UUID `json:"idNotIn,omitempty"` + IDGT *uuid.UUID `json:"idGT,omitempty"` + IDGTE *uuid.UUID `json:"idGTE,omitempty"` + IDLT *uuid.UUID `json:"idLT,omitempty"` + IDLTE *uuid.UUID `json:"idLTE,omitempty"` // "algorithm" field predicates. Algorithm *string `json:"algorithm,omitempty"` @@ -2220,14 +2221,14 @@ type TimestampWhereInput struct { And []*TimestampWhereInput `json:"and,omitempty"` // "id" field predicates. - ID *int `json:"id,omitempty"` - IDNEQ *int `json:"idNEQ,omitempty"` - IDIn []int `json:"idIn,omitempty"` - IDNotIn []int `json:"idNotIn,omitempty"` - IDGT *int `json:"idGT,omitempty"` - IDGTE *int `json:"idGTE,omitempty"` - IDLT *int `json:"idLT,omitempty"` - IDLTE *int `json:"idLTE,omitempty"` + ID *uuid.UUID `json:"id,omitempty"` + IDNEQ *uuid.UUID `json:"idNEQ,omitempty"` + IDIn []uuid.UUID `json:"idIn,omitempty"` + IDNotIn []uuid.UUID `json:"idNotIn,omitempty"` + IDGT *uuid.UUID `json:"idGT,omitempty"` + IDGTE *uuid.UUID `json:"idGTE,omitempty"` + IDLT *uuid.UUID `json:"idLT,omitempty"` + IDLTE *uuid.UUID `json:"idLTE,omitempty"` // "type" field predicates. Type *string `json:"type,omitempty"` diff --git a/ent/migrate/migrations/mysql/20231214165639_mysql.sql b/ent/migrate/migrations/mysql/20231214165639_mysql.sql deleted file mode 100644 index 549bb3d6..00000000 --- a/ent/migrate/migrations/mysql/20231214165639_mysql.sql +++ /dev/null @@ -1,18 +0,0 @@ --- Create "statements" table -CREATE TABLE `statements` (`id` bigint NOT NULL AUTO_INCREMENT, `predicate` varchar(255) NOT NULL, PRIMARY KEY (`id`), INDEX `statement_predicate` (`predicate`)) CHARSET utf8mb4 COLLATE utf8mb4_bin; --- Create "attestation_collections" table -CREATE TABLE `attestation_collections` (`id` bigint NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `statement_attestation_collections` bigint NOT NULL, PRIMARY KEY (`id`), INDEX `attestationcollection_name` (`name`), UNIQUE INDEX `statement_attestation_collections` (`statement_attestation_collections`), CONSTRAINT `attestation_collections_statements_attestation_collections` FOREIGN KEY (`statement_attestation_collections`) REFERENCES `statements` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION) CHARSET utf8mb4 COLLATE utf8mb4_bin; --- Create "attestations" table -CREATE TABLE `attestations` (`id` bigint NOT NULL AUTO_INCREMENT, `type` varchar(255) NOT NULL, `attestation_collection_attestations` bigint NOT NULL, PRIMARY KEY (`id`), INDEX `attestation_type` (`type`), INDEX `attestations_attestation_collections_attestations` (`attestation_collection_attestations`), CONSTRAINT `attestations_attestation_collections_attestations` FOREIGN KEY (`attestation_collection_attestations`) REFERENCES `attestation_collections` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION) CHARSET utf8mb4 COLLATE utf8mb4_bin; --- Create "dsses" table -CREATE TABLE `dsses` (`id` bigint NOT NULL AUTO_INCREMENT, `gitoid_sha256` varchar(255) NOT NULL, `payload_type` varchar(255) NOT NULL, `dsse_statement` bigint NULL, PRIMARY KEY (`id`), INDEX `dsses_statements_statement` (`dsse_statement`), UNIQUE INDEX `gitoid_sha256` (`gitoid_sha256`), CONSTRAINT `dsses_statements_statement` FOREIGN KEY (`dsse_statement`) REFERENCES `statements` (`id`) ON UPDATE NO ACTION ON DELETE SET NULL) CHARSET utf8mb4 COLLATE utf8mb4_bin; --- Create "payload_digests" table -CREATE TABLE `payload_digests` (`id` bigint NOT NULL AUTO_INCREMENT, `algorithm` varchar(255) NOT NULL, `value` varchar(255) NOT NULL, `dsse_payload_digests` bigint NULL, PRIMARY KEY (`id`), INDEX `payload_digests_dsses_payload_digests` (`dsse_payload_digests`), INDEX `payloaddigest_value` (`value`), CONSTRAINT `payload_digests_dsses_payload_digests` FOREIGN KEY (`dsse_payload_digests`) REFERENCES `dsses` (`id`) ON UPDATE NO ACTION ON DELETE SET NULL) CHARSET utf8mb4 COLLATE utf8mb4_bin; --- Create "signatures" table -CREATE TABLE `signatures` (`id` bigint NOT NULL AUTO_INCREMENT, `key_id` varchar(255) NOT NULL, `signature` text NOT NULL, `dsse_signatures` bigint NULL, PRIMARY KEY (`id`), INDEX `signature_key_id` (`key_id`), INDEX `signatures_dsses_signatures` (`dsse_signatures`), CONSTRAINT `signatures_dsses_signatures` FOREIGN KEY (`dsse_signatures`) REFERENCES `dsses` (`id`) ON UPDATE NO ACTION ON DELETE SET NULL) CHARSET utf8mb4 COLLATE utf8mb4_bin; --- Create "subjects" table -CREATE TABLE `subjects` (`id` bigint NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `statement_subjects` bigint NULL, PRIMARY KEY (`id`), INDEX `subject_name` (`name`), INDEX `subjects_statements_subjects` (`statement_subjects`), CONSTRAINT `subjects_statements_subjects` FOREIGN KEY (`statement_subjects`) REFERENCES `statements` (`id`) ON UPDATE NO ACTION ON DELETE SET NULL) CHARSET utf8mb4 COLLATE utf8mb4_bin; --- Create "subject_digests" table -CREATE TABLE `subject_digests` (`id` bigint NOT NULL AUTO_INCREMENT, `algorithm` varchar(255) NOT NULL, `value` varchar(255) NOT NULL, `subject_subject_digests` bigint NULL, PRIMARY KEY (`id`), INDEX `subject_digests_subjects_subject_digests` (`subject_subject_digests`), INDEX `subjectdigest_value` (`value`), CONSTRAINT `subject_digests_subjects_subject_digests` FOREIGN KEY (`subject_subject_digests`) REFERENCES `subjects` (`id`) ON UPDATE NO ACTION ON DELETE SET NULL) CHARSET utf8mb4 COLLATE utf8mb4_bin; --- Create "timestamps" table -CREATE TABLE `timestamps` (`id` bigint NOT NULL AUTO_INCREMENT, `type` varchar(255) NOT NULL, `timestamp` timestamp NOT NULL, `signature_timestamps` bigint NULL, PRIMARY KEY (`id`), INDEX `timestamps_signatures_timestamps` (`signature_timestamps`), CONSTRAINT `timestamps_signatures_timestamps` FOREIGN KEY (`signature_timestamps`) REFERENCES `signatures` (`id`) ON UPDATE NO ACTION ON DELETE SET NULL) CHARSET utf8mb4 COLLATE utf8mb4_bin; diff --git a/ent/migrate/migrations/mysql/20240412085222_mysql.sql b/ent/migrate/migrations/mysql/20240412085222_mysql.sql deleted file mode 100644 index b4f413d8..00000000 --- a/ent/migrate/migrations/mysql/20240412085222_mysql.sql +++ /dev/null @@ -1,2 +0,0 @@ --- Create "attestation_policies" table -CREATE TABLE `attestation_policies` (`id` bigint NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `statement_policy` bigint NULL, PRIMARY KEY (`id`), INDEX `attestationpolicy_name` (`name`), UNIQUE INDEX `statement_policy` (`statement_policy`), CONSTRAINT `attestation_policies_statements_policy` FOREIGN KEY (`statement_policy`) REFERENCES `statements` (`id`) ON UPDATE NO ACTION ON DELETE SET NULL) CHARSET utf8mb4 COLLATE utf8mb4_bin; diff --git a/ent/migrate/migrations/mysql/20240524112613_mysql.sql b/ent/migrate/migrations/mysql/20240524112613_mysql.sql new file mode 100644 index 00000000..7568182d --- /dev/null +++ b/ent/migrate/migrations/mysql/20240524112613_mysql.sql @@ -0,0 +1,20 @@ +-- Create "statements" table +CREATE TABLE `statements` (`id` char(36) NOT NULL, `predicate` varchar(255) NOT NULL, PRIMARY KEY (`id`), INDEX `statement_predicate` (`predicate`)) CHARSET utf8mb4 COLLATE utf8mb4_bin; +-- Create "attestation_collections" table +CREATE TABLE `attestation_collections` (`id` char(36) NOT NULL, `name` varchar(255) NOT NULL, `statement_attestation_collections` char(36) NOT NULL, PRIMARY KEY (`id`), INDEX `attestationcollection_name` (`name`), UNIQUE INDEX `statement_attestation_collections` (`statement_attestation_collections`), CONSTRAINT `attestation_collections_statements_attestation_collections` FOREIGN KEY (`statement_attestation_collections`) REFERENCES `statements` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION) CHARSET utf8mb4 COLLATE utf8mb4_bin; +-- Create "attestation_policies" table +CREATE TABLE `attestation_policies` (`id` char(36) NOT NULL, `name` varchar(255) NOT NULL, `statement_policy` char(36) NULL, PRIMARY KEY (`id`), INDEX `attestationpolicy_name` (`name`), UNIQUE INDEX `statement_policy` (`statement_policy`), CONSTRAINT `attestation_policies_statements_policy` FOREIGN KEY (`statement_policy`) REFERENCES `statements` (`id`) ON UPDATE NO ACTION ON DELETE SET NULL) CHARSET utf8mb4 COLLATE utf8mb4_bin; +-- Create "attestations" table +CREATE TABLE `attestations` (`id` char(36) NOT NULL, `type` varchar(255) NOT NULL, `attestation_collection_attestations` char(36) NOT NULL, PRIMARY KEY (`id`), INDEX `attestation_type` (`type`), INDEX `attestations_attestation_collections_attestations` (`attestation_collection_attestations`), CONSTRAINT `attestations_attestation_collections_attestations` FOREIGN KEY (`attestation_collection_attestations`) REFERENCES `attestation_collections` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION) CHARSET utf8mb4 COLLATE utf8mb4_bin; +-- Create "dsses" table +CREATE TABLE `dsses` (`id` char(36) NOT NULL, `gitoid_sha256` varchar(255) NOT NULL, `payload_type` varchar(255) NOT NULL, `dsse_statement` char(36) NULL, PRIMARY KEY (`id`), INDEX `dsses_statements_statement` (`dsse_statement`), UNIQUE INDEX `gitoid_sha256` (`gitoid_sha256`), CONSTRAINT `dsses_statements_statement` FOREIGN KEY (`dsse_statement`) REFERENCES `statements` (`id`) ON UPDATE NO ACTION ON DELETE SET NULL) CHARSET utf8mb4 COLLATE utf8mb4_bin; +-- Create "payload_digests" table +CREATE TABLE `payload_digests` (`id` char(36) NOT NULL, `algorithm` varchar(255) NOT NULL, `value` varchar(255) NOT NULL, `dsse_payload_digests` char(36) NULL, PRIMARY KEY (`id`), INDEX `payload_digests_dsses_payload_digests` (`dsse_payload_digests`), INDEX `payloaddigest_value` (`value`), CONSTRAINT `payload_digests_dsses_payload_digests` FOREIGN KEY (`dsse_payload_digests`) REFERENCES `dsses` (`id`) ON UPDATE NO ACTION ON DELETE SET NULL) CHARSET utf8mb4 COLLATE utf8mb4_bin; +-- Create "signatures" table +CREATE TABLE `signatures` (`id` char(36) NOT NULL, `key_id` varchar(255) NOT NULL, `signature` text NOT NULL, `dsse_signatures` char(36) NULL, PRIMARY KEY (`id`), INDEX `signature_key_id` (`key_id`), INDEX `signatures_dsses_signatures` (`dsse_signatures`), CONSTRAINT `signatures_dsses_signatures` FOREIGN KEY (`dsse_signatures`) REFERENCES `dsses` (`id`) ON UPDATE NO ACTION ON DELETE SET NULL) CHARSET utf8mb4 COLLATE utf8mb4_bin; +-- Create "subjects" table +CREATE TABLE `subjects` (`id` char(36) NOT NULL, `name` varchar(255) NOT NULL, `statement_subjects` char(36) NULL, PRIMARY KEY (`id`), INDEX `subject_name` (`name`), INDEX `subjects_statements_subjects` (`statement_subjects`), CONSTRAINT `subjects_statements_subjects` FOREIGN KEY (`statement_subjects`) REFERENCES `statements` (`id`) ON UPDATE NO ACTION ON DELETE SET NULL) CHARSET utf8mb4 COLLATE utf8mb4_bin; +-- Create "subject_digests" table +CREATE TABLE `subject_digests` (`id` char(36) NOT NULL, `algorithm` varchar(255) NOT NULL, `value` varchar(255) NOT NULL, `subject_subject_digests` char(36) NULL, PRIMARY KEY (`id`), INDEX `subject_digests_subjects_subject_digests` (`subject_subject_digests`), INDEX `subjectdigest_value` (`value`), CONSTRAINT `subject_digests_subjects_subject_digests` FOREIGN KEY (`subject_subject_digests`) REFERENCES `subjects` (`id`) ON UPDATE NO ACTION ON DELETE SET NULL) CHARSET utf8mb4 COLLATE utf8mb4_bin; +-- Create "timestamps" table +CREATE TABLE `timestamps` (`id` char(36) NOT NULL, `type` varchar(255) NOT NULL, `timestamp` timestamp NOT NULL, `signature_timestamps` char(36) NULL, PRIMARY KEY (`id`), INDEX `timestamps_signatures_timestamps` (`signature_timestamps`), CONSTRAINT `timestamps_signatures_timestamps` FOREIGN KEY (`signature_timestamps`) REFERENCES `signatures` (`id`) ON UPDATE NO ACTION ON DELETE SET NULL) CHARSET utf8mb4 COLLATE utf8mb4_bin; diff --git a/ent/migrate/migrations/mysql/atlas.sum b/ent/migrate/migrations/mysql/atlas.sum index a9adf4e2..55583c3a 100644 --- a/ent/migrate/migrations/mysql/atlas.sum +++ b/ent/migrate/migrations/mysql/atlas.sum @@ -1,3 +1,2 @@ -h1:1Ow/eZVMLy44Vylv2ewQF1uQtT3+kvN1yTCa+4JQ5MI= -20231214165639_mysql.sql h1:rqSqoXUOtdEpJT04rLCzyyPJC+NYRjQj9jXHZW+Oq9Q= -20240412085222_mysql.sql h1:V7ePmRzeLat9gKTFnWvZnZIZe+r6OBu0bCS/xeVMPg8= +h1:hmfy8z9GJo6qsuCUPic5i8LIZpfIF0Phkud7Woix6c4= +20240524112613_mysql.sql h1:P16hl/ui8F+xn7opuJT+GCQ8vnJEsQkZp8Q9PMOhrRI= diff --git a/ent/migrate/migrations/pgsql/20231214165922_pgsql.sql b/ent/migrate/migrations/pgsql/20231214165922_pgsql.sql deleted file mode 100644 index e3786c76..00000000 --- a/ent/migrate/migrations/pgsql/20231214165922_pgsql.sql +++ /dev/null @@ -1,36 +0,0 @@ --- Create "statements" table -CREATE TABLE "statements" ("id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "predicate" character varying NOT NULL, PRIMARY KEY ("id")); --- Create index "statement_predicate" to table: "statements" -CREATE INDEX "statement_predicate" ON "statements" ("predicate"); --- Create "attestation_collections" table -CREATE TABLE "attestation_collections" ("id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "name" character varying NOT NULL, "statement_attestation_collections" bigint NOT NULL, PRIMARY KEY ("id"), CONSTRAINT "attestation_collections_statements_attestation_collections" FOREIGN KEY ("statement_attestation_collections") REFERENCES "statements" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION); --- Create index "attestation_collections_statement_attestation_collections_key" to table: "attestation_collections" -CREATE UNIQUE INDEX "attestation_collections_statement_attestation_collections_key" ON "attestation_collections" ("statement_attestation_collections"); --- Create index "attestationcollection_name" to table: "attestation_collections" -CREATE INDEX "attestationcollection_name" ON "attestation_collections" ("name"); --- Create "attestations" table -CREATE TABLE "attestations" ("id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "type" character varying NOT NULL, "attestation_collection_attestations" bigint NOT NULL, PRIMARY KEY ("id"), CONSTRAINT "attestations_attestation_collections_attestations" FOREIGN KEY ("attestation_collection_attestations") REFERENCES "attestation_collections" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION); --- Create index "attestation_type" to table: "attestations" -CREATE INDEX "attestation_type" ON "attestations" ("type"); --- Create "dsses" table -CREATE TABLE "dsses" ("id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "gitoid_sha256" character varying NOT NULL, "payload_type" character varying NOT NULL, "dsse_statement" bigint NULL, PRIMARY KEY ("id"), CONSTRAINT "dsses_statements_statement" FOREIGN KEY ("dsse_statement") REFERENCES "statements" ("id") ON UPDATE NO ACTION ON DELETE SET NULL); --- Create index "dsses_gitoid_sha256_key" to table: "dsses" -CREATE UNIQUE INDEX "dsses_gitoid_sha256_key" ON "dsses" ("gitoid_sha256"); --- Create "payload_digests" table -CREATE TABLE "payload_digests" ("id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "algorithm" character varying NOT NULL, "value" character varying NOT NULL, "dsse_payload_digests" bigint NULL, PRIMARY KEY ("id"), CONSTRAINT "payload_digests_dsses_payload_digests" FOREIGN KEY ("dsse_payload_digests") REFERENCES "dsses" ("id") ON UPDATE NO ACTION ON DELETE SET NULL); --- Create index "payloaddigest_value" to table: "payload_digests" -CREATE INDEX "payloaddigest_value" ON "payload_digests" ("value"); --- Create "signatures" table -CREATE TABLE "signatures" ("id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "key_id" character varying NOT NULL, "signature" character varying NOT NULL, "dsse_signatures" bigint NULL, PRIMARY KEY ("id"), CONSTRAINT "signatures_dsses_signatures" FOREIGN KEY ("dsse_signatures") REFERENCES "dsses" ("id") ON UPDATE NO ACTION ON DELETE SET NULL); --- Create index "signature_key_id" to table: "signatures" -CREATE INDEX "signature_key_id" ON "signatures" ("key_id"); --- Create "subjects" table -CREATE TABLE "subjects" ("id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "name" character varying NOT NULL, "statement_subjects" bigint NULL, PRIMARY KEY ("id"), CONSTRAINT "subjects_statements_subjects" FOREIGN KEY ("statement_subjects") REFERENCES "statements" ("id") ON UPDATE NO ACTION ON DELETE SET NULL); --- Create index "subject_name" to table: "subjects" -CREATE INDEX "subject_name" ON "subjects" ("name"); --- Create "subject_digests" table -CREATE TABLE "subject_digests" ("id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "algorithm" character varying NOT NULL, "value" character varying NOT NULL, "subject_subject_digests" bigint NULL, PRIMARY KEY ("id"), CONSTRAINT "subject_digests_subjects_subject_digests" FOREIGN KEY ("subject_subject_digests") REFERENCES "subjects" ("id") ON UPDATE NO ACTION ON DELETE SET NULL); --- Create index "subjectdigest_value" to table: "subject_digests" -CREATE INDEX "subjectdigest_value" ON "subject_digests" ("value"); --- Create "timestamps" table -CREATE TABLE "timestamps" ("id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "type" character varying NOT NULL, "timestamp" timestamptz NOT NULL, "signature_timestamps" bigint NULL, PRIMARY KEY ("id"), CONSTRAINT "timestamps_signatures_timestamps" FOREIGN KEY ("signature_timestamps") REFERENCES "signatures" ("id") ON UPDATE NO ACTION ON DELETE SET NULL); diff --git a/ent/migrate/migrations/pgsql/20240412085224_pgsql.sql b/ent/migrate/migrations/pgsql/20240412085224_pgsql.sql deleted file mode 100644 index f597b456..00000000 --- a/ent/migrate/migrations/pgsql/20240412085224_pgsql.sql +++ /dev/null @@ -1,6 +0,0 @@ --- Create "attestation_policies" table -CREATE TABLE "attestation_policies" ("id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "name" character varying NOT NULL, "statement_policy" bigint NULL, PRIMARY KEY ("id"), CONSTRAINT "attestation_policies_statements_policy" FOREIGN KEY ("statement_policy") REFERENCES "statements" ("id") ON UPDATE NO ACTION ON DELETE SET NULL); --- Create index "attestation_policies_statement_policy_key" to table: "attestation_policies" -CREATE UNIQUE INDEX "attestation_policies_statement_policy_key" ON "attestation_policies" ("statement_policy"); --- Create index "attestationpolicy_name" to table: "attestation_policies" -CREATE INDEX "attestationpolicy_name" ON "attestation_policies" ("name"); diff --git a/ent/migrate/migrations/pgsql/20240524112615_pgsql.sql b/ent/migrate/migrations/pgsql/20240524112615_pgsql.sql new file mode 100644 index 00000000..130dd52a --- /dev/null +++ b/ent/migrate/migrations/pgsql/20240524112615_pgsql.sql @@ -0,0 +1,42 @@ +-- Create "statements" table +CREATE TABLE "statements" ("id" uuid NOT NULL, "predicate" character varying NOT NULL, PRIMARY KEY ("id")); +-- Create index "statement_predicate" to table: "statements" +CREATE INDEX "statement_predicate" ON "statements" ("predicate"); +-- Create "attestation_collections" table +CREATE TABLE "attestation_collections" ("id" uuid NOT NULL, "name" character varying NOT NULL, "statement_attestation_collections" uuid NOT NULL, PRIMARY KEY ("id"), CONSTRAINT "attestation_collections_statements_attestation_collections" FOREIGN KEY ("statement_attestation_collections") REFERENCES "statements" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION); +-- Create index "attestation_collections_statement_attestation_collections_key" to table: "attestation_collections" +CREATE UNIQUE INDEX "attestation_collections_statement_attestation_collections_key" ON "attestation_collections" ("statement_attestation_collections"); +-- Create index "attestationcollection_name" to table: "attestation_collections" +CREATE INDEX "attestationcollection_name" ON "attestation_collections" ("name"); +-- Create "attestation_policies" table +CREATE TABLE "attestation_policies" ("id" uuid NOT NULL, "name" character varying NOT NULL, "statement_policy" uuid NULL, PRIMARY KEY ("id"), CONSTRAINT "attestation_policies_statements_policy" FOREIGN KEY ("statement_policy") REFERENCES "statements" ("id") ON UPDATE NO ACTION ON DELETE SET NULL); +-- Create index "attestation_policies_statement_policy_key" to table: "attestation_policies" +CREATE UNIQUE INDEX "attestation_policies_statement_policy_key" ON "attestation_policies" ("statement_policy"); +-- Create index "attestationpolicy_name" to table: "attestation_policies" +CREATE INDEX "attestationpolicy_name" ON "attestation_policies" ("name"); +-- Create "attestations" table +CREATE TABLE "attestations" ("id" uuid NOT NULL, "type" character varying NOT NULL, "attestation_collection_attestations" uuid NOT NULL, PRIMARY KEY ("id"), CONSTRAINT "attestations_attestation_collections_attestations" FOREIGN KEY ("attestation_collection_attestations") REFERENCES "attestation_collections" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION); +-- Create index "attestation_type" to table: "attestations" +CREATE INDEX "attestation_type" ON "attestations" ("type"); +-- Create "dsses" table +CREATE TABLE "dsses" ("id" uuid NOT NULL, "gitoid_sha256" character varying NOT NULL, "payload_type" character varying NOT NULL, "dsse_statement" uuid NULL, PRIMARY KEY ("id"), CONSTRAINT "dsses_statements_statement" FOREIGN KEY ("dsse_statement") REFERENCES "statements" ("id") ON UPDATE NO ACTION ON DELETE SET NULL); +-- Create index "dsses_gitoid_sha256_key" to table: "dsses" +CREATE UNIQUE INDEX "dsses_gitoid_sha256_key" ON "dsses" ("gitoid_sha256"); +-- Create "payload_digests" table +CREATE TABLE "payload_digests" ("id" uuid NOT NULL, "algorithm" character varying NOT NULL, "value" character varying NOT NULL, "dsse_payload_digests" uuid NULL, PRIMARY KEY ("id"), CONSTRAINT "payload_digests_dsses_payload_digests" FOREIGN KEY ("dsse_payload_digests") REFERENCES "dsses" ("id") ON UPDATE NO ACTION ON DELETE SET NULL); +-- Create index "payloaddigest_value" to table: "payload_digests" +CREATE INDEX "payloaddigest_value" ON "payload_digests" ("value"); +-- Create "signatures" table +CREATE TABLE "signatures" ("id" uuid NOT NULL, "key_id" character varying NOT NULL, "signature" character varying NOT NULL, "dsse_signatures" uuid NULL, PRIMARY KEY ("id"), CONSTRAINT "signatures_dsses_signatures" FOREIGN KEY ("dsse_signatures") REFERENCES "dsses" ("id") ON UPDATE NO ACTION ON DELETE SET NULL); +-- Create index "signature_key_id" to table: "signatures" +CREATE INDEX "signature_key_id" ON "signatures" ("key_id"); +-- Create "subjects" table +CREATE TABLE "subjects" ("id" uuid NOT NULL, "name" character varying NOT NULL, "statement_subjects" uuid NULL, PRIMARY KEY ("id"), CONSTRAINT "subjects_statements_subjects" FOREIGN KEY ("statement_subjects") REFERENCES "statements" ("id") ON UPDATE NO ACTION ON DELETE SET NULL); +-- Create index "subject_name" to table: "subjects" +CREATE INDEX "subject_name" ON "subjects" ("name"); +-- Create "subject_digests" table +CREATE TABLE "subject_digests" ("id" uuid NOT NULL, "algorithm" character varying NOT NULL, "value" character varying NOT NULL, "subject_subject_digests" uuid NULL, PRIMARY KEY ("id"), CONSTRAINT "subject_digests_subjects_subject_digests" FOREIGN KEY ("subject_subject_digests") REFERENCES "subjects" ("id") ON UPDATE NO ACTION ON DELETE SET NULL); +-- Create index "subjectdigest_value" to table: "subject_digests" +CREATE INDEX "subjectdigest_value" ON "subject_digests" ("value"); +-- Create "timestamps" table +CREATE TABLE "timestamps" ("id" uuid NOT NULL, "type" character varying NOT NULL, "timestamp" timestamptz NOT NULL, "signature_timestamps" uuid NULL, PRIMARY KEY ("id"), CONSTRAINT "timestamps_signatures_timestamps" FOREIGN KEY ("signature_timestamps") REFERENCES "signatures" ("id") ON UPDATE NO ACTION ON DELETE SET NULL); diff --git a/ent/migrate/migrations/pgsql/atlas.sum b/ent/migrate/migrations/pgsql/atlas.sum index 033e45fa..ef622b12 100644 --- a/ent/migrate/migrations/pgsql/atlas.sum +++ b/ent/migrate/migrations/pgsql/atlas.sum @@ -1,3 +1,2 @@ -h1:D/veOuP9Sr5oRpHC8Ow9Td7h4BufsLknJawwIfzTdN0= -20231214165922_pgsql.sql h1:AZaZD6/98yKVFL6svm7gPpKlD1EL6fk8juLh+SW765I= -20240412085224_pgsql.sql h1:OLX7vanfNS1O24Gp8Jeb/1pQJWJKs9cghXJNZ5pwTUc= +h1:tRI2n5O6+6fHTOil/e3LGqO1PEcv3D02M3VmEkH00ls= +20240524112615_pgsql.sql h1:HMRY5DPVr3SjgjpdkCY3+3Us5y5LvtSzNEBwoIND5sY= diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index 20ab26cb..8d445000 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -10,9 +10,9 @@ import ( var ( // AttestationsColumns holds the columns for the "attestations" table. AttestationsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "type", Type: field.TypeString}, - {Name: "attestation_collection_attestations", Type: field.TypeInt}, + {Name: "attestation_collection_attestations", Type: field.TypeUUID}, } // AttestationsTable holds the schema information for the "attestations" table. AttestationsTable = &schema.Table{ @@ -37,9 +37,9 @@ var ( } // AttestationCollectionsColumns holds the columns for the "attestation_collections" table. AttestationCollectionsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "name", Type: field.TypeString}, - {Name: "statement_attestation_collections", Type: field.TypeInt, Unique: true}, + {Name: "statement_attestation_collections", Type: field.TypeUUID, Unique: true}, } // AttestationCollectionsTable holds the schema information for the "attestation_collections" table. AttestationCollectionsTable = &schema.Table{ @@ -64,9 +64,9 @@ var ( } // AttestationPoliciesColumns holds the columns for the "attestation_policies" table. AttestationPoliciesColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "name", Type: field.TypeString}, - {Name: "statement_policy", Type: field.TypeInt, Unique: true, Nullable: true}, + {Name: "statement_policy", Type: field.TypeUUID, Unique: true, Nullable: true}, } // AttestationPoliciesTable holds the schema information for the "attestation_policies" table. AttestationPoliciesTable = &schema.Table{ @@ -91,10 +91,10 @@ var ( } // DssesColumns holds the columns for the "dsses" table. DssesColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "gitoid_sha256", Type: field.TypeString, Unique: true}, {Name: "payload_type", Type: field.TypeString}, - {Name: "dsse_statement", Type: field.TypeInt, Nullable: true}, + {Name: "dsse_statement", Type: field.TypeUUID, Nullable: true}, } // DssesTable holds the schema information for the "dsses" table. DssesTable = &schema.Table{ @@ -112,10 +112,10 @@ var ( } // PayloadDigestsColumns holds the columns for the "payload_digests" table. PayloadDigestsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "algorithm", Type: field.TypeString}, {Name: "value", Type: field.TypeString}, - {Name: "dsse_payload_digests", Type: field.TypeInt, Nullable: true}, + {Name: "dsse_payload_digests", Type: field.TypeUUID, Nullable: true}, } // PayloadDigestsTable holds the schema information for the "payload_digests" table. PayloadDigestsTable = &schema.Table{ @@ -140,10 +140,10 @@ var ( } // SignaturesColumns holds the columns for the "signatures" table. SignaturesColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "key_id", Type: field.TypeString}, {Name: "signature", Type: field.TypeString, SchemaType: map[string]string{"mysql": "text"}}, - {Name: "dsse_signatures", Type: field.TypeInt, Nullable: true}, + {Name: "dsse_signatures", Type: field.TypeUUID, Nullable: true}, } // SignaturesTable holds the schema information for the "signatures" table. SignaturesTable = &schema.Table{ @@ -168,7 +168,7 @@ var ( } // StatementsColumns holds the columns for the "statements" table. StatementsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "predicate", Type: field.TypeString}, } // StatementsTable holds the schema information for the "statements" table. @@ -186,9 +186,9 @@ var ( } // SubjectsColumns holds the columns for the "subjects" table. SubjectsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "name", Type: field.TypeString}, - {Name: "statement_subjects", Type: field.TypeInt, Nullable: true}, + {Name: "statement_subjects", Type: field.TypeUUID, Nullable: true}, } // SubjectsTable holds the schema information for the "subjects" table. SubjectsTable = &schema.Table{ @@ -213,10 +213,10 @@ var ( } // SubjectDigestsColumns holds the columns for the "subject_digests" table. SubjectDigestsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "algorithm", Type: field.TypeString}, {Name: "value", Type: field.TypeString}, - {Name: "subject_subject_digests", Type: field.TypeInt, Nullable: true}, + {Name: "subject_subject_digests", Type: field.TypeUUID, Nullable: true}, } // SubjectDigestsTable holds the schema information for the "subject_digests" table. SubjectDigestsTable = &schema.Table{ @@ -241,10 +241,10 @@ var ( } // TimestampsColumns holds the columns for the "timestamps" table. TimestampsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "type", Type: field.TypeString}, {Name: "timestamp", Type: field.TypeTime}, - {Name: "signature_timestamps", Type: field.TypeInt, Nullable: true}, + {Name: "signature_timestamps", Type: field.TypeUUID, Nullable: true}, } // TimestampsTable holds the schema information for the "timestamps" table. TimestampsTable = &schema.Table{ diff --git a/ent/mutation.go b/ent/mutation.go index 699c685d..634bd35c 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -11,6 +11,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestation" "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/attestationpolicy" @@ -50,10 +51,10 @@ type AttestationMutation struct { config op Op typ string - id *int + id *uuid.UUID _type *string clearedFields map[string]struct{} - attestation_collection *int + attestation_collection *uuid.UUID clearedattestation_collection bool done bool oldValue func(context.Context) (*Attestation, error) @@ -80,7 +81,7 @@ func newAttestationMutation(c config, op Op, opts ...attestationOption) *Attesta } // withAttestationID sets the ID field of the mutation. -func withAttestationID(id int) attestationOption { +func withAttestationID(id uuid.UUID) attestationOption { return func(m *AttestationMutation) { var ( err error @@ -130,9 +131,15 @@ func (m AttestationMutation) Tx() (*Tx, error) { return tx, nil } +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Attestation entities. +func (m *AttestationMutation) SetID(id uuid.UUID) { + m.id = &id +} + // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *AttestationMutation) ID() (id int, exists bool) { +func (m *AttestationMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -143,12 +150,12 @@ func (m *AttestationMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *AttestationMutation) IDs(ctx context.Context) ([]int, error) { +func (m *AttestationMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []int{id}, nil + return []uuid.UUID{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): @@ -195,7 +202,7 @@ func (m *AttestationMutation) ResetType() { } // SetAttestationCollectionID sets the "attestation_collection" edge to the AttestationCollection entity by id. -func (m *AttestationMutation) SetAttestationCollectionID(id int) { +func (m *AttestationMutation) SetAttestationCollectionID(id uuid.UUID) { m.attestation_collection = &id } @@ -210,7 +217,7 @@ func (m *AttestationMutation) AttestationCollectionCleared() bool { } // AttestationCollectionID returns the "attestation_collection" edge ID in the mutation. -func (m *AttestationMutation) AttestationCollectionID() (id int, exists bool) { +func (m *AttestationMutation) AttestationCollectionID() (id uuid.UUID, exists bool) { if m.attestation_collection != nil { return *m.attestation_collection, true } @@ -220,7 +227,7 @@ func (m *AttestationMutation) AttestationCollectionID() (id int, exists bool) { // AttestationCollectionIDs returns the "attestation_collection" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // AttestationCollectionID instead. It exists only for internal usage by the builders. -func (m *AttestationMutation) AttestationCollectionIDs() (ids []int) { +func (m *AttestationMutation) AttestationCollectionIDs() (ids []uuid.UUID) { if id := m.attestation_collection; id != nil { ids = append(ids, *id) } @@ -443,13 +450,13 @@ type AttestationCollectionMutation struct { config op Op typ string - id *int + id *uuid.UUID name *string clearedFields map[string]struct{} - attestations map[int]struct{} - removedattestations map[int]struct{} + attestations map[uuid.UUID]struct{} + removedattestations map[uuid.UUID]struct{} clearedattestations bool - statement *int + statement *uuid.UUID clearedstatement bool done bool oldValue func(context.Context) (*AttestationCollection, error) @@ -476,7 +483,7 @@ func newAttestationCollectionMutation(c config, op Op, opts ...attestationcollec } // withAttestationCollectionID sets the ID field of the mutation. -func withAttestationCollectionID(id int) attestationcollectionOption { +func withAttestationCollectionID(id uuid.UUID) attestationcollectionOption { return func(m *AttestationCollectionMutation) { var ( err error @@ -526,9 +533,15 @@ func (m AttestationCollectionMutation) Tx() (*Tx, error) { return tx, nil } +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of AttestationCollection entities. +func (m *AttestationCollectionMutation) SetID(id uuid.UUID) { + m.id = &id +} + // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *AttestationCollectionMutation) ID() (id int, exists bool) { +func (m *AttestationCollectionMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -539,12 +552,12 @@ func (m *AttestationCollectionMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *AttestationCollectionMutation) IDs(ctx context.Context) ([]int, error) { +func (m *AttestationCollectionMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []int{id}, nil + return []uuid.UUID{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): @@ -591,9 +604,9 @@ func (m *AttestationCollectionMutation) ResetName() { } // AddAttestationIDs adds the "attestations" edge to the Attestation entity by ids. -func (m *AttestationCollectionMutation) AddAttestationIDs(ids ...int) { +func (m *AttestationCollectionMutation) AddAttestationIDs(ids ...uuid.UUID) { if m.attestations == nil { - m.attestations = make(map[int]struct{}) + m.attestations = make(map[uuid.UUID]struct{}) } for i := range ids { m.attestations[ids[i]] = struct{}{} @@ -611,9 +624,9 @@ func (m *AttestationCollectionMutation) AttestationsCleared() bool { } // RemoveAttestationIDs removes the "attestations" edge to the Attestation entity by IDs. -func (m *AttestationCollectionMutation) RemoveAttestationIDs(ids ...int) { +func (m *AttestationCollectionMutation) RemoveAttestationIDs(ids ...uuid.UUID) { if m.removedattestations == nil { - m.removedattestations = make(map[int]struct{}) + m.removedattestations = make(map[uuid.UUID]struct{}) } for i := range ids { delete(m.attestations, ids[i]) @@ -622,7 +635,7 @@ func (m *AttestationCollectionMutation) RemoveAttestationIDs(ids ...int) { } // RemovedAttestations returns the removed IDs of the "attestations" edge to the Attestation entity. -func (m *AttestationCollectionMutation) RemovedAttestationsIDs() (ids []int) { +func (m *AttestationCollectionMutation) RemovedAttestationsIDs() (ids []uuid.UUID) { for id := range m.removedattestations { ids = append(ids, id) } @@ -630,7 +643,7 @@ func (m *AttestationCollectionMutation) RemovedAttestationsIDs() (ids []int) { } // AttestationsIDs returns the "attestations" edge IDs in the mutation. -func (m *AttestationCollectionMutation) AttestationsIDs() (ids []int) { +func (m *AttestationCollectionMutation) AttestationsIDs() (ids []uuid.UUID) { for id := range m.attestations { ids = append(ids, id) } @@ -645,7 +658,7 @@ func (m *AttestationCollectionMutation) ResetAttestations() { } // SetStatementID sets the "statement" edge to the Statement entity by id. -func (m *AttestationCollectionMutation) SetStatementID(id int) { +func (m *AttestationCollectionMutation) SetStatementID(id uuid.UUID) { m.statement = &id } @@ -660,7 +673,7 @@ func (m *AttestationCollectionMutation) StatementCleared() bool { } // StatementID returns the "statement" edge ID in the mutation. -func (m *AttestationCollectionMutation) StatementID() (id int, exists bool) { +func (m *AttestationCollectionMutation) StatementID() (id uuid.UUID, exists bool) { if m.statement != nil { return *m.statement, true } @@ -670,7 +683,7 @@ func (m *AttestationCollectionMutation) StatementID() (id int, exists bool) { // StatementIDs returns the "statement" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // StatementID instead. It exists only for internal usage by the builders. -func (m *AttestationCollectionMutation) StatementIDs() (ids []int) { +func (m *AttestationCollectionMutation) StatementIDs() (ids []uuid.UUID) { if id := m.statement; id != nil { ids = append(ids, *id) } @@ -921,10 +934,10 @@ type AttestationPolicyMutation struct { config op Op typ string - id *int + id *uuid.UUID name *string clearedFields map[string]struct{} - statement *int + statement *uuid.UUID clearedstatement bool done bool oldValue func(context.Context) (*AttestationPolicy, error) @@ -951,7 +964,7 @@ func newAttestationPolicyMutation(c config, op Op, opts ...attestationpolicyOpti } // withAttestationPolicyID sets the ID field of the mutation. -func withAttestationPolicyID(id int) attestationpolicyOption { +func withAttestationPolicyID(id uuid.UUID) attestationpolicyOption { return func(m *AttestationPolicyMutation) { var ( err error @@ -1001,9 +1014,15 @@ func (m AttestationPolicyMutation) Tx() (*Tx, error) { return tx, nil } +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of AttestationPolicy entities. +func (m *AttestationPolicyMutation) SetID(id uuid.UUID) { + m.id = &id +} + // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *AttestationPolicyMutation) ID() (id int, exists bool) { +func (m *AttestationPolicyMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -1014,12 +1033,12 @@ func (m *AttestationPolicyMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *AttestationPolicyMutation) IDs(ctx context.Context) ([]int, error) { +func (m *AttestationPolicyMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []int{id}, nil + return []uuid.UUID{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): @@ -1066,7 +1085,7 @@ func (m *AttestationPolicyMutation) ResetName() { } // SetStatementID sets the "statement" edge to the Statement entity by id. -func (m *AttestationPolicyMutation) SetStatementID(id int) { +func (m *AttestationPolicyMutation) SetStatementID(id uuid.UUID) { m.statement = &id } @@ -1081,7 +1100,7 @@ func (m *AttestationPolicyMutation) StatementCleared() bool { } // StatementID returns the "statement" edge ID in the mutation. -func (m *AttestationPolicyMutation) StatementID() (id int, exists bool) { +func (m *AttestationPolicyMutation) StatementID() (id uuid.UUID, exists bool) { if m.statement != nil { return *m.statement, true } @@ -1091,7 +1110,7 @@ func (m *AttestationPolicyMutation) StatementID() (id int, exists bool) { // StatementIDs returns the "statement" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // StatementID instead. It exists only for internal usage by the builders. -func (m *AttestationPolicyMutation) StatementIDs() (ids []int) { +func (m *AttestationPolicyMutation) StatementIDs() (ids []uuid.UUID) { if id := m.statement; id != nil { ids = append(ids, *id) } @@ -1314,17 +1333,17 @@ type DsseMutation struct { config op Op typ string - id *int + id *uuid.UUID gitoid_sha256 *string payload_type *string clearedFields map[string]struct{} - statement *int + statement *uuid.UUID clearedstatement bool - signatures map[int]struct{} - removedsignatures map[int]struct{} + signatures map[uuid.UUID]struct{} + removedsignatures map[uuid.UUID]struct{} clearedsignatures bool - payload_digests map[int]struct{} - removedpayload_digests map[int]struct{} + payload_digests map[uuid.UUID]struct{} + removedpayload_digests map[uuid.UUID]struct{} clearedpayload_digests bool done bool oldValue func(context.Context) (*Dsse, error) @@ -1351,7 +1370,7 @@ func newDsseMutation(c config, op Op, opts ...dsseOption) *DsseMutation { } // withDsseID sets the ID field of the mutation. -func withDsseID(id int) dsseOption { +func withDsseID(id uuid.UUID) dsseOption { return func(m *DsseMutation) { var ( err error @@ -1401,9 +1420,15 @@ func (m DsseMutation) Tx() (*Tx, error) { return tx, nil } +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Dsse entities. +func (m *DsseMutation) SetID(id uuid.UUID) { + m.id = &id +} + // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *DsseMutation) ID() (id int, exists bool) { +func (m *DsseMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -1414,12 +1439,12 @@ func (m *DsseMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *DsseMutation) IDs(ctx context.Context) ([]int, error) { +func (m *DsseMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []int{id}, nil + return []uuid.UUID{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): @@ -1502,7 +1527,7 @@ func (m *DsseMutation) ResetPayloadType() { } // SetStatementID sets the "statement" edge to the Statement entity by id. -func (m *DsseMutation) SetStatementID(id int) { +func (m *DsseMutation) SetStatementID(id uuid.UUID) { m.statement = &id } @@ -1517,7 +1542,7 @@ func (m *DsseMutation) StatementCleared() bool { } // StatementID returns the "statement" edge ID in the mutation. -func (m *DsseMutation) StatementID() (id int, exists bool) { +func (m *DsseMutation) StatementID() (id uuid.UUID, exists bool) { if m.statement != nil { return *m.statement, true } @@ -1527,7 +1552,7 @@ func (m *DsseMutation) StatementID() (id int, exists bool) { // StatementIDs returns the "statement" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // StatementID instead. It exists only for internal usage by the builders. -func (m *DsseMutation) StatementIDs() (ids []int) { +func (m *DsseMutation) StatementIDs() (ids []uuid.UUID) { if id := m.statement; id != nil { ids = append(ids, *id) } @@ -1541,9 +1566,9 @@ func (m *DsseMutation) ResetStatement() { } // AddSignatureIDs adds the "signatures" edge to the Signature entity by ids. -func (m *DsseMutation) AddSignatureIDs(ids ...int) { +func (m *DsseMutation) AddSignatureIDs(ids ...uuid.UUID) { if m.signatures == nil { - m.signatures = make(map[int]struct{}) + m.signatures = make(map[uuid.UUID]struct{}) } for i := range ids { m.signatures[ids[i]] = struct{}{} @@ -1561,9 +1586,9 @@ func (m *DsseMutation) SignaturesCleared() bool { } // RemoveSignatureIDs removes the "signatures" edge to the Signature entity by IDs. -func (m *DsseMutation) RemoveSignatureIDs(ids ...int) { +func (m *DsseMutation) RemoveSignatureIDs(ids ...uuid.UUID) { if m.removedsignatures == nil { - m.removedsignatures = make(map[int]struct{}) + m.removedsignatures = make(map[uuid.UUID]struct{}) } for i := range ids { delete(m.signatures, ids[i]) @@ -1572,7 +1597,7 @@ func (m *DsseMutation) RemoveSignatureIDs(ids ...int) { } // RemovedSignatures returns the removed IDs of the "signatures" edge to the Signature entity. -func (m *DsseMutation) RemovedSignaturesIDs() (ids []int) { +func (m *DsseMutation) RemovedSignaturesIDs() (ids []uuid.UUID) { for id := range m.removedsignatures { ids = append(ids, id) } @@ -1580,7 +1605,7 @@ func (m *DsseMutation) RemovedSignaturesIDs() (ids []int) { } // SignaturesIDs returns the "signatures" edge IDs in the mutation. -func (m *DsseMutation) SignaturesIDs() (ids []int) { +func (m *DsseMutation) SignaturesIDs() (ids []uuid.UUID) { for id := range m.signatures { ids = append(ids, id) } @@ -1595,9 +1620,9 @@ func (m *DsseMutation) ResetSignatures() { } // AddPayloadDigestIDs adds the "payload_digests" edge to the PayloadDigest entity by ids. -func (m *DsseMutation) AddPayloadDigestIDs(ids ...int) { +func (m *DsseMutation) AddPayloadDigestIDs(ids ...uuid.UUID) { if m.payload_digests == nil { - m.payload_digests = make(map[int]struct{}) + m.payload_digests = make(map[uuid.UUID]struct{}) } for i := range ids { m.payload_digests[ids[i]] = struct{}{} @@ -1615,9 +1640,9 @@ func (m *DsseMutation) PayloadDigestsCleared() bool { } // RemovePayloadDigestIDs removes the "payload_digests" edge to the PayloadDigest entity by IDs. -func (m *DsseMutation) RemovePayloadDigestIDs(ids ...int) { +func (m *DsseMutation) RemovePayloadDigestIDs(ids ...uuid.UUID) { if m.removedpayload_digests == nil { - m.removedpayload_digests = make(map[int]struct{}) + m.removedpayload_digests = make(map[uuid.UUID]struct{}) } for i := range ids { delete(m.payload_digests, ids[i]) @@ -1626,7 +1651,7 @@ func (m *DsseMutation) RemovePayloadDigestIDs(ids ...int) { } // RemovedPayloadDigests returns the removed IDs of the "payload_digests" edge to the PayloadDigest entity. -func (m *DsseMutation) RemovedPayloadDigestsIDs() (ids []int) { +func (m *DsseMutation) RemovedPayloadDigestsIDs() (ids []uuid.UUID) { for id := range m.removedpayload_digests { ids = append(ids, id) } @@ -1634,7 +1659,7 @@ func (m *DsseMutation) RemovedPayloadDigestsIDs() (ids []int) { } // PayloadDigestsIDs returns the "payload_digests" edge IDs in the mutation. -func (m *DsseMutation) PayloadDigestsIDs() (ids []int) { +func (m *DsseMutation) PayloadDigestsIDs() (ids []uuid.UUID) { for id := range m.payload_digests { ids = append(ids, id) } @@ -1929,11 +1954,11 @@ type PayloadDigestMutation struct { config op Op typ string - id *int + id *uuid.UUID algorithm *string value *string clearedFields map[string]struct{} - dsse *int + dsse *uuid.UUID cleareddsse bool done bool oldValue func(context.Context) (*PayloadDigest, error) @@ -1960,7 +1985,7 @@ func newPayloadDigestMutation(c config, op Op, opts ...payloaddigestOption) *Pay } // withPayloadDigestID sets the ID field of the mutation. -func withPayloadDigestID(id int) payloaddigestOption { +func withPayloadDigestID(id uuid.UUID) payloaddigestOption { return func(m *PayloadDigestMutation) { var ( err error @@ -2010,9 +2035,15 @@ func (m PayloadDigestMutation) Tx() (*Tx, error) { return tx, nil } +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of PayloadDigest entities. +func (m *PayloadDigestMutation) SetID(id uuid.UUID) { + m.id = &id +} + // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *PayloadDigestMutation) ID() (id int, exists bool) { +func (m *PayloadDigestMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -2023,12 +2054,12 @@ func (m *PayloadDigestMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *PayloadDigestMutation) IDs(ctx context.Context) ([]int, error) { +func (m *PayloadDigestMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []int{id}, nil + return []uuid.UUID{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): @@ -2111,7 +2142,7 @@ func (m *PayloadDigestMutation) ResetValue() { } // SetDsseID sets the "dsse" edge to the Dsse entity by id. -func (m *PayloadDigestMutation) SetDsseID(id int) { +func (m *PayloadDigestMutation) SetDsseID(id uuid.UUID) { m.dsse = &id } @@ -2126,7 +2157,7 @@ func (m *PayloadDigestMutation) DsseCleared() bool { } // DsseID returns the "dsse" edge ID in the mutation. -func (m *PayloadDigestMutation) DsseID() (id int, exists bool) { +func (m *PayloadDigestMutation) DsseID() (id uuid.UUID, exists bool) { if m.dsse != nil { return *m.dsse, true } @@ -2136,7 +2167,7 @@ func (m *PayloadDigestMutation) DsseID() (id int, exists bool) { // DsseIDs returns the "dsse" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // DsseID instead. It exists only for internal usage by the builders. -func (m *PayloadDigestMutation) DsseIDs() (ids []int) { +func (m *PayloadDigestMutation) DsseIDs() (ids []uuid.UUID) { if id := m.dsse; id != nil { ids = append(ids, *id) } @@ -2376,14 +2407,14 @@ type SignatureMutation struct { config op Op typ string - id *int + id *uuid.UUID key_id *string signature *string clearedFields map[string]struct{} - dsse *int + dsse *uuid.UUID cleareddsse bool - timestamps map[int]struct{} - removedtimestamps map[int]struct{} + timestamps map[uuid.UUID]struct{} + removedtimestamps map[uuid.UUID]struct{} clearedtimestamps bool done bool oldValue func(context.Context) (*Signature, error) @@ -2410,7 +2441,7 @@ func newSignatureMutation(c config, op Op, opts ...signatureOption) *SignatureMu } // withSignatureID sets the ID field of the mutation. -func withSignatureID(id int) signatureOption { +func withSignatureID(id uuid.UUID) signatureOption { return func(m *SignatureMutation) { var ( err error @@ -2460,9 +2491,15 @@ func (m SignatureMutation) Tx() (*Tx, error) { return tx, nil } +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Signature entities. +func (m *SignatureMutation) SetID(id uuid.UUID) { + m.id = &id +} + // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *SignatureMutation) ID() (id int, exists bool) { +func (m *SignatureMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -2473,12 +2510,12 @@ func (m *SignatureMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *SignatureMutation) IDs(ctx context.Context) ([]int, error) { +func (m *SignatureMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []int{id}, nil + return []uuid.UUID{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): @@ -2561,7 +2598,7 @@ func (m *SignatureMutation) ResetSignature() { } // SetDsseID sets the "dsse" edge to the Dsse entity by id. -func (m *SignatureMutation) SetDsseID(id int) { +func (m *SignatureMutation) SetDsseID(id uuid.UUID) { m.dsse = &id } @@ -2576,7 +2613,7 @@ func (m *SignatureMutation) DsseCleared() bool { } // DsseID returns the "dsse" edge ID in the mutation. -func (m *SignatureMutation) DsseID() (id int, exists bool) { +func (m *SignatureMutation) DsseID() (id uuid.UUID, exists bool) { if m.dsse != nil { return *m.dsse, true } @@ -2586,7 +2623,7 @@ func (m *SignatureMutation) DsseID() (id int, exists bool) { // DsseIDs returns the "dsse" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // DsseID instead. It exists only for internal usage by the builders. -func (m *SignatureMutation) DsseIDs() (ids []int) { +func (m *SignatureMutation) DsseIDs() (ids []uuid.UUID) { if id := m.dsse; id != nil { ids = append(ids, *id) } @@ -2600,9 +2637,9 @@ func (m *SignatureMutation) ResetDsse() { } // AddTimestampIDs adds the "timestamps" edge to the Timestamp entity by ids. -func (m *SignatureMutation) AddTimestampIDs(ids ...int) { +func (m *SignatureMutation) AddTimestampIDs(ids ...uuid.UUID) { if m.timestamps == nil { - m.timestamps = make(map[int]struct{}) + m.timestamps = make(map[uuid.UUID]struct{}) } for i := range ids { m.timestamps[ids[i]] = struct{}{} @@ -2620,9 +2657,9 @@ func (m *SignatureMutation) TimestampsCleared() bool { } // RemoveTimestampIDs removes the "timestamps" edge to the Timestamp entity by IDs. -func (m *SignatureMutation) RemoveTimestampIDs(ids ...int) { +func (m *SignatureMutation) RemoveTimestampIDs(ids ...uuid.UUID) { if m.removedtimestamps == nil { - m.removedtimestamps = make(map[int]struct{}) + m.removedtimestamps = make(map[uuid.UUID]struct{}) } for i := range ids { delete(m.timestamps, ids[i]) @@ -2631,7 +2668,7 @@ func (m *SignatureMutation) RemoveTimestampIDs(ids ...int) { } // RemovedTimestamps returns the removed IDs of the "timestamps" edge to the Timestamp entity. -func (m *SignatureMutation) RemovedTimestampsIDs() (ids []int) { +func (m *SignatureMutation) RemovedTimestampsIDs() (ids []uuid.UUID) { for id := range m.removedtimestamps { ids = append(ids, id) } @@ -2639,7 +2676,7 @@ func (m *SignatureMutation) RemovedTimestampsIDs() (ids []int) { } // TimestampsIDs returns the "timestamps" edge IDs in the mutation. -func (m *SignatureMutation) TimestampsIDs() (ids []int) { +func (m *SignatureMutation) TimestampsIDs() (ids []uuid.UUID) { for id := range m.timestamps { ids = append(ids, id) } @@ -2908,18 +2945,18 @@ type StatementMutation struct { config op Op typ string - id *int + id *uuid.UUID predicate *string clearedFields map[string]struct{} - subjects map[int]struct{} - removedsubjects map[int]struct{} + subjects map[uuid.UUID]struct{} + removedsubjects map[uuid.UUID]struct{} clearedsubjects bool - policy *int + policy *uuid.UUID clearedpolicy bool - attestation_collections *int + attestation_collections *uuid.UUID clearedattestation_collections bool - dsse map[int]struct{} - removeddsse map[int]struct{} + dsse map[uuid.UUID]struct{} + removeddsse map[uuid.UUID]struct{} cleareddsse bool done bool oldValue func(context.Context) (*Statement, error) @@ -2946,7 +2983,7 @@ func newStatementMutation(c config, op Op, opts ...statementOption) *StatementMu } // withStatementID sets the ID field of the mutation. -func withStatementID(id int) statementOption { +func withStatementID(id uuid.UUID) statementOption { return func(m *StatementMutation) { var ( err error @@ -2996,9 +3033,15 @@ func (m StatementMutation) Tx() (*Tx, error) { return tx, nil } +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Statement entities. +func (m *StatementMutation) SetID(id uuid.UUID) { + m.id = &id +} + // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *StatementMutation) ID() (id int, exists bool) { +func (m *StatementMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -3009,12 +3052,12 @@ func (m *StatementMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *StatementMutation) IDs(ctx context.Context) ([]int, error) { +func (m *StatementMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []int{id}, nil + return []uuid.UUID{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): @@ -3061,9 +3104,9 @@ func (m *StatementMutation) ResetPredicate() { } // AddSubjectIDs adds the "subjects" edge to the Subject entity by ids. -func (m *StatementMutation) AddSubjectIDs(ids ...int) { +func (m *StatementMutation) AddSubjectIDs(ids ...uuid.UUID) { if m.subjects == nil { - m.subjects = make(map[int]struct{}) + m.subjects = make(map[uuid.UUID]struct{}) } for i := range ids { m.subjects[ids[i]] = struct{}{} @@ -3081,9 +3124,9 @@ func (m *StatementMutation) SubjectsCleared() bool { } // RemoveSubjectIDs removes the "subjects" edge to the Subject entity by IDs. -func (m *StatementMutation) RemoveSubjectIDs(ids ...int) { +func (m *StatementMutation) RemoveSubjectIDs(ids ...uuid.UUID) { if m.removedsubjects == nil { - m.removedsubjects = make(map[int]struct{}) + m.removedsubjects = make(map[uuid.UUID]struct{}) } for i := range ids { delete(m.subjects, ids[i]) @@ -3092,7 +3135,7 @@ func (m *StatementMutation) RemoveSubjectIDs(ids ...int) { } // RemovedSubjects returns the removed IDs of the "subjects" edge to the Subject entity. -func (m *StatementMutation) RemovedSubjectsIDs() (ids []int) { +func (m *StatementMutation) RemovedSubjectsIDs() (ids []uuid.UUID) { for id := range m.removedsubjects { ids = append(ids, id) } @@ -3100,7 +3143,7 @@ func (m *StatementMutation) RemovedSubjectsIDs() (ids []int) { } // SubjectsIDs returns the "subjects" edge IDs in the mutation. -func (m *StatementMutation) SubjectsIDs() (ids []int) { +func (m *StatementMutation) SubjectsIDs() (ids []uuid.UUID) { for id := range m.subjects { ids = append(ids, id) } @@ -3115,7 +3158,7 @@ func (m *StatementMutation) ResetSubjects() { } // SetPolicyID sets the "policy" edge to the AttestationPolicy entity by id. -func (m *StatementMutation) SetPolicyID(id int) { +func (m *StatementMutation) SetPolicyID(id uuid.UUID) { m.policy = &id } @@ -3130,7 +3173,7 @@ func (m *StatementMutation) PolicyCleared() bool { } // PolicyID returns the "policy" edge ID in the mutation. -func (m *StatementMutation) PolicyID() (id int, exists bool) { +func (m *StatementMutation) PolicyID() (id uuid.UUID, exists bool) { if m.policy != nil { return *m.policy, true } @@ -3140,7 +3183,7 @@ func (m *StatementMutation) PolicyID() (id int, exists bool) { // PolicyIDs returns the "policy" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // PolicyID instead. It exists only for internal usage by the builders. -func (m *StatementMutation) PolicyIDs() (ids []int) { +func (m *StatementMutation) PolicyIDs() (ids []uuid.UUID) { if id := m.policy; id != nil { ids = append(ids, *id) } @@ -3154,7 +3197,7 @@ func (m *StatementMutation) ResetPolicy() { } // SetAttestationCollectionsID sets the "attestation_collections" edge to the AttestationCollection entity by id. -func (m *StatementMutation) SetAttestationCollectionsID(id int) { +func (m *StatementMutation) SetAttestationCollectionsID(id uuid.UUID) { m.attestation_collections = &id } @@ -3169,7 +3212,7 @@ func (m *StatementMutation) AttestationCollectionsCleared() bool { } // AttestationCollectionsID returns the "attestation_collections" edge ID in the mutation. -func (m *StatementMutation) AttestationCollectionsID() (id int, exists bool) { +func (m *StatementMutation) AttestationCollectionsID() (id uuid.UUID, exists bool) { if m.attestation_collections != nil { return *m.attestation_collections, true } @@ -3179,7 +3222,7 @@ func (m *StatementMutation) AttestationCollectionsID() (id int, exists bool) { // AttestationCollectionsIDs returns the "attestation_collections" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // AttestationCollectionsID instead. It exists only for internal usage by the builders. -func (m *StatementMutation) AttestationCollectionsIDs() (ids []int) { +func (m *StatementMutation) AttestationCollectionsIDs() (ids []uuid.UUID) { if id := m.attestation_collections; id != nil { ids = append(ids, *id) } @@ -3193,9 +3236,9 @@ func (m *StatementMutation) ResetAttestationCollections() { } // AddDsseIDs adds the "dsse" edge to the Dsse entity by ids. -func (m *StatementMutation) AddDsseIDs(ids ...int) { +func (m *StatementMutation) AddDsseIDs(ids ...uuid.UUID) { if m.dsse == nil { - m.dsse = make(map[int]struct{}) + m.dsse = make(map[uuid.UUID]struct{}) } for i := range ids { m.dsse[ids[i]] = struct{}{} @@ -3213,9 +3256,9 @@ func (m *StatementMutation) DsseCleared() bool { } // RemoveDsseIDs removes the "dsse" edge to the Dsse entity by IDs. -func (m *StatementMutation) RemoveDsseIDs(ids ...int) { +func (m *StatementMutation) RemoveDsseIDs(ids ...uuid.UUID) { if m.removeddsse == nil { - m.removeddsse = make(map[int]struct{}) + m.removeddsse = make(map[uuid.UUID]struct{}) } for i := range ids { delete(m.dsse, ids[i]) @@ -3224,7 +3267,7 @@ func (m *StatementMutation) RemoveDsseIDs(ids ...int) { } // RemovedDsse returns the removed IDs of the "dsse" edge to the Dsse entity. -func (m *StatementMutation) RemovedDsseIDs() (ids []int) { +func (m *StatementMutation) RemovedDsseIDs() (ids []uuid.UUID) { for id := range m.removeddsse { ids = append(ids, id) } @@ -3232,7 +3275,7 @@ func (m *StatementMutation) RemovedDsseIDs() (ids []int) { } // DsseIDs returns the "dsse" edge IDs in the mutation. -func (m *StatementMutation) DsseIDs() (ids []int) { +func (m *StatementMutation) DsseIDs() (ids []uuid.UUID) { for id := range m.dsse { ids = append(ids, id) } @@ -3528,13 +3571,13 @@ type SubjectMutation struct { config op Op typ string - id *int + id *uuid.UUID name *string clearedFields map[string]struct{} - subject_digests map[int]struct{} - removedsubject_digests map[int]struct{} + subject_digests map[uuid.UUID]struct{} + removedsubject_digests map[uuid.UUID]struct{} clearedsubject_digests bool - statement *int + statement *uuid.UUID clearedstatement bool done bool oldValue func(context.Context) (*Subject, error) @@ -3561,7 +3604,7 @@ func newSubjectMutation(c config, op Op, opts ...subjectOption) *SubjectMutation } // withSubjectID sets the ID field of the mutation. -func withSubjectID(id int) subjectOption { +func withSubjectID(id uuid.UUID) subjectOption { return func(m *SubjectMutation) { var ( err error @@ -3611,9 +3654,15 @@ func (m SubjectMutation) Tx() (*Tx, error) { return tx, nil } +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Subject entities. +func (m *SubjectMutation) SetID(id uuid.UUID) { + m.id = &id +} + // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *SubjectMutation) ID() (id int, exists bool) { +func (m *SubjectMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -3624,12 +3673,12 @@ func (m *SubjectMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *SubjectMutation) IDs(ctx context.Context) ([]int, error) { +func (m *SubjectMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []int{id}, nil + return []uuid.UUID{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): @@ -3676,9 +3725,9 @@ func (m *SubjectMutation) ResetName() { } // AddSubjectDigestIDs adds the "subject_digests" edge to the SubjectDigest entity by ids. -func (m *SubjectMutation) AddSubjectDigestIDs(ids ...int) { +func (m *SubjectMutation) AddSubjectDigestIDs(ids ...uuid.UUID) { if m.subject_digests == nil { - m.subject_digests = make(map[int]struct{}) + m.subject_digests = make(map[uuid.UUID]struct{}) } for i := range ids { m.subject_digests[ids[i]] = struct{}{} @@ -3696,9 +3745,9 @@ func (m *SubjectMutation) SubjectDigestsCleared() bool { } // RemoveSubjectDigestIDs removes the "subject_digests" edge to the SubjectDigest entity by IDs. -func (m *SubjectMutation) RemoveSubjectDigestIDs(ids ...int) { +func (m *SubjectMutation) RemoveSubjectDigestIDs(ids ...uuid.UUID) { if m.removedsubject_digests == nil { - m.removedsubject_digests = make(map[int]struct{}) + m.removedsubject_digests = make(map[uuid.UUID]struct{}) } for i := range ids { delete(m.subject_digests, ids[i]) @@ -3707,7 +3756,7 @@ func (m *SubjectMutation) RemoveSubjectDigestIDs(ids ...int) { } // RemovedSubjectDigests returns the removed IDs of the "subject_digests" edge to the SubjectDigest entity. -func (m *SubjectMutation) RemovedSubjectDigestsIDs() (ids []int) { +func (m *SubjectMutation) RemovedSubjectDigestsIDs() (ids []uuid.UUID) { for id := range m.removedsubject_digests { ids = append(ids, id) } @@ -3715,7 +3764,7 @@ func (m *SubjectMutation) RemovedSubjectDigestsIDs() (ids []int) { } // SubjectDigestsIDs returns the "subject_digests" edge IDs in the mutation. -func (m *SubjectMutation) SubjectDigestsIDs() (ids []int) { +func (m *SubjectMutation) SubjectDigestsIDs() (ids []uuid.UUID) { for id := range m.subject_digests { ids = append(ids, id) } @@ -3730,7 +3779,7 @@ func (m *SubjectMutation) ResetSubjectDigests() { } // SetStatementID sets the "statement" edge to the Statement entity by id. -func (m *SubjectMutation) SetStatementID(id int) { +func (m *SubjectMutation) SetStatementID(id uuid.UUID) { m.statement = &id } @@ -3745,7 +3794,7 @@ func (m *SubjectMutation) StatementCleared() bool { } // StatementID returns the "statement" edge ID in the mutation. -func (m *SubjectMutation) StatementID() (id int, exists bool) { +func (m *SubjectMutation) StatementID() (id uuid.UUID, exists bool) { if m.statement != nil { return *m.statement, true } @@ -3755,7 +3804,7 @@ func (m *SubjectMutation) StatementID() (id int, exists bool) { // StatementIDs returns the "statement" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // StatementID instead. It exists only for internal usage by the builders. -func (m *SubjectMutation) StatementIDs() (ids []int) { +func (m *SubjectMutation) StatementIDs() (ids []uuid.UUID) { if id := m.statement; id != nil { ids = append(ids, *id) } @@ -4006,11 +4055,11 @@ type SubjectDigestMutation struct { config op Op typ string - id *int + id *uuid.UUID algorithm *string value *string clearedFields map[string]struct{} - subject *int + subject *uuid.UUID clearedsubject bool done bool oldValue func(context.Context) (*SubjectDigest, error) @@ -4037,7 +4086,7 @@ func newSubjectDigestMutation(c config, op Op, opts ...subjectdigestOption) *Sub } // withSubjectDigestID sets the ID field of the mutation. -func withSubjectDigestID(id int) subjectdigestOption { +func withSubjectDigestID(id uuid.UUID) subjectdigestOption { return func(m *SubjectDigestMutation) { var ( err error @@ -4087,9 +4136,15 @@ func (m SubjectDigestMutation) Tx() (*Tx, error) { return tx, nil } +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of SubjectDigest entities. +func (m *SubjectDigestMutation) SetID(id uuid.UUID) { + m.id = &id +} + // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *SubjectDigestMutation) ID() (id int, exists bool) { +func (m *SubjectDigestMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -4100,12 +4155,12 @@ func (m *SubjectDigestMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *SubjectDigestMutation) IDs(ctx context.Context) ([]int, error) { +func (m *SubjectDigestMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []int{id}, nil + return []uuid.UUID{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): @@ -4188,7 +4243,7 @@ func (m *SubjectDigestMutation) ResetValue() { } // SetSubjectID sets the "subject" edge to the Subject entity by id. -func (m *SubjectDigestMutation) SetSubjectID(id int) { +func (m *SubjectDigestMutation) SetSubjectID(id uuid.UUID) { m.subject = &id } @@ -4203,7 +4258,7 @@ func (m *SubjectDigestMutation) SubjectCleared() bool { } // SubjectID returns the "subject" edge ID in the mutation. -func (m *SubjectDigestMutation) SubjectID() (id int, exists bool) { +func (m *SubjectDigestMutation) SubjectID() (id uuid.UUID, exists bool) { if m.subject != nil { return *m.subject, true } @@ -4213,7 +4268,7 @@ func (m *SubjectDigestMutation) SubjectID() (id int, exists bool) { // SubjectIDs returns the "subject" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // SubjectID instead. It exists only for internal usage by the builders. -func (m *SubjectDigestMutation) SubjectIDs() (ids []int) { +func (m *SubjectDigestMutation) SubjectIDs() (ids []uuid.UUID) { if id := m.subject; id != nil { ids = append(ids, *id) } @@ -4453,11 +4508,11 @@ type TimestampMutation struct { config op Op typ string - id *int + id *uuid.UUID _type *string timestamp *time.Time clearedFields map[string]struct{} - signature *int + signature *uuid.UUID clearedsignature bool done bool oldValue func(context.Context) (*Timestamp, error) @@ -4484,7 +4539,7 @@ func newTimestampMutation(c config, op Op, opts ...timestampOption) *TimestampMu } // withTimestampID sets the ID field of the mutation. -func withTimestampID(id int) timestampOption { +func withTimestampID(id uuid.UUID) timestampOption { return func(m *TimestampMutation) { var ( err error @@ -4534,9 +4589,15 @@ func (m TimestampMutation) Tx() (*Tx, error) { return tx, nil } +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Timestamp entities. +func (m *TimestampMutation) SetID(id uuid.UUID) { + m.id = &id +} + // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *TimestampMutation) ID() (id int, exists bool) { +func (m *TimestampMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -4547,12 +4608,12 @@ func (m *TimestampMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *TimestampMutation) IDs(ctx context.Context) ([]int, error) { +func (m *TimestampMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []int{id}, nil + return []uuid.UUID{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): @@ -4635,7 +4696,7 @@ func (m *TimestampMutation) ResetTimestamp() { } // SetSignatureID sets the "signature" edge to the Signature entity by id. -func (m *TimestampMutation) SetSignatureID(id int) { +func (m *TimestampMutation) SetSignatureID(id uuid.UUID) { m.signature = &id } @@ -4650,7 +4711,7 @@ func (m *TimestampMutation) SignatureCleared() bool { } // SignatureID returns the "signature" edge ID in the mutation. -func (m *TimestampMutation) SignatureID() (id int, exists bool) { +func (m *TimestampMutation) SignatureID() (id uuid.UUID, exists bool) { if m.signature != nil { return *m.signature, true } @@ -4660,7 +4721,7 @@ func (m *TimestampMutation) SignatureID() (id int, exists bool) { // SignatureIDs returns the "signature" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // SignatureID instead. It exists only for internal usage by the builders. -func (m *TimestampMutation) SignatureIDs() (ids []int) { +func (m *TimestampMutation) SignatureIDs() (ids []uuid.UUID) { if id := m.signature; id != nil { ids = append(ids, *id) } diff --git a/ent/payloaddigest.go b/ent/payloaddigest.go index 6e07080b..17a97c0a 100644 --- a/ent/payloaddigest.go +++ b/ent/payloaddigest.go @@ -8,6 +8,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/dsse" "github.com/in-toto/archivista/ent/payloaddigest" ) @@ -16,7 +17,7 @@ import ( type PayloadDigest struct { config `json:"-"` // ID of the ent. - ID int `json:"id,omitempty"` + ID uuid.UUID `json:"id,omitempty"` // Algorithm holds the value of the "algorithm" field. Algorithm string `json:"algorithm,omitempty"` // Value holds the value of the "value" field. @@ -24,7 +25,7 @@ type PayloadDigest struct { // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the PayloadDigestQuery when eager-loading is set. Edges PayloadDigestEdges `json:"edges"` - dsse_payload_digests *int + dsse_payload_digests *uuid.UUID selectValues sql.SelectValues } @@ -55,12 +56,12 @@ func (*PayloadDigest) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case payloaddigest.FieldID: - values[i] = new(sql.NullInt64) case payloaddigest.FieldAlgorithm, payloaddigest.FieldValue: values[i] = new(sql.NullString) + case payloaddigest.FieldID: + values[i] = new(uuid.UUID) case payloaddigest.ForeignKeys[0]: // dsse_payload_digests - values[i] = new(sql.NullInt64) + values[i] = &sql.NullScanner{S: new(uuid.UUID)} default: values[i] = new(sql.UnknownType) } @@ -77,11 +78,11 @@ func (pd *PayloadDigest) assignValues(columns []string, values []any) error { for i := range columns { switch columns[i] { case payloaddigest.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + pd.ID = *value } - pd.ID = int(value.Int64) case payloaddigest.FieldAlgorithm: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field algorithm", values[i]) @@ -95,11 +96,11 @@ func (pd *PayloadDigest) assignValues(columns []string, values []any) error { pd.Value = value.String } case payloaddigest.ForeignKeys[0]: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field dsse_payload_digests", value) + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field dsse_payload_digests", values[i]) } else if value.Valid { - pd.dsse_payload_digests = new(int) - *pd.dsse_payload_digests = int(value.Int64) + pd.dsse_payload_digests = new(uuid.UUID) + *pd.dsse_payload_digests = *value.S.(*uuid.UUID) } default: pd.selectValues.Set(columns[i], values[i]) diff --git a/ent/payloaddigest/payloaddigest.go b/ent/payloaddigest/payloaddigest.go index d2e31d7a..79264ea6 100644 --- a/ent/payloaddigest/payloaddigest.go +++ b/ent/payloaddigest/payloaddigest.go @@ -5,6 +5,7 @@ package payloaddigest import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" ) const ( @@ -62,6 +63,8 @@ var ( AlgorithmValidator func(string) error // ValueValidator is a validator for the "value" field. It is called by the builders before save. ValueValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID ) // OrderOption defines the ordering options for the PayloadDigest queries. diff --git a/ent/payloaddigest/where.go b/ent/payloaddigest/where.go index e766123d..333c83c0 100644 --- a/ent/payloaddigest/where.go +++ b/ent/payloaddigest/where.go @@ -5,51 +5,52 @@ package payloaddigest import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/predicate" ) // ID filters vertices based on their ID field. -func ID(id int) predicate.PayloadDigest { +func ID(id uuid.UUID) predicate.PayloadDigest { return predicate.PayloadDigest(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.PayloadDigest { +func IDEQ(id uuid.UUID) predicate.PayloadDigest { return predicate.PayloadDigest(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.PayloadDigest { +func IDNEQ(id uuid.UUID) predicate.PayloadDigest { return predicate.PayloadDigest(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.PayloadDigest { +func IDIn(ids ...uuid.UUID) predicate.PayloadDigest { return predicate.PayloadDigest(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.PayloadDigest { +func IDNotIn(ids ...uuid.UUID) predicate.PayloadDigest { return predicate.PayloadDigest(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.PayloadDigest { +func IDGT(id uuid.UUID) predicate.PayloadDigest { return predicate.PayloadDigest(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.PayloadDigest { +func IDGTE(id uuid.UUID) predicate.PayloadDigest { return predicate.PayloadDigest(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.PayloadDigest { +func IDLT(id uuid.UUID) predicate.PayloadDigest { return predicate.PayloadDigest(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.PayloadDigest { +func IDLTE(id uuid.UUID) predicate.PayloadDigest { return predicate.PayloadDigest(sql.FieldLTE(FieldID, id)) } diff --git a/ent/payloaddigest_create.go b/ent/payloaddigest_create.go index f9a6ca9d..d2fc0351 100644 --- a/ent/payloaddigest_create.go +++ b/ent/payloaddigest_create.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/dsse" "github.com/in-toto/archivista/ent/payloaddigest" ) @@ -32,14 +33,28 @@ func (pdc *PayloadDigestCreate) SetValue(s string) *PayloadDigestCreate { return pdc } +// SetID sets the "id" field. +func (pdc *PayloadDigestCreate) SetID(u uuid.UUID) *PayloadDigestCreate { + pdc.mutation.SetID(u) + return pdc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (pdc *PayloadDigestCreate) SetNillableID(u *uuid.UUID) *PayloadDigestCreate { + if u != nil { + pdc.SetID(*u) + } + return pdc +} + // SetDsseID sets the "dsse" edge to the Dsse entity by ID. -func (pdc *PayloadDigestCreate) SetDsseID(id int) *PayloadDigestCreate { +func (pdc *PayloadDigestCreate) SetDsseID(id uuid.UUID) *PayloadDigestCreate { pdc.mutation.SetDsseID(id) return pdc } // SetNillableDsseID sets the "dsse" edge to the Dsse entity by ID if the given value is not nil. -func (pdc *PayloadDigestCreate) SetNillableDsseID(id *int) *PayloadDigestCreate { +func (pdc *PayloadDigestCreate) SetNillableDsseID(id *uuid.UUID) *PayloadDigestCreate { if id != nil { pdc = pdc.SetDsseID(*id) } @@ -58,6 +73,7 @@ func (pdc *PayloadDigestCreate) Mutation() *PayloadDigestMutation { // Save creates the PayloadDigest in the database. func (pdc *PayloadDigestCreate) Save(ctx context.Context) (*PayloadDigest, error) { + pdc.defaults() return withHooks(ctx, pdc.sqlSave, pdc.mutation, pdc.hooks) } @@ -83,6 +99,14 @@ func (pdc *PayloadDigestCreate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (pdc *PayloadDigestCreate) defaults() { + if _, ok := pdc.mutation.ID(); !ok { + v := payloaddigest.DefaultID() + pdc.mutation.SetID(v) + } +} + // check runs all checks and user-defined validators on the builder. func (pdc *PayloadDigestCreate) check() error { if _, ok := pdc.mutation.Algorithm(); !ok { @@ -115,8 +139,13 @@ func (pdc *PayloadDigestCreate) sqlSave(ctx context.Context) (*PayloadDigest, er } return nil, err } - id := _spec.ID.Value.(int64) - _node.ID = int(id) + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } pdc.mutation.id = &_node.ID pdc.mutation.done = true return _node, nil @@ -125,8 +154,12 @@ func (pdc *PayloadDigestCreate) sqlSave(ctx context.Context) (*PayloadDigest, er func (pdc *PayloadDigestCreate) createSpec() (*PayloadDigest, *sqlgraph.CreateSpec) { var ( _node = &PayloadDigest{config: pdc.config} - _spec = sqlgraph.NewCreateSpec(payloaddigest.Table, sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeInt)) + _spec = sqlgraph.NewCreateSpec(payloaddigest.Table, sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeUUID)) ) + if id, ok := pdc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } if value, ok := pdc.mutation.Algorithm(); ok { _spec.SetField(payloaddigest.FieldAlgorithm, field.TypeString, value) _node.Algorithm = value @@ -143,7 +176,7 @@ func (pdc *PayloadDigestCreate) createSpec() (*PayloadDigest, *sqlgraph.CreateSp Columns: []string{payloaddigest.DsseColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -173,6 +206,7 @@ func (pdcb *PayloadDigestCreateBulk) Save(ctx context.Context) ([]*PayloadDigest for i := range pdcb.builders { func(i int, root context.Context) { builder := pdcb.builders[i] + builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*PayloadDigestMutation) if !ok { @@ -199,10 +233,6 @@ func (pdcb *PayloadDigestCreateBulk) Save(ctx context.Context) ([]*PayloadDigest return nil, err } mutation.id = &nodes[i].ID - if specs[i].ID.Value != nil { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int(id) - } mutation.done = true return nodes[i], nil }) diff --git a/ent/payloaddigest_delete.go b/ent/payloaddigest_delete.go index d9b80795..c8ed6075 100644 --- a/ent/payloaddigest_delete.go +++ b/ent/payloaddigest_delete.go @@ -40,7 +40,7 @@ func (pdd *PayloadDigestDelete) ExecX(ctx context.Context) int { } func (pdd *PayloadDigestDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(payloaddigest.Table, sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeInt)) + _spec := sqlgraph.NewDeleteSpec(payloaddigest.Table, sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeUUID)) if ps := pdd.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { diff --git a/ent/payloaddigest_query.go b/ent/payloaddigest_query.go index bbe3f8c9..ae831ef7 100644 --- a/ent/payloaddigest_query.go +++ b/ent/payloaddigest_query.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/dsse" "github.com/in-toto/archivista/ent/payloaddigest" "github.com/in-toto/archivista/ent/predicate" @@ -108,8 +109,8 @@ func (pdq *PayloadDigestQuery) FirstX(ctx context.Context) *PayloadDigest { // FirstID returns the first PayloadDigest ID from the query. // Returns a *NotFoundError when no PayloadDigest ID was found. -func (pdq *PayloadDigestQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -121,7 +122,7 @@ func (pdq *PayloadDigestQuery) FirstID(ctx context.Context) (id int, err error) } // FirstIDX is like FirstID, but panics if an error occurs. -func (pdq *PayloadDigestQuery) FirstIDX(ctx context.Context) int { +func (pdq *PayloadDigestQuery) FirstIDX(ctx context.Context) uuid.UUID { id, err := pdq.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) @@ -159,8 +160,8 @@ func (pdq *PayloadDigestQuery) OnlyX(ctx context.Context) *PayloadDigest { // OnlyID is like Only, but returns the only PayloadDigest ID in the query. // Returns a *NotSingularError when more than one PayloadDigest ID is found. // Returns a *NotFoundError when no entities are found. -func (pdq *PayloadDigestQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -176,7 +177,7 @@ func (pdq *PayloadDigestQuery) OnlyID(ctx context.Context) (id int, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (pdq *PayloadDigestQuery) OnlyIDX(ctx context.Context) int { +func (pdq *PayloadDigestQuery) OnlyIDX(ctx context.Context) uuid.UUID { id, err := pdq.OnlyID(ctx) if err != nil { panic(err) @@ -204,7 +205,7 @@ func (pdq *PayloadDigestQuery) AllX(ctx context.Context) []*PayloadDigest { } // IDs executes the query and returns a list of PayloadDigest IDs. -func (pdq *PayloadDigestQuery) IDs(ctx context.Context) (ids []int, err error) { +func (pdq *PayloadDigestQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if pdq.ctx.Unique == nil && pdq.path != nil { pdq.Unique(true) } @@ -216,7 +217,7 @@ func (pdq *PayloadDigestQuery) IDs(ctx context.Context) (ids []int, err error) { } // IDsX is like IDs, but panics if an error occurs. -func (pdq *PayloadDigestQuery) IDsX(ctx context.Context) []int { +func (pdq *PayloadDigestQuery) IDsX(ctx context.Context) []uuid.UUID { ids, err := pdq.IDs(ctx) if err != nil { panic(err) @@ -419,8 +420,8 @@ func (pdq *PayloadDigestQuery) sqlAll(ctx context.Context, hooks ...queryHook) ( } func (pdq *PayloadDigestQuery) loadDsse(ctx context.Context, query *DsseQuery, nodes []*PayloadDigest, init func(*PayloadDigest), assign func(*PayloadDigest, *Dsse)) error { - ids := make([]int, 0, len(nodes)) - nodeids := make(map[int][]*PayloadDigest) + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*PayloadDigest) for i := range nodes { if nodes[i].dsse_payload_digests == nil { continue @@ -464,7 +465,7 @@ func (pdq *PayloadDigestQuery) sqlCount(ctx context.Context) (int, error) { } func (pdq *PayloadDigestQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(payloaddigest.Table, payloaddigest.Columns, sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeInt)) + _spec := sqlgraph.NewQuerySpec(payloaddigest.Table, payloaddigest.Columns, sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeUUID)) _spec.From = pdq.sql if unique := pdq.ctx.Unique; unique != nil { _spec.Unique = *unique diff --git a/ent/payloaddigest_update.go b/ent/payloaddigest_update.go index a2bb7656..d0715b16 100644 --- a/ent/payloaddigest_update.go +++ b/ent/payloaddigest_update.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/dsse" "github.com/in-toto/archivista/ent/payloaddigest" "github.com/in-toto/archivista/ent/predicate" @@ -57,13 +58,13 @@ func (pdu *PayloadDigestUpdate) SetNillableValue(s *string) *PayloadDigestUpdate } // SetDsseID sets the "dsse" edge to the Dsse entity by ID. -func (pdu *PayloadDigestUpdate) SetDsseID(id int) *PayloadDigestUpdate { +func (pdu *PayloadDigestUpdate) SetDsseID(id uuid.UUID) *PayloadDigestUpdate { pdu.mutation.SetDsseID(id) return pdu } // SetNillableDsseID sets the "dsse" edge to the Dsse entity by ID if the given value is not nil. -func (pdu *PayloadDigestUpdate) SetNillableDsseID(id *int) *PayloadDigestUpdate { +func (pdu *PayloadDigestUpdate) SetNillableDsseID(id *uuid.UUID) *PayloadDigestUpdate { if id != nil { pdu = pdu.SetDsseID(*id) } @@ -132,7 +133,7 @@ func (pdu *PayloadDigestUpdate) sqlSave(ctx context.Context) (n int, err error) if err := pdu.check(); err != nil { return n, err } - _spec := sqlgraph.NewUpdateSpec(payloaddigest.Table, payloaddigest.Columns, sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(payloaddigest.Table, payloaddigest.Columns, sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeUUID)) if ps := pdu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -154,7 +155,7 @@ func (pdu *PayloadDigestUpdate) sqlSave(ctx context.Context) (n int, err error) Columns: []string{payloaddigest.DsseColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -167,7 +168,7 @@ func (pdu *PayloadDigestUpdate) sqlSave(ctx context.Context) (n int, err error) Columns: []string{payloaddigest.DsseColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -224,13 +225,13 @@ func (pduo *PayloadDigestUpdateOne) SetNillableValue(s *string) *PayloadDigestUp } // SetDsseID sets the "dsse" edge to the Dsse entity by ID. -func (pduo *PayloadDigestUpdateOne) SetDsseID(id int) *PayloadDigestUpdateOne { +func (pduo *PayloadDigestUpdateOne) SetDsseID(id uuid.UUID) *PayloadDigestUpdateOne { pduo.mutation.SetDsseID(id) return pduo } // SetNillableDsseID sets the "dsse" edge to the Dsse entity by ID if the given value is not nil. -func (pduo *PayloadDigestUpdateOne) SetNillableDsseID(id *int) *PayloadDigestUpdateOne { +func (pduo *PayloadDigestUpdateOne) SetNillableDsseID(id *uuid.UUID) *PayloadDigestUpdateOne { if id != nil { pduo = pduo.SetDsseID(*id) } @@ -312,7 +313,7 @@ func (pduo *PayloadDigestUpdateOne) sqlSave(ctx context.Context) (_node *Payload if err := pduo.check(); err != nil { return _node, err } - _spec := sqlgraph.NewUpdateSpec(payloaddigest.Table, payloaddigest.Columns, sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(payloaddigest.Table, payloaddigest.Columns, sqlgraph.NewFieldSpec(payloaddigest.FieldID, field.TypeUUID)) id, ok := pduo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PayloadDigest.id" for update`)} @@ -351,7 +352,7 @@ func (pduo *PayloadDigestUpdateOne) sqlSave(ctx context.Context) (_node *Payload Columns: []string{payloaddigest.DsseColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -364,7 +365,7 @@ func (pduo *PayloadDigestUpdateOne) sqlSave(ctx context.Context) (_node *Payload Columns: []string{payloaddigest.DsseColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/ent/runtime.go b/ent/runtime.go index 06f23d34..b8a55dcd 100644 --- a/ent/runtime.go +++ b/ent/runtime.go @@ -3,6 +3,7 @@ package ent import ( + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestation" "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/attestationpolicy" @@ -13,6 +14,7 @@ import ( "github.com/in-toto/archivista/ent/statement" "github.com/in-toto/archivista/ent/subject" "github.com/in-toto/archivista/ent/subjectdigest" + "github.com/in-toto/archivista/ent/timestamp" ) // The init function reads all schema descriptors with runtime code @@ -22,71 +24,113 @@ func init() { attestationFields := schema.Attestation{}.Fields() _ = attestationFields // attestationDescType is the schema descriptor for type field. - attestationDescType := attestationFields[0].Descriptor() + attestationDescType := attestationFields[1].Descriptor() // attestation.TypeValidator is a validator for the "type" field. It is called by the builders before save. attestation.TypeValidator = attestationDescType.Validators[0].(func(string) error) + // attestationDescID is the schema descriptor for id field. + attestationDescID := attestationFields[0].Descriptor() + // attestation.DefaultID holds the default value on creation for the id field. + attestation.DefaultID = attestationDescID.Default.(func() uuid.UUID) attestationcollectionFields := schema.AttestationCollection{}.Fields() _ = attestationcollectionFields // attestationcollectionDescName is the schema descriptor for name field. - attestationcollectionDescName := attestationcollectionFields[0].Descriptor() + attestationcollectionDescName := attestationcollectionFields[1].Descriptor() // attestationcollection.NameValidator is a validator for the "name" field. It is called by the builders before save. attestationcollection.NameValidator = attestationcollectionDescName.Validators[0].(func(string) error) + // attestationcollectionDescID is the schema descriptor for id field. + attestationcollectionDescID := attestationcollectionFields[0].Descriptor() + // attestationcollection.DefaultID holds the default value on creation for the id field. + attestationcollection.DefaultID = attestationcollectionDescID.Default.(func() uuid.UUID) attestationpolicyFields := schema.AttestationPolicy{}.Fields() _ = attestationpolicyFields // attestationpolicyDescName is the schema descriptor for name field. - attestationpolicyDescName := attestationpolicyFields[0].Descriptor() + attestationpolicyDescName := attestationpolicyFields[1].Descriptor() // attestationpolicy.NameValidator is a validator for the "name" field. It is called by the builders before save. attestationpolicy.NameValidator = attestationpolicyDescName.Validators[0].(func(string) error) + // attestationpolicyDescID is the schema descriptor for id field. + attestationpolicyDescID := attestationpolicyFields[0].Descriptor() + // attestationpolicy.DefaultID holds the default value on creation for the id field. + attestationpolicy.DefaultID = attestationpolicyDescID.Default.(func() uuid.UUID) dsseFields := schema.Dsse{}.Fields() _ = dsseFields // dsseDescGitoidSha256 is the schema descriptor for gitoid_sha256 field. - dsseDescGitoidSha256 := dsseFields[0].Descriptor() + dsseDescGitoidSha256 := dsseFields[1].Descriptor() // dsse.GitoidSha256Validator is a validator for the "gitoid_sha256" field. It is called by the builders before save. dsse.GitoidSha256Validator = dsseDescGitoidSha256.Validators[0].(func(string) error) // dsseDescPayloadType is the schema descriptor for payload_type field. - dsseDescPayloadType := dsseFields[1].Descriptor() + dsseDescPayloadType := dsseFields[2].Descriptor() // dsse.PayloadTypeValidator is a validator for the "payload_type" field. It is called by the builders before save. dsse.PayloadTypeValidator = dsseDescPayloadType.Validators[0].(func(string) error) + // dsseDescID is the schema descriptor for id field. + dsseDescID := dsseFields[0].Descriptor() + // dsse.DefaultID holds the default value on creation for the id field. + dsse.DefaultID = dsseDescID.Default.(func() uuid.UUID) payloaddigestFields := schema.PayloadDigest{}.Fields() _ = payloaddigestFields // payloaddigestDescAlgorithm is the schema descriptor for algorithm field. - payloaddigestDescAlgorithm := payloaddigestFields[0].Descriptor() + payloaddigestDescAlgorithm := payloaddigestFields[1].Descriptor() // payloaddigest.AlgorithmValidator is a validator for the "algorithm" field. It is called by the builders before save. payloaddigest.AlgorithmValidator = payloaddigestDescAlgorithm.Validators[0].(func(string) error) // payloaddigestDescValue is the schema descriptor for value field. - payloaddigestDescValue := payloaddigestFields[1].Descriptor() + payloaddigestDescValue := payloaddigestFields[2].Descriptor() // payloaddigest.ValueValidator is a validator for the "value" field. It is called by the builders before save. payloaddigest.ValueValidator = payloaddigestDescValue.Validators[0].(func(string) error) + // payloaddigestDescID is the schema descriptor for id field. + payloaddigestDescID := payloaddigestFields[0].Descriptor() + // payloaddigest.DefaultID holds the default value on creation for the id field. + payloaddigest.DefaultID = payloaddigestDescID.Default.(func() uuid.UUID) signatureFields := schema.Signature{}.Fields() _ = signatureFields // signatureDescKeyID is the schema descriptor for key_id field. - signatureDescKeyID := signatureFields[0].Descriptor() + 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[1].Descriptor() + signatureDescSignature := signatureFields[2].Descriptor() // signature.SignatureValidator is a validator for the "signature" field. It is called by the builders before save. signature.SignatureValidator = signatureDescSignature.Validators[0].(func(string) error) + // signatureDescID is the schema descriptor for id field. + signatureDescID := signatureFields[0].Descriptor() + // signature.DefaultID holds the default value on creation for the id field. + signature.DefaultID = signatureDescID.Default.(func() uuid.UUID) statementFields := schema.Statement{}.Fields() _ = statementFields // statementDescPredicate is the schema descriptor for predicate field. - statementDescPredicate := statementFields[0].Descriptor() + statementDescPredicate := statementFields[1].Descriptor() // statement.PredicateValidator is a validator for the "predicate" field. It is called by the builders before save. statement.PredicateValidator = statementDescPredicate.Validators[0].(func(string) error) + // statementDescID is the schema descriptor for id field. + statementDescID := statementFields[0].Descriptor() + // statement.DefaultID holds the default value on creation for the id field. + statement.DefaultID = statementDescID.Default.(func() uuid.UUID) subjectFields := schema.Subject{}.Fields() _ = subjectFields // subjectDescName is the schema descriptor for name field. - subjectDescName := subjectFields[0].Descriptor() + subjectDescName := subjectFields[1].Descriptor() // subject.NameValidator is a validator for the "name" field. It is called by the builders before save. subject.NameValidator = subjectDescName.Validators[0].(func(string) error) + // subjectDescID is the schema descriptor for id field. + subjectDescID := subjectFields[0].Descriptor() + // subject.DefaultID holds the default value on creation for the id field. + subject.DefaultID = subjectDescID.Default.(func() uuid.UUID) subjectdigestFields := schema.SubjectDigest{}.Fields() _ = subjectdigestFields // subjectdigestDescAlgorithm is the schema descriptor for algorithm field. - subjectdigestDescAlgorithm := subjectdigestFields[0].Descriptor() + subjectdigestDescAlgorithm := subjectdigestFields[1].Descriptor() // subjectdigest.AlgorithmValidator is a validator for the "algorithm" field. It is called by the builders before save. subjectdigest.AlgorithmValidator = subjectdigestDescAlgorithm.Validators[0].(func(string) error) // subjectdigestDescValue is the schema descriptor for value field. - subjectdigestDescValue := subjectdigestFields[1].Descriptor() + subjectdigestDescValue := subjectdigestFields[2].Descriptor() // subjectdigest.ValueValidator is a validator for the "value" field. It is called by the builders before save. subjectdigest.ValueValidator = subjectdigestDescValue.Validators[0].(func(string) error) + // subjectdigestDescID is the schema descriptor for id field. + subjectdigestDescID := subjectdigestFields[0].Descriptor() + // subjectdigest.DefaultID holds the default value on creation for the id field. + subjectdigest.DefaultID = subjectdigestDescID.Default.(func() uuid.UUID) + timestampFields := schema.Timestamp{}.Fields() + _ = timestampFields + // timestampDescID is the schema descriptor for id field. + timestampDescID := timestampFields[0].Descriptor() + // timestamp.DefaultID holds the default value on creation for the id field. + timestamp.DefaultID = timestampDescID.Default.(func() uuid.UUID) } diff --git a/ent/signature.go b/ent/signature.go index 46b0aeca..276e7ada 100644 --- a/ent/signature.go +++ b/ent/signature.go @@ -8,6 +8,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/dsse" "github.com/in-toto/archivista/ent/signature" ) @@ -16,7 +17,7 @@ import ( type Signature struct { config `json:"-"` // ID of the ent. - ID int `json:"id,omitempty"` + ID uuid.UUID `json:"id,omitempty"` // KeyID holds the value of the "key_id" field. KeyID string `json:"key_id,omitempty"` // Signature holds the value of the "signature" field. @@ -24,7 +25,7 @@ type Signature struct { // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the SignatureQuery when eager-loading is set. Edges SignatureEdges `json:"edges"` - dsse_signatures *int + dsse_signatures *uuid.UUID selectValues sql.SelectValues } @@ -68,12 +69,12 @@ func (*Signature) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case signature.FieldID: - values[i] = new(sql.NullInt64) case signature.FieldKeyID, signature.FieldSignature: values[i] = new(sql.NullString) + case signature.FieldID: + values[i] = new(uuid.UUID) case signature.ForeignKeys[0]: // dsse_signatures - values[i] = new(sql.NullInt64) + values[i] = &sql.NullScanner{S: new(uuid.UUID)} default: values[i] = new(sql.UnknownType) } @@ -90,11 +91,11 @@ func (s *Signature) assignValues(columns []string, values []any) error { for i := range columns { switch columns[i] { case signature.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + s.ID = *value } - s.ID = int(value.Int64) case signature.FieldKeyID: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field key_id", values[i]) @@ -108,11 +109,11 @@ func (s *Signature) assignValues(columns []string, values []any) error { s.Signature = value.String } case signature.ForeignKeys[0]: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field dsse_signatures", value) + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field dsse_signatures", values[i]) } else if value.Valid { - s.dsse_signatures = new(int) - *s.dsse_signatures = int(value.Int64) + s.dsse_signatures = new(uuid.UUID) + *s.dsse_signatures = *value.S.(*uuid.UUID) } default: s.selectValues.Set(columns[i], values[i]) diff --git a/ent/signature/signature.go b/ent/signature/signature.go index 8e7d97f6..ef7e8ce5 100644 --- a/ent/signature/signature.go +++ b/ent/signature/signature.go @@ -5,6 +5,7 @@ package signature import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" ) const ( @@ -71,6 +72,8 @@ var ( 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. + DefaultID func() uuid.UUID ) // OrderOption defines the ordering options for the Signature queries. diff --git a/ent/signature/where.go b/ent/signature/where.go index 2caa4a87..bafd62df 100644 --- a/ent/signature/where.go +++ b/ent/signature/where.go @@ -5,51 +5,52 @@ package signature import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/predicate" ) // ID filters vertices based on their ID field. -func ID(id int) predicate.Signature { +func ID(id uuid.UUID) predicate.Signature { return predicate.Signature(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.Signature { +func IDEQ(id uuid.UUID) predicate.Signature { return predicate.Signature(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.Signature { +func IDNEQ(id uuid.UUID) predicate.Signature { return predicate.Signature(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.Signature { +func IDIn(ids ...uuid.UUID) predicate.Signature { return predicate.Signature(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.Signature { +func IDNotIn(ids ...uuid.UUID) predicate.Signature { return predicate.Signature(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.Signature { +func IDGT(id uuid.UUID) predicate.Signature { return predicate.Signature(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.Signature { +func IDGTE(id uuid.UUID) predicate.Signature { return predicate.Signature(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.Signature { +func IDLT(id uuid.UUID) predicate.Signature { return predicate.Signature(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.Signature { +func IDLTE(id uuid.UUID) predicate.Signature { return predicate.Signature(sql.FieldLTE(FieldID, id)) } diff --git a/ent/signature_create.go b/ent/signature_create.go index 6d4e21f8..141d3d24 100644 --- a/ent/signature_create.go +++ b/ent/signature_create.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/dsse" "github.com/in-toto/archivista/ent/signature" "github.com/in-toto/archivista/ent/timestamp" @@ -33,14 +34,28 @@ func (sc *SignatureCreate) SetSignature(s string) *SignatureCreate { return sc } +// SetID sets the "id" field. +func (sc *SignatureCreate) SetID(u uuid.UUID) *SignatureCreate { + sc.mutation.SetID(u) + return sc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (sc *SignatureCreate) SetNillableID(u *uuid.UUID) *SignatureCreate { + if u != nil { + sc.SetID(*u) + } + return sc +} + // SetDsseID sets the "dsse" edge to the Dsse entity by ID. -func (sc *SignatureCreate) SetDsseID(id int) *SignatureCreate { +func (sc *SignatureCreate) SetDsseID(id uuid.UUID) *SignatureCreate { sc.mutation.SetDsseID(id) return sc } // SetNillableDsseID sets the "dsse" edge to the Dsse entity by ID if the given value is not nil. -func (sc *SignatureCreate) SetNillableDsseID(id *int) *SignatureCreate { +func (sc *SignatureCreate) SetNillableDsseID(id *uuid.UUID) *SignatureCreate { if id != nil { sc = sc.SetDsseID(*id) } @@ -53,14 +68,14 @@ func (sc *SignatureCreate) SetDsse(d *Dsse) *SignatureCreate { } // AddTimestampIDs adds the "timestamps" edge to the Timestamp entity by IDs. -func (sc *SignatureCreate) AddTimestampIDs(ids ...int) *SignatureCreate { +func (sc *SignatureCreate) AddTimestampIDs(ids ...uuid.UUID) *SignatureCreate { sc.mutation.AddTimestampIDs(ids...) return sc } // AddTimestamps adds the "timestamps" edges to the Timestamp entity. func (sc *SignatureCreate) AddTimestamps(t ...*Timestamp) *SignatureCreate { - ids := make([]int, len(t)) + ids := make([]uuid.UUID, len(t)) for i := range t { ids[i] = t[i].ID } @@ -74,6 +89,7 @@ func (sc *SignatureCreate) Mutation() *SignatureMutation { // Save creates the Signature in the database. func (sc *SignatureCreate) Save(ctx context.Context) (*Signature, error) { + sc.defaults() return withHooks(ctx, sc.sqlSave, sc.mutation, sc.hooks) } @@ -99,6 +115,14 @@ func (sc *SignatureCreate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (sc *SignatureCreate) defaults() { + if _, ok := sc.mutation.ID(); !ok { + v := signature.DefaultID() + sc.mutation.SetID(v) + } +} + // check runs all checks and user-defined validators on the builder. func (sc *SignatureCreate) check() error { if _, ok := sc.mutation.KeyID(); !ok { @@ -131,8 +155,13 @@ func (sc *SignatureCreate) sqlSave(ctx context.Context) (*Signature, error) { } return nil, err } - id := _spec.ID.Value.(int64) - _node.ID = int(id) + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } sc.mutation.id = &_node.ID sc.mutation.done = true return _node, nil @@ -141,8 +170,12 @@ func (sc *SignatureCreate) sqlSave(ctx context.Context) (*Signature, error) { func (sc *SignatureCreate) createSpec() (*Signature, *sqlgraph.CreateSpec) { var ( _node = &Signature{config: sc.config} - _spec = sqlgraph.NewCreateSpec(signature.Table, sqlgraph.NewFieldSpec(signature.FieldID, field.TypeInt)) + _spec = sqlgraph.NewCreateSpec(signature.Table, sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID)) ) + if id, ok := sc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } if value, ok := sc.mutation.KeyID(); ok { _spec.SetField(signature.FieldKeyID, field.TypeString, value) _node.KeyID = value @@ -159,7 +192,7 @@ func (sc *SignatureCreate) createSpec() (*Signature, *sqlgraph.CreateSpec) { Columns: []string{signature.DsseColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -176,7 +209,7 @@ func (sc *SignatureCreate) createSpec() (*Signature, *sqlgraph.CreateSpec) { Columns: []string{signature.TimestampsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -205,6 +238,7 @@ func (scb *SignatureCreateBulk) Save(ctx context.Context) ([]*Signature, error) for i := range scb.builders { func(i int, root context.Context) { builder := scb.builders[i] + builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*SignatureMutation) if !ok { @@ -231,10 +265,6 @@ func (scb *SignatureCreateBulk) Save(ctx context.Context) ([]*Signature, error) return nil, err } mutation.id = &nodes[i].ID - if specs[i].ID.Value != nil { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int(id) - } mutation.done = true return nodes[i], nil }) diff --git a/ent/signature_delete.go b/ent/signature_delete.go index 32891ab6..bfb74f3d 100644 --- a/ent/signature_delete.go +++ b/ent/signature_delete.go @@ -40,7 +40,7 @@ func (sd *SignatureDelete) ExecX(ctx context.Context) int { } func (sd *SignatureDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(signature.Table, sqlgraph.NewFieldSpec(signature.FieldID, field.TypeInt)) + _spec := sqlgraph.NewDeleteSpec(signature.Table, sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID)) if ps := sd.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { diff --git a/ent/signature_query.go b/ent/signature_query.go index 280b61ba..8ece2a0c 100644 --- a/ent/signature_query.go +++ b/ent/signature_query.go @@ -11,6 +11,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/dsse" "github.com/in-toto/archivista/ent/predicate" "github.com/in-toto/archivista/ent/signature" @@ -134,8 +135,8 @@ func (sq *SignatureQuery) FirstX(ctx context.Context) *Signature { // FirstID returns the first Signature ID from the query. // Returns a *NotFoundError when no Signature ID was found. -func (sq *SignatureQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -147,7 +148,7 @@ func (sq *SignatureQuery) FirstID(ctx context.Context) (id int, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (sq *SignatureQuery) FirstIDX(ctx context.Context) int { +func (sq *SignatureQuery) FirstIDX(ctx context.Context) uuid.UUID { id, err := sq.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) @@ -185,8 +186,8 @@ func (sq *SignatureQuery) OnlyX(ctx context.Context) *Signature { // OnlyID is like Only, but returns the only Signature ID in the query. // Returns a *NotSingularError when more than one Signature ID is found. // Returns a *NotFoundError when no entities are found. -func (sq *SignatureQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -202,7 +203,7 @@ func (sq *SignatureQuery) OnlyID(ctx context.Context) (id int, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (sq *SignatureQuery) OnlyIDX(ctx context.Context) int { +func (sq *SignatureQuery) OnlyIDX(ctx context.Context) uuid.UUID { id, err := sq.OnlyID(ctx) if err != nil { panic(err) @@ -230,7 +231,7 @@ func (sq *SignatureQuery) AllX(ctx context.Context) []*Signature { } // IDs executes the query and returns a list of Signature IDs. -func (sq *SignatureQuery) IDs(ctx context.Context) (ids []int, err error) { +func (sq *SignatureQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if sq.ctx.Unique == nil && sq.path != nil { sq.Unique(true) } @@ -242,7 +243,7 @@ func (sq *SignatureQuery) IDs(ctx context.Context) (ids []int, err error) { } // IDsX is like IDs, but panics if an error occurs. -func (sq *SignatureQuery) IDsX(ctx context.Context) []int { +func (sq *SignatureQuery) IDsX(ctx context.Context) []uuid.UUID { ids, err := sq.IDs(ctx) if err != nil { panic(err) @@ -472,8 +473,8 @@ func (sq *SignatureQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Si } func (sq *SignatureQuery) loadDsse(ctx context.Context, query *DsseQuery, nodes []*Signature, init func(*Signature), assign func(*Signature, *Dsse)) error { - ids := make([]int, 0, len(nodes)) - nodeids := make(map[int][]*Signature) + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*Signature) for i := range nodes { if nodes[i].dsse_signatures == nil { continue @@ -505,7 +506,7 @@ func (sq *SignatureQuery) loadDsse(ctx context.Context, query *DsseQuery, nodes } func (sq *SignatureQuery) loadTimestamps(ctx context.Context, query *TimestampQuery, nodes []*Signature, init func(*Signature), assign func(*Signature, *Timestamp)) error { fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int]*Signature) + nodeids := make(map[uuid.UUID]*Signature) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] @@ -548,7 +549,7 @@ func (sq *SignatureQuery) sqlCount(ctx context.Context) (int, error) { } func (sq *SignatureQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(signature.Table, signature.Columns, sqlgraph.NewFieldSpec(signature.FieldID, field.TypeInt)) + _spec := sqlgraph.NewQuerySpec(signature.Table, signature.Columns, sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID)) _spec.From = sq.sql if unique := sq.ctx.Unique; unique != nil { _spec.Unique = *unique diff --git a/ent/signature_update.go b/ent/signature_update.go index d9f7775c..9f75f137 100644 --- a/ent/signature_update.go +++ b/ent/signature_update.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/dsse" "github.com/in-toto/archivista/ent/predicate" "github.com/in-toto/archivista/ent/signature" @@ -58,13 +59,13 @@ func (su *SignatureUpdate) SetNillableSignature(s *string) *SignatureUpdate { } // SetDsseID sets the "dsse" edge to the Dsse entity by ID. -func (su *SignatureUpdate) SetDsseID(id int) *SignatureUpdate { +func (su *SignatureUpdate) SetDsseID(id uuid.UUID) *SignatureUpdate { su.mutation.SetDsseID(id) return su } // SetNillableDsseID sets the "dsse" edge to the Dsse entity by ID if the given value is not nil. -func (su *SignatureUpdate) SetNillableDsseID(id *int) *SignatureUpdate { +func (su *SignatureUpdate) SetNillableDsseID(id *uuid.UUID) *SignatureUpdate { if id != nil { su = su.SetDsseID(*id) } @@ -77,14 +78,14 @@ func (su *SignatureUpdate) SetDsse(d *Dsse) *SignatureUpdate { } // AddTimestampIDs adds the "timestamps" edge to the Timestamp entity by IDs. -func (su *SignatureUpdate) AddTimestampIDs(ids ...int) *SignatureUpdate { +func (su *SignatureUpdate) AddTimestampIDs(ids ...uuid.UUID) *SignatureUpdate { su.mutation.AddTimestampIDs(ids...) return su } // AddTimestamps adds the "timestamps" edges to the Timestamp entity. func (su *SignatureUpdate) AddTimestamps(t ...*Timestamp) *SignatureUpdate { - ids := make([]int, len(t)) + ids := make([]uuid.UUID, len(t)) for i := range t { ids[i] = t[i].ID } @@ -109,14 +110,14 @@ func (su *SignatureUpdate) ClearTimestamps() *SignatureUpdate { } // RemoveTimestampIDs removes the "timestamps" edge to Timestamp entities by IDs. -func (su *SignatureUpdate) RemoveTimestampIDs(ids ...int) *SignatureUpdate { +func (su *SignatureUpdate) RemoveTimestampIDs(ids ...uuid.UUID) *SignatureUpdate { su.mutation.RemoveTimestampIDs(ids...) return su } // RemoveTimestamps removes "timestamps" edges to Timestamp entities. func (su *SignatureUpdate) RemoveTimestamps(t ...*Timestamp) *SignatureUpdate { - ids := make([]int, len(t)) + ids := make([]uuid.UUID, len(t)) for i := range t { ids[i] = t[i].ID } @@ -169,7 +170,7 @@ func (su *SignatureUpdate) sqlSave(ctx context.Context) (n int, err error) { if err := su.check(); err != nil { return n, err } - _spec := sqlgraph.NewUpdateSpec(signature.Table, signature.Columns, sqlgraph.NewFieldSpec(signature.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(signature.Table, signature.Columns, sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID)) if ps := su.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -191,7 +192,7 @@ func (su *SignatureUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{signature.DsseColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -204,7 +205,7 @@ func (su *SignatureUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{signature.DsseColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -220,7 +221,7 @@ func (su *SignatureUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{signature.TimestampsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -233,7 +234,7 @@ func (su *SignatureUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{signature.TimestampsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -249,7 +250,7 @@ func (su *SignatureUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{signature.TimestampsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -306,13 +307,13 @@ func (suo *SignatureUpdateOne) SetNillableSignature(s *string) *SignatureUpdateO } // SetDsseID sets the "dsse" edge to the Dsse entity by ID. -func (suo *SignatureUpdateOne) SetDsseID(id int) *SignatureUpdateOne { +func (suo *SignatureUpdateOne) SetDsseID(id uuid.UUID) *SignatureUpdateOne { suo.mutation.SetDsseID(id) return suo } // SetNillableDsseID sets the "dsse" edge to the Dsse entity by ID if the given value is not nil. -func (suo *SignatureUpdateOne) SetNillableDsseID(id *int) *SignatureUpdateOne { +func (suo *SignatureUpdateOne) SetNillableDsseID(id *uuid.UUID) *SignatureUpdateOne { if id != nil { suo = suo.SetDsseID(*id) } @@ -325,14 +326,14 @@ func (suo *SignatureUpdateOne) SetDsse(d *Dsse) *SignatureUpdateOne { } // AddTimestampIDs adds the "timestamps" edge to the Timestamp entity by IDs. -func (suo *SignatureUpdateOne) AddTimestampIDs(ids ...int) *SignatureUpdateOne { +func (suo *SignatureUpdateOne) AddTimestampIDs(ids ...uuid.UUID) *SignatureUpdateOne { suo.mutation.AddTimestampIDs(ids...) return suo } // AddTimestamps adds the "timestamps" edges to the Timestamp entity. func (suo *SignatureUpdateOne) AddTimestamps(t ...*Timestamp) *SignatureUpdateOne { - ids := make([]int, len(t)) + ids := make([]uuid.UUID, len(t)) for i := range t { ids[i] = t[i].ID } @@ -357,14 +358,14 @@ func (suo *SignatureUpdateOne) ClearTimestamps() *SignatureUpdateOne { } // RemoveTimestampIDs removes the "timestamps" edge to Timestamp entities by IDs. -func (suo *SignatureUpdateOne) RemoveTimestampIDs(ids ...int) *SignatureUpdateOne { +func (suo *SignatureUpdateOne) RemoveTimestampIDs(ids ...uuid.UUID) *SignatureUpdateOne { suo.mutation.RemoveTimestampIDs(ids...) return suo } // RemoveTimestamps removes "timestamps" edges to Timestamp entities. func (suo *SignatureUpdateOne) RemoveTimestamps(t ...*Timestamp) *SignatureUpdateOne { - ids := make([]int, len(t)) + ids := make([]uuid.UUID, len(t)) for i := range t { ids[i] = t[i].ID } @@ -430,7 +431,7 @@ func (suo *SignatureUpdateOne) sqlSave(ctx context.Context) (_node *Signature, e if err := suo.check(); err != nil { return _node, err } - _spec := sqlgraph.NewUpdateSpec(signature.Table, signature.Columns, sqlgraph.NewFieldSpec(signature.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(signature.Table, signature.Columns, sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID)) id, ok := suo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Signature.id" for update`)} @@ -469,7 +470,7 @@ func (suo *SignatureUpdateOne) sqlSave(ctx context.Context) (_node *Signature, e Columns: []string{signature.DsseColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -482,7 +483,7 @@ func (suo *SignatureUpdateOne) sqlSave(ctx context.Context) (_node *Signature, e Columns: []string{signature.DsseColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -498,7 +499,7 @@ func (suo *SignatureUpdateOne) sqlSave(ctx context.Context) (_node *Signature, e Columns: []string{signature.TimestampsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -511,7 +512,7 @@ func (suo *SignatureUpdateOne) sqlSave(ctx context.Context) (_node *Signature, e Columns: []string{signature.TimestampsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -527,7 +528,7 @@ func (suo *SignatureUpdateOne) sqlSave(ctx context.Context) (_node *Signature, e Columns: []string{signature.TimestampsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/ent/statement.go b/ent/statement.go index f59a0d80..2a713ed0 100644 --- a/ent/statement.go +++ b/ent/statement.go @@ -8,6 +8,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/attestationpolicy" "github.com/in-toto/archivista/ent/statement" @@ -17,7 +18,7 @@ import ( type Statement struct { config `json:"-"` // ID of the ent. - ID int `json:"id,omitempty"` + ID uuid.UUID `json:"id,omitempty"` // Predicate holds the value of the "predicate" field. Predicate string `json:"predicate,omitempty"` // Edges holds the relations/edges for other nodes in the graph. @@ -91,10 +92,10 @@ func (*Statement) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case statement.FieldID: - values[i] = new(sql.NullInt64) case statement.FieldPredicate: values[i] = new(sql.NullString) + case statement.FieldID: + values[i] = new(uuid.UUID) default: values[i] = new(sql.UnknownType) } @@ -111,11 +112,11 @@ func (s *Statement) assignValues(columns []string, values []any) error { for i := range columns { switch columns[i] { case statement.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + s.ID = *value } - s.ID = int(value.Int64) case statement.FieldPredicate: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field predicate", values[i]) diff --git a/ent/statement/statement.go b/ent/statement/statement.go index 97713e3c..62112092 100644 --- a/ent/statement/statement.go +++ b/ent/statement/statement.go @@ -5,6 +5,7 @@ package statement import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" ) const ( @@ -73,6 +74,8 @@ func ValidColumn(column string) bool { var ( // PredicateValidator is a validator for the "predicate" field. It is called by the builders before save. PredicateValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID ) // OrderOption defines the ordering options for the Statement queries. diff --git a/ent/statement/where.go b/ent/statement/where.go index 50bcb781..cdeaca54 100644 --- a/ent/statement/where.go +++ b/ent/statement/where.go @@ -5,51 +5,52 @@ package statement import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/predicate" ) // ID filters vertices based on their ID field. -func ID(id int) predicate.Statement { +func ID(id uuid.UUID) predicate.Statement { return predicate.Statement(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.Statement { +func IDEQ(id uuid.UUID) predicate.Statement { return predicate.Statement(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.Statement { +func IDNEQ(id uuid.UUID) predicate.Statement { return predicate.Statement(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.Statement { +func IDIn(ids ...uuid.UUID) predicate.Statement { return predicate.Statement(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.Statement { +func IDNotIn(ids ...uuid.UUID) predicate.Statement { return predicate.Statement(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.Statement { +func IDGT(id uuid.UUID) predicate.Statement { return predicate.Statement(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.Statement { +func IDGTE(id uuid.UUID) predicate.Statement { return predicate.Statement(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.Statement { +func IDLT(id uuid.UUID) predicate.Statement { return predicate.Statement(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.Statement { +func IDLTE(id uuid.UUID) predicate.Statement { return predicate.Statement(sql.FieldLTE(FieldID, id)) } diff --git a/ent/statement_create.go b/ent/statement_create.go index 5e3b086f..8fd4ff16 100644 --- a/ent/statement_create.go +++ b/ent/statement_create.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/attestationpolicy" "github.com/in-toto/archivista/ent/dsse" @@ -29,15 +30,29 @@ func (sc *StatementCreate) SetPredicate(s string) *StatementCreate { return sc } +// SetID sets the "id" field. +func (sc *StatementCreate) SetID(u uuid.UUID) *StatementCreate { + sc.mutation.SetID(u) + return sc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (sc *StatementCreate) SetNillableID(u *uuid.UUID) *StatementCreate { + if u != nil { + sc.SetID(*u) + } + return sc +} + // AddSubjectIDs adds the "subjects" edge to the Subject entity by IDs. -func (sc *StatementCreate) AddSubjectIDs(ids ...int) *StatementCreate { +func (sc *StatementCreate) AddSubjectIDs(ids ...uuid.UUID) *StatementCreate { sc.mutation.AddSubjectIDs(ids...) return sc } // AddSubjects adds the "subjects" edges to the Subject entity. func (sc *StatementCreate) AddSubjects(s ...*Subject) *StatementCreate { - ids := make([]int, len(s)) + ids := make([]uuid.UUID, len(s)) for i := range s { ids[i] = s[i].ID } @@ -45,13 +60,13 @@ func (sc *StatementCreate) AddSubjects(s ...*Subject) *StatementCreate { } // SetPolicyID sets the "policy" edge to the AttestationPolicy entity by ID. -func (sc *StatementCreate) SetPolicyID(id int) *StatementCreate { +func (sc *StatementCreate) SetPolicyID(id uuid.UUID) *StatementCreate { sc.mutation.SetPolicyID(id) return sc } // SetNillablePolicyID sets the "policy" edge to the AttestationPolicy entity by ID if the given value is not nil. -func (sc *StatementCreate) SetNillablePolicyID(id *int) *StatementCreate { +func (sc *StatementCreate) SetNillablePolicyID(id *uuid.UUID) *StatementCreate { if id != nil { sc = sc.SetPolicyID(*id) } @@ -64,13 +79,13 @@ func (sc *StatementCreate) SetPolicy(a *AttestationPolicy) *StatementCreate { } // SetAttestationCollectionsID sets the "attestation_collections" edge to the AttestationCollection entity by ID. -func (sc *StatementCreate) SetAttestationCollectionsID(id int) *StatementCreate { +func (sc *StatementCreate) SetAttestationCollectionsID(id uuid.UUID) *StatementCreate { sc.mutation.SetAttestationCollectionsID(id) return sc } // SetNillableAttestationCollectionsID sets the "attestation_collections" edge to the AttestationCollection entity by ID if the given value is not nil. -func (sc *StatementCreate) SetNillableAttestationCollectionsID(id *int) *StatementCreate { +func (sc *StatementCreate) SetNillableAttestationCollectionsID(id *uuid.UUID) *StatementCreate { if id != nil { sc = sc.SetAttestationCollectionsID(*id) } @@ -83,14 +98,14 @@ func (sc *StatementCreate) SetAttestationCollections(a *AttestationCollection) * } // AddDsseIDs adds the "dsse" edge to the Dsse entity by IDs. -func (sc *StatementCreate) AddDsseIDs(ids ...int) *StatementCreate { +func (sc *StatementCreate) AddDsseIDs(ids ...uuid.UUID) *StatementCreate { sc.mutation.AddDsseIDs(ids...) return sc } // AddDsse adds the "dsse" edges to the Dsse entity. func (sc *StatementCreate) AddDsse(d ...*Dsse) *StatementCreate { - ids := make([]int, len(d)) + ids := make([]uuid.UUID, len(d)) for i := range d { ids[i] = d[i].ID } @@ -104,6 +119,7 @@ func (sc *StatementCreate) Mutation() *StatementMutation { // Save creates the Statement in the database. func (sc *StatementCreate) Save(ctx context.Context) (*Statement, error) { + sc.defaults() return withHooks(ctx, sc.sqlSave, sc.mutation, sc.hooks) } @@ -129,6 +145,14 @@ func (sc *StatementCreate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (sc *StatementCreate) defaults() { + if _, ok := sc.mutation.ID(); !ok { + v := statement.DefaultID() + sc.mutation.SetID(v) + } +} + // check runs all checks and user-defined validators on the builder. func (sc *StatementCreate) check() error { if _, ok := sc.mutation.Predicate(); !ok { @@ -153,8 +177,13 @@ func (sc *StatementCreate) sqlSave(ctx context.Context) (*Statement, error) { } return nil, err } - id := _spec.ID.Value.(int64) - _node.ID = int(id) + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } sc.mutation.id = &_node.ID sc.mutation.done = true return _node, nil @@ -163,8 +192,12 @@ func (sc *StatementCreate) sqlSave(ctx context.Context) (*Statement, error) { func (sc *StatementCreate) createSpec() (*Statement, *sqlgraph.CreateSpec) { var ( _node = &Statement{config: sc.config} - _spec = sqlgraph.NewCreateSpec(statement.Table, sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt)) + _spec = sqlgraph.NewCreateSpec(statement.Table, sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID)) ) + if id, ok := sc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } if value, ok := sc.mutation.Predicate(); ok { _spec.SetField(statement.FieldPredicate, field.TypeString, value) _node.Predicate = value @@ -177,7 +210,7 @@ func (sc *StatementCreate) createSpec() (*Statement, *sqlgraph.CreateSpec) { Columns: []string{statement.SubjectsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -193,7 +226,7 @@ func (sc *StatementCreate) createSpec() (*Statement, *sqlgraph.CreateSpec) { Columns: []string{statement.PolicyColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -209,7 +242,7 @@ func (sc *StatementCreate) createSpec() (*Statement, *sqlgraph.CreateSpec) { Columns: []string{statement.AttestationCollectionsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -225,7 +258,7 @@ func (sc *StatementCreate) createSpec() (*Statement, *sqlgraph.CreateSpec) { Columns: []string{statement.DsseColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -254,6 +287,7 @@ func (scb *StatementCreateBulk) Save(ctx context.Context) ([]*Statement, error) for i := range scb.builders { func(i int, root context.Context) { builder := scb.builders[i] + builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*StatementMutation) if !ok { @@ -280,10 +314,6 @@ func (scb *StatementCreateBulk) Save(ctx context.Context) ([]*Statement, error) return nil, err } mutation.id = &nodes[i].ID - if specs[i].ID.Value != nil { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int(id) - } mutation.done = true return nodes[i], nil }) diff --git a/ent/statement_delete.go b/ent/statement_delete.go index ee1ef99b..bac5116d 100644 --- a/ent/statement_delete.go +++ b/ent/statement_delete.go @@ -40,7 +40,7 @@ func (sd *StatementDelete) ExecX(ctx context.Context) int { } func (sd *StatementDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(statement.Table, sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt)) + _spec := sqlgraph.NewDeleteSpec(statement.Table, sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID)) if ps := sd.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { diff --git a/ent/statement_query.go b/ent/statement_query.go index 160a2ac0..520e2928 100644 --- a/ent/statement_query.go +++ b/ent/statement_query.go @@ -11,6 +11,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/attestationpolicy" "github.com/in-toto/archivista/ent/dsse" @@ -182,8 +183,8 @@ func (sq *StatementQuery) FirstX(ctx context.Context) *Statement { // FirstID returns the first Statement ID from the query. // Returns a *NotFoundError when no Statement ID was found. -func (sq *StatementQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -195,7 +196,7 @@ func (sq *StatementQuery) FirstID(ctx context.Context) (id int, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (sq *StatementQuery) FirstIDX(ctx context.Context) int { +func (sq *StatementQuery) FirstIDX(ctx context.Context) uuid.UUID { id, err := sq.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) @@ -233,8 +234,8 @@ func (sq *StatementQuery) OnlyX(ctx context.Context) *Statement { // OnlyID is like Only, but returns the only Statement ID in the query. // Returns a *NotSingularError when more than one Statement ID is found. // Returns a *NotFoundError when no entities are found. -func (sq *StatementQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -250,7 +251,7 @@ func (sq *StatementQuery) OnlyID(ctx context.Context) (id int, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (sq *StatementQuery) OnlyIDX(ctx context.Context) int { +func (sq *StatementQuery) OnlyIDX(ctx context.Context) uuid.UUID { id, err := sq.OnlyID(ctx) if err != nil { panic(err) @@ -278,7 +279,7 @@ func (sq *StatementQuery) AllX(ctx context.Context) []*Statement { } // IDs executes the query and returns a list of Statement IDs. -func (sq *StatementQuery) IDs(ctx context.Context) (ids []int, err error) { +func (sq *StatementQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if sq.ctx.Unique == nil && sq.path != nil { sq.Unique(true) } @@ -290,7 +291,7 @@ func (sq *StatementQuery) IDs(ctx context.Context) (ids []int, err error) { } // IDsX is like IDs, but panics if an error occurs. -func (sq *StatementQuery) IDsX(ctx context.Context) []int { +func (sq *StatementQuery) IDsX(ctx context.Context) []uuid.UUID { ids, err := sq.IDs(ctx) if err != nil { panic(err) @@ -560,7 +561,7 @@ func (sq *StatementQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*St func (sq *StatementQuery) loadSubjects(ctx context.Context, query *SubjectQuery, nodes []*Statement, init func(*Statement), assign func(*Statement, *Subject)) error { fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int]*Statement) + nodeids := make(map[uuid.UUID]*Statement) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] @@ -591,7 +592,7 @@ func (sq *StatementQuery) loadSubjects(ctx context.Context, query *SubjectQuery, } func (sq *StatementQuery) loadPolicy(ctx context.Context, query *AttestationPolicyQuery, nodes []*Statement, init func(*Statement), assign func(*Statement, *AttestationPolicy)) error { fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int]*Statement) + nodeids := make(map[uuid.UUID]*Statement) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] @@ -619,7 +620,7 @@ func (sq *StatementQuery) loadPolicy(ctx context.Context, query *AttestationPoli } func (sq *StatementQuery) loadAttestationCollections(ctx context.Context, query *AttestationCollectionQuery, nodes []*Statement, init func(*Statement), assign func(*Statement, *AttestationCollection)) error { fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int]*Statement) + nodeids := make(map[uuid.UUID]*Statement) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] @@ -647,7 +648,7 @@ func (sq *StatementQuery) loadAttestationCollections(ctx context.Context, query } func (sq *StatementQuery) loadDsse(ctx context.Context, query *DsseQuery, nodes []*Statement, init func(*Statement), assign func(*Statement, *Dsse)) error { fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int]*Statement) + nodeids := make(map[uuid.UUID]*Statement) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] @@ -690,7 +691,7 @@ func (sq *StatementQuery) sqlCount(ctx context.Context) (int, error) { } func (sq *StatementQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(statement.Table, statement.Columns, sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt)) + _spec := sqlgraph.NewQuerySpec(statement.Table, statement.Columns, sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID)) _spec.From = sq.sql if unique := sq.ctx.Unique; unique != nil { _spec.Unique = *unique diff --git a/ent/statement_update.go b/ent/statement_update.go index befaba69..8a4851bc 100644 --- a/ent/statement_update.go +++ b/ent/statement_update.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/attestationcollection" "github.com/in-toto/archivista/ent/attestationpolicy" "github.com/in-toto/archivista/ent/dsse" @@ -46,14 +47,14 @@ func (su *StatementUpdate) SetNillablePredicate(s *string) *StatementUpdate { } // AddSubjectIDs adds the "subjects" edge to the Subject entity by IDs. -func (su *StatementUpdate) AddSubjectIDs(ids ...int) *StatementUpdate { +func (su *StatementUpdate) AddSubjectIDs(ids ...uuid.UUID) *StatementUpdate { su.mutation.AddSubjectIDs(ids...) return su } // AddSubjects adds the "subjects" edges to the Subject entity. func (su *StatementUpdate) AddSubjects(s ...*Subject) *StatementUpdate { - ids := make([]int, len(s)) + ids := make([]uuid.UUID, len(s)) for i := range s { ids[i] = s[i].ID } @@ -61,13 +62,13 @@ func (su *StatementUpdate) AddSubjects(s ...*Subject) *StatementUpdate { } // SetPolicyID sets the "policy" edge to the AttestationPolicy entity by ID. -func (su *StatementUpdate) SetPolicyID(id int) *StatementUpdate { +func (su *StatementUpdate) SetPolicyID(id uuid.UUID) *StatementUpdate { su.mutation.SetPolicyID(id) return su } // SetNillablePolicyID sets the "policy" edge to the AttestationPolicy entity by ID if the given value is not nil. -func (su *StatementUpdate) SetNillablePolicyID(id *int) *StatementUpdate { +func (su *StatementUpdate) SetNillablePolicyID(id *uuid.UUID) *StatementUpdate { if id != nil { su = su.SetPolicyID(*id) } @@ -80,13 +81,13 @@ func (su *StatementUpdate) SetPolicy(a *AttestationPolicy) *StatementUpdate { } // SetAttestationCollectionsID sets the "attestation_collections" edge to the AttestationCollection entity by ID. -func (su *StatementUpdate) SetAttestationCollectionsID(id int) *StatementUpdate { +func (su *StatementUpdate) SetAttestationCollectionsID(id uuid.UUID) *StatementUpdate { su.mutation.SetAttestationCollectionsID(id) return su } // SetNillableAttestationCollectionsID sets the "attestation_collections" edge to the AttestationCollection entity by ID if the given value is not nil. -func (su *StatementUpdate) SetNillableAttestationCollectionsID(id *int) *StatementUpdate { +func (su *StatementUpdate) SetNillableAttestationCollectionsID(id *uuid.UUID) *StatementUpdate { if id != nil { su = su.SetAttestationCollectionsID(*id) } @@ -99,14 +100,14 @@ func (su *StatementUpdate) SetAttestationCollections(a *AttestationCollection) * } // AddDsseIDs adds the "dsse" edge to the Dsse entity by IDs. -func (su *StatementUpdate) AddDsseIDs(ids ...int) *StatementUpdate { +func (su *StatementUpdate) AddDsseIDs(ids ...uuid.UUID) *StatementUpdate { su.mutation.AddDsseIDs(ids...) return su } // AddDsse adds the "dsse" edges to the Dsse entity. func (su *StatementUpdate) AddDsse(d ...*Dsse) *StatementUpdate { - ids := make([]int, len(d)) + ids := make([]uuid.UUID, len(d)) for i := range d { ids[i] = d[i].ID } @@ -125,14 +126,14 @@ func (su *StatementUpdate) ClearSubjects() *StatementUpdate { } // RemoveSubjectIDs removes the "subjects" edge to Subject entities by IDs. -func (su *StatementUpdate) RemoveSubjectIDs(ids ...int) *StatementUpdate { +func (su *StatementUpdate) RemoveSubjectIDs(ids ...uuid.UUID) *StatementUpdate { su.mutation.RemoveSubjectIDs(ids...) return su } // RemoveSubjects removes "subjects" edges to Subject entities. func (su *StatementUpdate) RemoveSubjects(s ...*Subject) *StatementUpdate { - ids := make([]int, len(s)) + ids := make([]uuid.UUID, len(s)) for i := range s { ids[i] = s[i].ID } @@ -158,14 +159,14 @@ func (su *StatementUpdate) ClearDsse() *StatementUpdate { } // RemoveDsseIDs removes the "dsse" edge to Dsse entities by IDs. -func (su *StatementUpdate) RemoveDsseIDs(ids ...int) *StatementUpdate { +func (su *StatementUpdate) RemoveDsseIDs(ids ...uuid.UUID) *StatementUpdate { su.mutation.RemoveDsseIDs(ids...) return su } // RemoveDsse removes "dsse" edges to Dsse entities. func (su *StatementUpdate) RemoveDsse(d ...*Dsse) *StatementUpdate { - ids := make([]int, len(d)) + ids := make([]uuid.UUID, len(d)) for i := range d { ids[i] = d[i].ID } @@ -213,7 +214,7 @@ func (su *StatementUpdate) sqlSave(ctx context.Context) (n int, err error) { if err := su.check(); err != nil { return n, err } - _spec := sqlgraph.NewUpdateSpec(statement.Table, statement.Columns, sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(statement.Table, statement.Columns, sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID)) if ps := su.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -232,7 +233,7 @@ func (su *StatementUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{statement.SubjectsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -245,7 +246,7 @@ func (su *StatementUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{statement.SubjectsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -261,7 +262,7 @@ func (su *StatementUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{statement.SubjectsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -277,7 +278,7 @@ func (su *StatementUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{statement.PolicyColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -290,7 +291,7 @@ func (su *StatementUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{statement.PolicyColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -306,7 +307,7 @@ func (su *StatementUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{statement.AttestationCollectionsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -319,7 +320,7 @@ func (su *StatementUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{statement.AttestationCollectionsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -335,7 +336,7 @@ func (su *StatementUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{statement.DsseColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -348,7 +349,7 @@ func (su *StatementUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{statement.DsseColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -364,7 +365,7 @@ func (su *StatementUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{statement.DsseColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -407,14 +408,14 @@ func (suo *StatementUpdateOne) SetNillablePredicate(s *string) *StatementUpdateO } // AddSubjectIDs adds the "subjects" edge to the Subject entity by IDs. -func (suo *StatementUpdateOne) AddSubjectIDs(ids ...int) *StatementUpdateOne { +func (suo *StatementUpdateOne) AddSubjectIDs(ids ...uuid.UUID) *StatementUpdateOne { suo.mutation.AddSubjectIDs(ids...) return suo } // AddSubjects adds the "subjects" edges to the Subject entity. func (suo *StatementUpdateOne) AddSubjects(s ...*Subject) *StatementUpdateOne { - ids := make([]int, len(s)) + ids := make([]uuid.UUID, len(s)) for i := range s { ids[i] = s[i].ID } @@ -422,13 +423,13 @@ func (suo *StatementUpdateOne) AddSubjects(s ...*Subject) *StatementUpdateOne { } // SetPolicyID sets the "policy" edge to the AttestationPolicy entity by ID. -func (suo *StatementUpdateOne) SetPolicyID(id int) *StatementUpdateOne { +func (suo *StatementUpdateOne) SetPolicyID(id uuid.UUID) *StatementUpdateOne { suo.mutation.SetPolicyID(id) return suo } // SetNillablePolicyID sets the "policy" edge to the AttestationPolicy entity by ID if the given value is not nil. -func (suo *StatementUpdateOne) SetNillablePolicyID(id *int) *StatementUpdateOne { +func (suo *StatementUpdateOne) SetNillablePolicyID(id *uuid.UUID) *StatementUpdateOne { if id != nil { suo = suo.SetPolicyID(*id) } @@ -441,13 +442,13 @@ func (suo *StatementUpdateOne) SetPolicy(a *AttestationPolicy) *StatementUpdateO } // SetAttestationCollectionsID sets the "attestation_collections" edge to the AttestationCollection entity by ID. -func (suo *StatementUpdateOne) SetAttestationCollectionsID(id int) *StatementUpdateOne { +func (suo *StatementUpdateOne) SetAttestationCollectionsID(id uuid.UUID) *StatementUpdateOne { suo.mutation.SetAttestationCollectionsID(id) return suo } // SetNillableAttestationCollectionsID sets the "attestation_collections" edge to the AttestationCollection entity by ID if the given value is not nil. -func (suo *StatementUpdateOne) SetNillableAttestationCollectionsID(id *int) *StatementUpdateOne { +func (suo *StatementUpdateOne) SetNillableAttestationCollectionsID(id *uuid.UUID) *StatementUpdateOne { if id != nil { suo = suo.SetAttestationCollectionsID(*id) } @@ -460,14 +461,14 @@ func (suo *StatementUpdateOne) SetAttestationCollections(a *AttestationCollectio } // AddDsseIDs adds the "dsse" edge to the Dsse entity by IDs. -func (suo *StatementUpdateOne) AddDsseIDs(ids ...int) *StatementUpdateOne { +func (suo *StatementUpdateOne) AddDsseIDs(ids ...uuid.UUID) *StatementUpdateOne { suo.mutation.AddDsseIDs(ids...) return suo } // AddDsse adds the "dsse" edges to the Dsse entity. func (suo *StatementUpdateOne) AddDsse(d ...*Dsse) *StatementUpdateOne { - ids := make([]int, len(d)) + ids := make([]uuid.UUID, len(d)) for i := range d { ids[i] = d[i].ID } @@ -486,14 +487,14 @@ func (suo *StatementUpdateOne) ClearSubjects() *StatementUpdateOne { } // RemoveSubjectIDs removes the "subjects" edge to Subject entities by IDs. -func (suo *StatementUpdateOne) RemoveSubjectIDs(ids ...int) *StatementUpdateOne { +func (suo *StatementUpdateOne) RemoveSubjectIDs(ids ...uuid.UUID) *StatementUpdateOne { suo.mutation.RemoveSubjectIDs(ids...) return suo } // RemoveSubjects removes "subjects" edges to Subject entities. func (suo *StatementUpdateOne) RemoveSubjects(s ...*Subject) *StatementUpdateOne { - ids := make([]int, len(s)) + ids := make([]uuid.UUID, len(s)) for i := range s { ids[i] = s[i].ID } @@ -519,14 +520,14 @@ func (suo *StatementUpdateOne) ClearDsse() *StatementUpdateOne { } // RemoveDsseIDs removes the "dsse" edge to Dsse entities by IDs. -func (suo *StatementUpdateOne) RemoveDsseIDs(ids ...int) *StatementUpdateOne { +func (suo *StatementUpdateOne) RemoveDsseIDs(ids ...uuid.UUID) *StatementUpdateOne { suo.mutation.RemoveDsseIDs(ids...) return suo } // RemoveDsse removes "dsse" edges to Dsse entities. func (suo *StatementUpdateOne) RemoveDsse(d ...*Dsse) *StatementUpdateOne { - ids := make([]int, len(d)) + ids := make([]uuid.UUID, len(d)) for i := range d { ids[i] = d[i].ID } @@ -587,7 +588,7 @@ func (suo *StatementUpdateOne) sqlSave(ctx context.Context) (_node *Statement, e if err := suo.check(); err != nil { return _node, err } - _spec := sqlgraph.NewUpdateSpec(statement.Table, statement.Columns, sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(statement.Table, statement.Columns, sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID)) id, ok := suo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Statement.id" for update`)} @@ -623,7 +624,7 @@ func (suo *StatementUpdateOne) sqlSave(ctx context.Context) (_node *Statement, e Columns: []string{statement.SubjectsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -636,7 +637,7 @@ func (suo *StatementUpdateOne) sqlSave(ctx context.Context) (_node *Statement, e Columns: []string{statement.SubjectsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -652,7 +653,7 @@ func (suo *StatementUpdateOne) sqlSave(ctx context.Context) (_node *Statement, e Columns: []string{statement.SubjectsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -668,7 +669,7 @@ func (suo *StatementUpdateOne) sqlSave(ctx context.Context) (_node *Statement, e Columns: []string{statement.PolicyColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -681,7 +682,7 @@ func (suo *StatementUpdateOne) sqlSave(ctx context.Context) (_node *Statement, e Columns: []string{statement.PolicyColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestationpolicy.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -697,7 +698,7 @@ func (suo *StatementUpdateOne) sqlSave(ctx context.Context) (_node *Statement, e Columns: []string{statement.AttestationCollectionsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -710,7 +711,7 @@ func (suo *StatementUpdateOne) sqlSave(ctx context.Context) (_node *Statement, e Columns: []string{statement.AttestationCollectionsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(attestationcollection.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -726,7 +727,7 @@ func (suo *StatementUpdateOne) sqlSave(ctx context.Context) (_node *Statement, e Columns: []string{statement.DsseColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -739,7 +740,7 @@ func (suo *StatementUpdateOne) sqlSave(ctx context.Context) (_node *Statement, e Columns: []string{statement.DsseColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -755,7 +756,7 @@ func (suo *StatementUpdateOne) sqlSave(ctx context.Context) (_node *Statement, e Columns: []string{statement.DsseColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(dsse.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/ent/subject.go b/ent/subject.go index cfc92bca..74c4e87f 100644 --- a/ent/subject.go +++ b/ent/subject.go @@ -8,6 +8,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/statement" "github.com/in-toto/archivista/ent/subject" ) @@ -16,13 +17,13 @@ import ( type Subject struct { config `json:"-"` // ID of the ent. - ID int `json:"id,omitempty"` + ID uuid.UUID `json:"id,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the SubjectQuery when eager-loading is set. Edges SubjectEdges `json:"edges"` - statement_subjects *int + statement_subjects *uuid.UUID selectValues sql.SelectValues } @@ -66,12 +67,12 @@ func (*Subject) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case subject.FieldID: - values[i] = new(sql.NullInt64) case subject.FieldName: values[i] = new(sql.NullString) + case subject.FieldID: + values[i] = new(uuid.UUID) case subject.ForeignKeys[0]: // statement_subjects - values[i] = new(sql.NullInt64) + values[i] = &sql.NullScanner{S: new(uuid.UUID)} default: values[i] = new(sql.UnknownType) } @@ -88,11 +89,11 @@ func (s *Subject) assignValues(columns []string, values []any) error { for i := range columns { switch columns[i] { case subject.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + s.ID = *value } - s.ID = int(value.Int64) case subject.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) @@ -100,11 +101,11 @@ func (s *Subject) assignValues(columns []string, values []any) error { s.Name = value.String } case subject.ForeignKeys[0]: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field statement_subjects", value) + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field statement_subjects", values[i]) } else if value.Valid { - s.statement_subjects = new(int) - *s.statement_subjects = int(value.Int64) + s.statement_subjects = new(uuid.UUID) + *s.statement_subjects = *value.S.(*uuid.UUID) } default: s.selectValues.Set(columns[i], values[i]) diff --git a/ent/subject/subject.go b/ent/subject/subject.go index ec6aa416..2469abf3 100644 --- a/ent/subject/subject.go +++ b/ent/subject/subject.go @@ -5,6 +5,7 @@ package subject import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" ) const ( @@ -66,6 +67,8 @@ func ValidColumn(column string) bool { var ( // NameValidator is a validator for the "name" field. It is called by the builders before save. NameValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID ) // OrderOption defines the ordering options for the Subject queries. diff --git a/ent/subject/where.go b/ent/subject/where.go index eecf8b66..5ce4210b 100644 --- a/ent/subject/where.go +++ b/ent/subject/where.go @@ -5,51 +5,52 @@ package subject import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/predicate" ) // ID filters vertices based on their ID field. -func ID(id int) predicate.Subject { +func ID(id uuid.UUID) predicate.Subject { return predicate.Subject(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.Subject { +func IDEQ(id uuid.UUID) predicate.Subject { return predicate.Subject(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.Subject { +func IDNEQ(id uuid.UUID) predicate.Subject { return predicate.Subject(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.Subject { +func IDIn(ids ...uuid.UUID) predicate.Subject { return predicate.Subject(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.Subject { +func IDNotIn(ids ...uuid.UUID) predicate.Subject { return predicate.Subject(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.Subject { +func IDGT(id uuid.UUID) predicate.Subject { return predicate.Subject(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.Subject { +func IDGTE(id uuid.UUID) predicate.Subject { return predicate.Subject(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.Subject { +func IDLT(id uuid.UUID) predicate.Subject { return predicate.Subject(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.Subject { +func IDLTE(id uuid.UUID) predicate.Subject { return predicate.Subject(sql.FieldLTE(FieldID, id)) } diff --git a/ent/subject_create.go b/ent/subject_create.go index 5f42df41..66113794 100644 --- a/ent/subject_create.go +++ b/ent/subject_create.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/statement" "github.com/in-toto/archivista/ent/subject" "github.com/in-toto/archivista/ent/subjectdigest" @@ -27,15 +28,29 @@ func (sc *SubjectCreate) SetName(s string) *SubjectCreate { return sc } +// SetID sets the "id" field. +func (sc *SubjectCreate) SetID(u uuid.UUID) *SubjectCreate { + sc.mutation.SetID(u) + return sc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (sc *SubjectCreate) SetNillableID(u *uuid.UUID) *SubjectCreate { + if u != nil { + sc.SetID(*u) + } + return sc +} + // AddSubjectDigestIDs adds the "subject_digests" edge to the SubjectDigest entity by IDs. -func (sc *SubjectCreate) AddSubjectDigestIDs(ids ...int) *SubjectCreate { +func (sc *SubjectCreate) AddSubjectDigestIDs(ids ...uuid.UUID) *SubjectCreate { sc.mutation.AddSubjectDigestIDs(ids...) return sc } // AddSubjectDigests adds the "subject_digests" edges to the SubjectDigest entity. func (sc *SubjectCreate) AddSubjectDigests(s ...*SubjectDigest) *SubjectCreate { - ids := make([]int, len(s)) + ids := make([]uuid.UUID, len(s)) for i := range s { ids[i] = s[i].ID } @@ -43,13 +58,13 @@ func (sc *SubjectCreate) AddSubjectDigests(s ...*SubjectDigest) *SubjectCreate { } // SetStatementID sets the "statement" edge to the Statement entity by ID. -func (sc *SubjectCreate) SetStatementID(id int) *SubjectCreate { +func (sc *SubjectCreate) SetStatementID(id uuid.UUID) *SubjectCreate { sc.mutation.SetStatementID(id) return sc } // SetNillableStatementID sets the "statement" edge to the Statement entity by ID if the given value is not nil. -func (sc *SubjectCreate) SetNillableStatementID(id *int) *SubjectCreate { +func (sc *SubjectCreate) SetNillableStatementID(id *uuid.UUID) *SubjectCreate { if id != nil { sc = sc.SetStatementID(*id) } @@ -68,6 +83,7 @@ func (sc *SubjectCreate) Mutation() *SubjectMutation { // Save creates the Subject in the database. func (sc *SubjectCreate) Save(ctx context.Context) (*Subject, error) { + sc.defaults() return withHooks(ctx, sc.sqlSave, sc.mutation, sc.hooks) } @@ -93,6 +109,14 @@ func (sc *SubjectCreate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (sc *SubjectCreate) defaults() { + if _, ok := sc.mutation.ID(); !ok { + v := subject.DefaultID() + sc.mutation.SetID(v) + } +} + // check runs all checks and user-defined validators on the builder. func (sc *SubjectCreate) check() error { if _, ok := sc.mutation.Name(); !ok { @@ -117,8 +141,13 @@ func (sc *SubjectCreate) sqlSave(ctx context.Context) (*Subject, error) { } return nil, err } - id := _spec.ID.Value.(int64) - _node.ID = int(id) + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } sc.mutation.id = &_node.ID sc.mutation.done = true return _node, nil @@ -127,8 +156,12 @@ func (sc *SubjectCreate) sqlSave(ctx context.Context) (*Subject, error) { func (sc *SubjectCreate) createSpec() (*Subject, *sqlgraph.CreateSpec) { var ( _node = &Subject{config: sc.config} - _spec = sqlgraph.NewCreateSpec(subject.Table, sqlgraph.NewFieldSpec(subject.FieldID, field.TypeInt)) + _spec = sqlgraph.NewCreateSpec(subject.Table, sqlgraph.NewFieldSpec(subject.FieldID, field.TypeUUID)) ) + if id, ok := sc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } if value, ok := sc.mutation.Name(); ok { _spec.SetField(subject.FieldName, field.TypeString, value) _node.Name = value @@ -141,7 +174,7 @@ func (sc *SubjectCreate) createSpec() (*Subject, *sqlgraph.CreateSpec) { Columns: []string{subject.SubjectDigestsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -157,7 +190,7 @@ func (sc *SubjectCreate) createSpec() (*Subject, *sqlgraph.CreateSpec) { Columns: []string{subject.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -187,6 +220,7 @@ func (scb *SubjectCreateBulk) Save(ctx context.Context) ([]*Subject, error) { for i := range scb.builders { func(i int, root context.Context) { builder := scb.builders[i] + builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*SubjectMutation) if !ok { @@ -213,10 +247,6 @@ func (scb *SubjectCreateBulk) Save(ctx context.Context) ([]*Subject, error) { return nil, err } mutation.id = &nodes[i].ID - if specs[i].ID.Value != nil { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int(id) - } mutation.done = true return nodes[i], nil }) diff --git a/ent/subject_delete.go b/ent/subject_delete.go index fac5965e..096918e0 100644 --- a/ent/subject_delete.go +++ b/ent/subject_delete.go @@ -40,7 +40,7 @@ func (sd *SubjectDelete) ExecX(ctx context.Context) int { } func (sd *SubjectDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(subject.Table, sqlgraph.NewFieldSpec(subject.FieldID, field.TypeInt)) + _spec := sqlgraph.NewDeleteSpec(subject.Table, sqlgraph.NewFieldSpec(subject.FieldID, field.TypeUUID)) if ps := sd.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { diff --git a/ent/subject_query.go b/ent/subject_query.go index e04d1879..3d180109 100644 --- a/ent/subject_query.go +++ b/ent/subject_query.go @@ -11,6 +11,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/predicate" "github.com/in-toto/archivista/ent/statement" "github.com/in-toto/archivista/ent/subject" @@ -134,8 +135,8 @@ func (sq *SubjectQuery) FirstX(ctx context.Context) *Subject { // FirstID returns the first Subject ID from the query. // Returns a *NotFoundError when no Subject ID was found. -func (sq *SubjectQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -147,7 +148,7 @@ func (sq *SubjectQuery) FirstID(ctx context.Context) (id int, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (sq *SubjectQuery) FirstIDX(ctx context.Context) int { +func (sq *SubjectQuery) FirstIDX(ctx context.Context) uuid.UUID { id, err := sq.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) @@ -185,8 +186,8 @@ func (sq *SubjectQuery) OnlyX(ctx context.Context) *Subject { // OnlyID is like Only, but returns the only Subject ID in the query. // Returns a *NotSingularError when more than one Subject ID is found. // Returns a *NotFoundError when no entities are found. -func (sq *SubjectQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -202,7 +203,7 @@ func (sq *SubjectQuery) OnlyID(ctx context.Context) (id int, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (sq *SubjectQuery) OnlyIDX(ctx context.Context) int { +func (sq *SubjectQuery) OnlyIDX(ctx context.Context) uuid.UUID { id, err := sq.OnlyID(ctx) if err != nil { panic(err) @@ -230,7 +231,7 @@ func (sq *SubjectQuery) AllX(ctx context.Context) []*Subject { } // IDs executes the query and returns a list of Subject IDs. -func (sq *SubjectQuery) IDs(ctx context.Context) (ids []int, err error) { +func (sq *SubjectQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if sq.ctx.Unique == nil && sq.path != nil { sq.Unique(true) } @@ -242,7 +243,7 @@ func (sq *SubjectQuery) IDs(ctx context.Context) (ids []int, err error) { } // IDsX is like IDs, but panics if an error occurs. -func (sq *SubjectQuery) IDsX(ctx context.Context) []int { +func (sq *SubjectQuery) IDsX(ctx context.Context) []uuid.UUID { ids, err := sq.IDs(ctx) if err != nil { panic(err) @@ -473,7 +474,7 @@ func (sq *SubjectQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Subj func (sq *SubjectQuery) loadSubjectDigests(ctx context.Context, query *SubjectDigestQuery, nodes []*Subject, init func(*Subject), assign func(*Subject, *SubjectDigest)) error { fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int]*Subject) + nodeids := make(map[uuid.UUID]*Subject) for i := range nodes { fks = append(fks, nodes[i].ID) nodeids[nodes[i].ID] = nodes[i] @@ -503,8 +504,8 @@ func (sq *SubjectQuery) loadSubjectDigests(ctx context.Context, query *SubjectDi return nil } func (sq *SubjectQuery) loadStatement(ctx context.Context, query *StatementQuery, nodes []*Subject, init func(*Subject), assign func(*Subject, *Statement)) error { - ids := make([]int, 0, len(nodes)) - nodeids := make(map[int][]*Subject) + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*Subject) for i := range nodes { if nodes[i].statement_subjects == nil { continue @@ -548,7 +549,7 @@ func (sq *SubjectQuery) sqlCount(ctx context.Context) (int, error) { } func (sq *SubjectQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(subject.Table, subject.Columns, sqlgraph.NewFieldSpec(subject.FieldID, field.TypeInt)) + _spec := sqlgraph.NewQuerySpec(subject.Table, subject.Columns, sqlgraph.NewFieldSpec(subject.FieldID, field.TypeUUID)) _spec.From = sq.sql if unique := sq.ctx.Unique; unique != nil { _spec.Unique = *unique diff --git a/ent/subject_update.go b/ent/subject_update.go index 8cb8f882..958ce466 100644 --- a/ent/subject_update.go +++ b/ent/subject_update.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/predicate" "github.com/in-toto/archivista/ent/statement" "github.com/in-toto/archivista/ent/subject" @@ -44,14 +45,14 @@ func (su *SubjectUpdate) SetNillableName(s *string) *SubjectUpdate { } // AddSubjectDigestIDs adds the "subject_digests" edge to the SubjectDigest entity by IDs. -func (su *SubjectUpdate) AddSubjectDigestIDs(ids ...int) *SubjectUpdate { +func (su *SubjectUpdate) AddSubjectDigestIDs(ids ...uuid.UUID) *SubjectUpdate { su.mutation.AddSubjectDigestIDs(ids...) return su } // AddSubjectDigests adds the "subject_digests" edges to the SubjectDigest entity. func (su *SubjectUpdate) AddSubjectDigests(s ...*SubjectDigest) *SubjectUpdate { - ids := make([]int, len(s)) + ids := make([]uuid.UUID, len(s)) for i := range s { ids[i] = s[i].ID } @@ -59,13 +60,13 @@ func (su *SubjectUpdate) AddSubjectDigests(s ...*SubjectDigest) *SubjectUpdate { } // SetStatementID sets the "statement" edge to the Statement entity by ID. -func (su *SubjectUpdate) SetStatementID(id int) *SubjectUpdate { +func (su *SubjectUpdate) SetStatementID(id uuid.UUID) *SubjectUpdate { su.mutation.SetStatementID(id) return su } // SetNillableStatementID sets the "statement" edge to the Statement entity by ID if the given value is not nil. -func (su *SubjectUpdate) SetNillableStatementID(id *int) *SubjectUpdate { +func (su *SubjectUpdate) SetNillableStatementID(id *uuid.UUID) *SubjectUpdate { if id != nil { su = su.SetStatementID(*id) } @@ -89,14 +90,14 @@ func (su *SubjectUpdate) ClearSubjectDigests() *SubjectUpdate { } // RemoveSubjectDigestIDs removes the "subject_digests" edge to SubjectDigest entities by IDs. -func (su *SubjectUpdate) RemoveSubjectDigestIDs(ids ...int) *SubjectUpdate { +func (su *SubjectUpdate) RemoveSubjectDigestIDs(ids ...uuid.UUID) *SubjectUpdate { su.mutation.RemoveSubjectDigestIDs(ids...) return su } // RemoveSubjectDigests removes "subject_digests" edges to SubjectDigest entities. func (su *SubjectUpdate) RemoveSubjectDigests(s ...*SubjectDigest) *SubjectUpdate { - ids := make([]int, len(s)) + ids := make([]uuid.UUID, len(s)) for i := range s { ids[i] = s[i].ID } @@ -150,7 +151,7 @@ func (su *SubjectUpdate) sqlSave(ctx context.Context) (n int, err error) { if err := su.check(); err != nil { return n, err } - _spec := sqlgraph.NewUpdateSpec(subject.Table, subject.Columns, sqlgraph.NewFieldSpec(subject.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(subject.Table, subject.Columns, sqlgraph.NewFieldSpec(subject.FieldID, field.TypeUUID)) if ps := su.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -169,7 +170,7 @@ func (su *SubjectUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{subject.SubjectDigestsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -182,7 +183,7 @@ func (su *SubjectUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{subject.SubjectDigestsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -198,7 +199,7 @@ func (su *SubjectUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{subject.SubjectDigestsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -214,7 +215,7 @@ func (su *SubjectUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{subject.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -227,7 +228,7 @@ func (su *SubjectUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{subject.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -270,14 +271,14 @@ func (suo *SubjectUpdateOne) SetNillableName(s *string) *SubjectUpdateOne { } // AddSubjectDigestIDs adds the "subject_digests" edge to the SubjectDigest entity by IDs. -func (suo *SubjectUpdateOne) AddSubjectDigestIDs(ids ...int) *SubjectUpdateOne { +func (suo *SubjectUpdateOne) AddSubjectDigestIDs(ids ...uuid.UUID) *SubjectUpdateOne { suo.mutation.AddSubjectDigestIDs(ids...) return suo } // AddSubjectDigests adds the "subject_digests" edges to the SubjectDigest entity. func (suo *SubjectUpdateOne) AddSubjectDigests(s ...*SubjectDigest) *SubjectUpdateOne { - ids := make([]int, len(s)) + ids := make([]uuid.UUID, len(s)) for i := range s { ids[i] = s[i].ID } @@ -285,13 +286,13 @@ func (suo *SubjectUpdateOne) AddSubjectDigests(s ...*SubjectDigest) *SubjectUpda } // SetStatementID sets the "statement" edge to the Statement entity by ID. -func (suo *SubjectUpdateOne) SetStatementID(id int) *SubjectUpdateOne { +func (suo *SubjectUpdateOne) SetStatementID(id uuid.UUID) *SubjectUpdateOne { suo.mutation.SetStatementID(id) return suo } // SetNillableStatementID sets the "statement" edge to the Statement entity by ID if the given value is not nil. -func (suo *SubjectUpdateOne) SetNillableStatementID(id *int) *SubjectUpdateOne { +func (suo *SubjectUpdateOne) SetNillableStatementID(id *uuid.UUID) *SubjectUpdateOne { if id != nil { suo = suo.SetStatementID(*id) } @@ -315,14 +316,14 @@ func (suo *SubjectUpdateOne) ClearSubjectDigests() *SubjectUpdateOne { } // RemoveSubjectDigestIDs removes the "subject_digests" edge to SubjectDigest entities by IDs. -func (suo *SubjectUpdateOne) RemoveSubjectDigestIDs(ids ...int) *SubjectUpdateOne { +func (suo *SubjectUpdateOne) RemoveSubjectDigestIDs(ids ...uuid.UUID) *SubjectUpdateOne { suo.mutation.RemoveSubjectDigestIDs(ids...) return suo } // RemoveSubjectDigests removes "subject_digests" edges to SubjectDigest entities. func (suo *SubjectUpdateOne) RemoveSubjectDigests(s ...*SubjectDigest) *SubjectUpdateOne { - ids := make([]int, len(s)) + ids := make([]uuid.UUID, len(s)) for i := range s { ids[i] = s[i].ID } @@ -389,7 +390,7 @@ func (suo *SubjectUpdateOne) sqlSave(ctx context.Context) (_node *Subject, err e if err := suo.check(); err != nil { return _node, err } - _spec := sqlgraph.NewUpdateSpec(subject.Table, subject.Columns, sqlgraph.NewFieldSpec(subject.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(subject.Table, subject.Columns, sqlgraph.NewFieldSpec(subject.FieldID, field.TypeUUID)) id, ok := suo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Subject.id" for update`)} @@ -425,7 +426,7 @@ func (suo *SubjectUpdateOne) sqlSave(ctx context.Context) (_node *Subject, err e Columns: []string{subject.SubjectDigestsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -438,7 +439,7 @@ func (suo *SubjectUpdateOne) sqlSave(ctx context.Context) (_node *Subject, err e Columns: []string{subject.SubjectDigestsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -454,7 +455,7 @@ func (suo *SubjectUpdateOne) sqlSave(ctx context.Context) (_node *Subject, err e Columns: []string{subject.SubjectDigestsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -470,7 +471,7 @@ func (suo *SubjectUpdateOne) sqlSave(ctx context.Context) (_node *Subject, err e Columns: []string{subject.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -483,7 +484,7 @@ func (suo *SubjectUpdateOne) sqlSave(ctx context.Context) (_node *Subject, err e Columns: []string{subject.StatementColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(statement.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/ent/subjectdigest.go b/ent/subjectdigest.go index 0c778149..b7aecbda 100644 --- a/ent/subjectdigest.go +++ b/ent/subjectdigest.go @@ -8,6 +8,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/subject" "github.com/in-toto/archivista/ent/subjectdigest" ) @@ -16,7 +17,7 @@ import ( type SubjectDigest struct { config `json:"-"` // ID of the ent. - ID int `json:"id,omitempty"` + ID uuid.UUID `json:"id,omitempty"` // Algorithm holds the value of the "algorithm" field. Algorithm string `json:"algorithm,omitempty"` // Value holds the value of the "value" field. @@ -24,7 +25,7 @@ type SubjectDigest struct { // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the SubjectDigestQuery when eager-loading is set. Edges SubjectDigestEdges `json:"edges"` - subject_subject_digests *int + subject_subject_digests *uuid.UUID selectValues sql.SelectValues } @@ -55,12 +56,12 @@ func (*SubjectDigest) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case subjectdigest.FieldID: - values[i] = new(sql.NullInt64) case subjectdigest.FieldAlgorithm, subjectdigest.FieldValue: values[i] = new(sql.NullString) + case subjectdigest.FieldID: + values[i] = new(uuid.UUID) case subjectdigest.ForeignKeys[0]: // subject_subject_digests - values[i] = new(sql.NullInt64) + values[i] = &sql.NullScanner{S: new(uuid.UUID)} default: values[i] = new(sql.UnknownType) } @@ -77,11 +78,11 @@ func (sd *SubjectDigest) assignValues(columns []string, values []any) error { for i := range columns { switch columns[i] { case subjectdigest.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + sd.ID = *value } - sd.ID = int(value.Int64) case subjectdigest.FieldAlgorithm: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field algorithm", values[i]) @@ -95,11 +96,11 @@ func (sd *SubjectDigest) assignValues(columns []string, values []any) error { sd.Value = value.String } case subjectdigest.ForeignKeys[0]: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field subject_subject_digests", value) + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field subject_subject_digests", values[i]) } else if value.Valid { - sd.subject_subject_digests = new(int) - *sd.subject_subject_digests = int(value.Int64) + sd.subject_subject_digests = new(uuid.UUID) + *sd.subject_subject_digests = *value.S.(*uuid.UUID) } default: sd.selectValues.Set(columns[i], values[i]) diff --git a/ent/subjectdigest/subjectdigest.go b/ent/subjectdigest/subjectdigest.go index 2d540aba..b16e90df 100644 --- a/ent/subjectdigest/subjectdigest.go +++ b/ent/subjectdigest/subjectdigest.go @@ -5,6 +5,7 @@ package subjectdigest import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" ) const ( @@ -62,6 +63,8 @@ var ( AlgorithmValidator func(string) error // ValueValidator is a validator for the "value" field. It is called by the builders before save. ValueValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID ) // OrderOption defines the ordering options for the SubjectDigest queries. diff --git a/ent/subjectdigest/where.go b/ent/subjectdigest/where.go index f6bec0a4..d30d9735 100644 --- a/ent/subjectdigest/where.go +++ b/ent/subjectdigest/where.go @@ -5,51 +5,52 @@ package subjectdigest import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/predicate" ) // ID filters vertices based on their ID field. -func ID(id int) predicate.SubjectDigest { +func ID(id uuid.UUID) predicate.SubjectDigest { return predicate.SubjectDigest(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.SubjectDigest { +func IDEQ(id uuid.UUID) predicate.SubjectDigest { return predicate.SubjectDigest(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.SubjectDigest { +func IDNEQ(id uuid.UUID) predicate.SubjectDigest { return predicate.SubjectDigest(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.SubjectDigest { +func IDIn(ids ...uuid.UUID) predicate.SubjectDigest { return predicate.SubjectDigest(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.SubjectDigest { +func IDNotIn(ids ...uuid.UUID) predicate.SubjectDigest { return predicate.SubjectDigest(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.SubjectDigest { +func IDGT(id uuid.UUID) predicate.SubjectDigest { return predicate.SubjectDigest(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.SubjectDigest { +func IDGTE(id uuid.UUID) predicate.SubjectDigest { return predicate.SubjectDigest(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.SubjectDigest { +func IDLT(id uuid.UUID) predicate.SubjectDigest { return predicate.SubjectDigest(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.SubjectDigest { +func IDLTE(id uuid.UUID) predicate.SubjectDigest { return predicate.SubjectDigest(sql.FieldLTE(FieldID, id)) } diff --git a/ent/subjectdigest_create.go b/ent/subjectdigest_create.go index fe3f48cc..77ec4e40 100644 --- a/ent/subjectdigest_create.go +++ b/ent/subjectdigest_create.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/subject" "github.com/in-toto/archivista/ent/subjectdigest" ) @@ -32,14 +33,28 @@ func (sdc *SubjectDigestCreate) SetValue(s string) *SubjectDigestCreate { return sdc } +// SetID sets the "id" field. +func (sdc *SubjectDigestCreate) SetID(u uuid.UUID) *SubjectDigestCreate { + sdc.mutation.SetID(u) + return sdc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (sdc *SubjectDigestCreate) SetNillableID(u *uuid.UUID) *SubjectDigestCreate { + if u != nil { + sdc.SetID(*u) + } + return sdc +} + // SetSubjectID sets the "subject" edge to the Subject entity by ID. -func (sdc *SubjectDigestCreate) SetSubjectID(id int) *SubjectDigestCreate { +func (sdc *SubjectDigestCreate) SetSubjectID(id uuid.UUID) *SubjectDigestCreate { sdc.mutation.SetSubjectID(id) return sdc } // SetNillableSubjectID sets the "subject" edge to the Subject entity by ID if the given value is not nil. -func (sdc *SubjectDigestCreate) SetNillableSubjectID(id *int) *SubjectDigestCreate { +func (sdc *SubjectDigestCreate) SetNillableSubjectID(id *uuid.UUID) *SubjectDigestCreate { if id != nil { sdc = sdc.SetSubjectID(*id) } @@ -58,6 +73,7 @@ func (sdc *SubjectDigestCreate) Mutation() *SubjectDigestMutation { // Save creates the SubjectDigest in the database. func (sdc *SubjectDigestCreate) Save(ctx context.Context) (*SubjectDigest, error) { + sdc.defaults() return withHooks(ctx, sdc.sqlSave, sdc.mutation, sdc.hooks) } @@ -83,6 +99,14 @@ func (sdc *SubjectDigestCreate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (sdc *SubjectDigestCreate) defaults() { + if _, ok := sdc.mutation.ID(); !ok { + v := subjectdigest.DefaultID() + sdc.mutation.SetID(v) + } +} + // check runs all checks and user-defined validators on the builder. func (sdc *SubjectDigestCreate) check() error { if _, ok := sdc.mutation.Algorithm(); !ok { @@ -115,8 +139,13 @@ func (sdc *SubjectDigestCreate) sqlSave(ctx context.Context) (*SubjectDigest, er } return nil, err } - id := _spec.ID.Value.(int64) - _node.ID = int(id) + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } sdc.mutation.id = &_node.ID sdc.mutation.done = true return _node, nil @@ -125,8 +154,12 @@ func (sdc *SubjectDigestCreate) sqlSave(ctx context.Context) (*SubjectDigest, er func (sdc *SubjectDigestCreate) createSpec() (*SubjectDigest, *sqlgraph.CreateSpec) { var ( _node = &SubjectDigest{config: sdc.config} - _spec = sqlgraph.NewCreateSpec(subjectdigest.Table, sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeInt)) + _spec = sqlgraph.NewCreateSpec(subjectdigest.Table, sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeUUID)) ) + if id, ok := sdc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } if value, ok := sdc.mutation.Algorithm(); ok { _spec.SetField(subjectdigest.FieldAlgorithm, field.TypeString, value) _node.Algorithm = value @@ -143,7 +176,7 @@ func (sdc *SubjectDigestCreate) createSpec() (*SubjectDigest, *sqlgraph.CreateSp Columns: []string{subjectdigest.SubjectColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -173,6 +206,7 @@ func (sdcb *SubjectDigestCreateBulk) Save(ctx context.Context) ([]*SubjectDigest for i := range sdcb.builders { func(i int, root context.Context) { builder := sdcb.builders[i] + builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*SubjectDigestMutation) if !ok { @@ -199,10 +233,6 @@ func (sdcb *SubjectDigestCreateBulk) Save(ctx context.Context) ([]*SubjectDigest return nil, err } mutation.id = &nodes[i].ID - if specs[i].ID.Value != nil { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int(id) - } mutation.done = true return nodes[i], nil }) diff --git a/ent/subjectdigest_delete.go b/ent/subjectdigest_delete.go index 35e87cc9..c764122b 100644 --- a/ent/subjectdigest_delete.go +++ b/ent/subjectdigest_delete.go @@ -40,7 +40,7 @@ func (sdd *SubjectDigestDelete) ExecX(ctx context.Context) int { } func (sdd *SubjectDigestDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(subjectdigest.Table, sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeInt)) + _spec := sqlgraph.NewDeleteSpec(subjectdigest.Table, sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeUUID)) if ps := sdd.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { diff --git a/ent/subjectdigest_query.go b/ent/subjectdigest_query.go index 60cfa884..6f049fd8 100644 --- a/ent/subjectdigest_query.go +++ b/ent/subjectdigest_query.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/predicate" "github.com/in-toto/archivista/ent/subject" "github.com/in-toto/archivista/ent/subjectdigest" @@ -108,8 +109,8 @@ func (sdq *SubjectDigestQuery) FirstX(ctx context.Context) *SubjectDigest { // FirstID returns the first SubjectDigest ID from the query. // Returns a *NotFoundError when no SubjectDigest ID was found. -func (sdq *SubjectDigestQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -121,7 +122,7 @@ func (sdq *SubjectDigestQuery) FirstID(ctx context.Context) (id int, err error) } // FirstIDX is like FirstID, but panics if an error occurs. -func (sdq *SubjectDigestQuery) FirstIDX(ctx context.Context) int { +func (sdq *SubjectDigestQuery) FirstIDX(ctx context.Context) uuid.UUID { id, err := sdq.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) @@ -159,8 +160,8 @@ func (sdq *SubjectDigestQuery) OnlyX(ctx context.Context) *SubjectDigest { // OnlyID is like Only, but returns the only SubjectDigest ID in the query. // Returns a *NotSingularError when more than one SubjectDigest ID is found. // Returns a *NotFoundError when no entities are found. -func (sdq *SubjectDigestQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -176,7 +177,7 @@ func (sdq *SubjectDigestQuery) OnlyID(ctx context.Context) (id int, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (sdq *SubjectDigestQuery) OnlyIDX(ctx context.Context) int { +func (sdq *SubjectDigestQuery) OnlyIDX(ctx context.Context) uuid.UUID { id, err := sdq.OnlyID(ctx) if err != nil { panic(err) @@ -204,7 +205,7 @@ func (sdq *SubjectDigestQuery) AllX(ctx context.Context) []*SubjectDigest { } // IDs executes the query and returns a list of SubjectDigest IDs. -func (sdq *SubjectDigestQuery) IDs(ctx context.Context) (ids []int, err error) { +func (sdq *SubjectDigestQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if sdq.ctx.Unique == nil && sdq.path != nil { sdq.Unique(true) } @@ -216,7 +217,7 @@ func (sdq *SubjectDigestQuery) IDs(ctx context.Context) (ids []int, err error) { } // IDsX is like IDs, but panics if an error occurs. -func (sdq *SubjectDigestQuery) IDsX(ctx context.Context) []int { +func (sdq *SubjectDigestQuery) IDsX(ctx context.Context) []uuid.UUID { ids, err := sdq.IDs(ctx) if err != nil { panic(err) @@ -419,8 +420,8 @@ func (sdq *SubjectDigestQuery) sqlAll(ctx context.Context, hooks ...queryHook) ( } func (sdq *SubjectDigestQuery) loadSubject(ctx context.Context, query *SubjectQuery, nodes []*SubjectDigest, init func(*SubjectDigest), assign func(*SubjectDigest, *Subject)) error { - ids := make([]int, 0, len(nodes)) - nodeids := make(map[int][]*SubjectDigest) + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*SubjectDigest) for i := range nodes { if nodes[i].subject_subject_digests == nil { continue @@ -464,7 +465,7 @@ func (sdq *SubjectDigestQuery) sqlCount(ctx context.Context) (int, error) { } func (sdq *SubjectDigestQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(subjectdigest.Table, subjectdigest.Columns, sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeInt)) + _spec := sqlgraph.NewQuerySpec(subjectdigest.Table, subjectdigest.Columns, sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeUUID)) _spec.From = sdq.sql if unique := sdq.ctx.Unique; unique != nil { _spec.Unique = *unique diff --git a/ent/subjectdigest_update.go b/ent/subjectdigest_update.go index 4f50c680..2b6c95cf 100644 --- a/ent/subjectdigest_update.go +++ b/ent/subjectdigest_update.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/predicate" "github.com/in-toto/archivista/ent/subject" "github.com/in-toto/archivista/ent/subjectdigest" @@ -57,13 +58,13 @@ func (sdu *SubjectDigestUpdate) SetNillableValue(s *string) *SubjectDigestUpdate } // SetSubjectID sets the "subject" edge to the Subject entity by ID. -func (sdu *SubjectDigestUpdate) SetSubjectID(id int) *SubjectDigestUpdate { +func (sdu *SubjectDigestUpdate) SetSubjectID(id uuid.UUID) *SubjectDigestUpdate { sdu.mutation.SetSubjectID(id) return sdu } // SetNillableSubjectID sets the "subject" edge to the Subject entity by ID if the given value is not nil. -func (sdu *SubjectDigestUpdate) SetNillableSubjectID(id *int) *SubjectDigestUpdate { +func (sdu *SubjectDigestUpdate) SetNillableSubjectID(id *uuid.UUID) *SubjectDigestUpdate { if id != nil { sdu = sdu.SetSubjectID(*id) } @@ -132,7 +133,7 @@ func (sdu *SubjectDigestUpdate) sqlSave(ctx context.Context) (n int, err error) if err := sdu.check(); err != nil { return n, err } - _spec := sqlgraph.NewUpdateSpec(subjectdigest.Table, subjectdigest.Columns, sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(subjectdigest.Table, subjectdigest.Columns, sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeUUID)) if ps := sdu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -154,7 +155,7 @@ func (sdu *SubjectDigestUpdate) sqlSave(ctx context.Context) (n int, err error) Columns: []string{subjectdigest.SubjectColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -167,7 +168,7 @@ func (sdu *SubjectDigestUpdate) sqlSave(ctx context.Context) (n int, err error) Columns: []string{subjectdigest.SubjectColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -224,13 +225,13 @@ func (sduo *SubjectDigestUpdateOne) SetNillableValue(s *string) *SubjectDigestUp } // SetSubjectID sets the "subject" edge to the Subject entity by ID. -func (sduo *SubjectDigestUpdateOne) SetSubjectID(id int) *SubjectDigestUpdateOne { +func (sduo *SubjectDigestUpdateOne) SetSubjectID(id uuid.UUID) *SubjectDigestUpdateOne { sduo.mutation.SetSubjectID(id) return sduo } // SetNillableSubjectID sets the "subject" edge to the Subject entity by ID if the given value is not nil. -func (sduo *SubjectDigestUpdateOne) SetNillableSubjectID(id *int) *SubjectDigestUpdateOne { +func (sduo *SubjectDigestUpdateOne) SetNillableSubjectID(id *uuid.UUID) *SubjectDigestUpdateOne { if id != nil { sduo = sduo.SetSubjectID(*id) } @@ -312,7 +313,7 @@ func (sduo *SubjectDigestUpdateOne) sqlSave(ctx context.Context) (_node *Subject if err := sduo.check(); err != nil { return _node, err } - _spec := sqlgraph.NewUpdateSpec(subjectdigest.Table, subjectdigest.Columns, sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(subjectdigest.Table, subjectdigest.Columns, sqlgraph.NewFieldSpec(subjectdigest.FieldID, field.TypeUUID)) id, ok := sduo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "SubjectDigest.id" for update`)} @@ -351,7 +352,7 @@ func (sduo *SubjectDigestUpdateOne) sqlSave(ctx context.Context) (_node *Subject Columns: []string{subjectdigest.SubjectColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -364,7 +365,7 @@ func (sduo *SubjectDigestUpdateOne) sqlSave(ctx context.Context) (_node *Subject Columns: []string{subjectdigest.SubjectColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(subject.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/ent/timestamp.go b/ent/timestamp.go index 2aa595be..079cfbb0 100644 --- a/ent/timestamp.go +++ b/ent/timestamp.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/signature" "github.com/in-toto/archivista/ent/timestamp" ) @@ -17,7 +18,7 @@ import ( type Timestamp struct { config `json:"-"` // ID of the ent. - ID int `json:"id,omitempty"` + ID uuid.UUID `json:"id,omitempty"` // Type holds the value of the "type" field. Type string `json:"type,omitempty"` // Timestamp holds the value of the "timestamp" field. @@ -25,7 +26,7 @@ type Timestamp struct { // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the TimestampQuery when eager-loading is set. Edges TimestampEdges `json:"edges"` - signature_timestamps *int + signature_timestamps *uuid.UUID selectValues sql.SelectValues } @@ -56,14 +57,14 @@ func (*Timestamp) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case timestamp.FieldID: - values[i] = new(sql.NullInt64) case timestamp.FieldType: values[i] = new(sql.NullString) case timestamp.FieldTimestamp: values[i] = new(sql.NullTime) + case timestamp.FieldID: + values[i] = new(uuid.UUID) case timestamp.ForeignKeys[0]: // signature_timestamps - values[i] = new(sql.NullInt64) + values[i] = &sql.NullScanner{S: new(uuid.UUID)} default: values[i] = new(sql.UnknownType) } @@ -80,11 +81,11 @@ func (t *Timestamp) assignValues(columns []string, values []any) error { for i := range columns { switch columns[i] { case timestamp.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + t.ID = *value } - t.ID = int(value.Int64) case timestamp.FieldType: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field type", values[i]) @@ -98,11 +99,11 @@ func (t *Timestamp) assignValues(columns []string, values []any) error { t.Timestamp = value.Time } case timestamp.ForeignKeys[0]: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field signature_timestamps", value) + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field signature_timestamps", values[i]) } else if value.Valid { - t.signature_timestamps = new(int) - *t.signature_timestamps = int(value.Int64) + t.signature_timestamps = new(uuid.UUID) + *t.signature_timestamps = *value.S.(*uuid.UUID) } default: t.selectValues.Set(columns[i], values[i]) diff --git a/ent/timestamp/timestamp.go b/ent/timestamp/timestamp.go index f73b7cb3..6d444583 100644 --- a/ent/timestamp/timestamp.go +++ b/ent/timestamp/timestamp.go @@ -5,6 +5,7 @@ package timestamp import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" ) const ( @@ -57,6 +58,11 @@ func ValidColumn(column string) bool { return false } +var ( + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID +) + // OrderOption defines the ordering options for the Timestamp queries. type OrderOption func(*sql.Selector) diff --git a/ent/timestamp/where.go b/ent/timestamp/where.go index edc4a156..ba0ba02c 100644 --- a/ent/timestamp/where.go +++ b/ent/timestamp/where.go @@ -7,51 +7,52 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/predicate" ) // ID filters vertices based on their ID field. -func ID(id int) predicate.Timestamp { +func ID(id uuid.UUID) predicate.Timestamp { return predicate.Timestamp(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.Timestamp { +func IDEQ(id uuid.UUID) predicate.Timestamp { return predicate.Timestamp(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.Timestamp { +func IDNEQ(id uuid.UUID) predicate.Timestamp { return predicate.Timestamp(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.Timestamp { +func IDIn(ids ...uuid.UUID) predicate.Timestamp { return predicate.Timestamp(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.Timestamp { +func IDNotIn(ids ...uuid.UUID) predicate.Timestamp { return predicate.Timestamp(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.Timestamp { +func IDGT(id uuid.UUID) predicate.Timestamp { return predicate.Timestamp(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.Timestamp { +func IDGTE(id uuid.UUID) predicate.Timestamp { return predicate.Timestamp(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.Timestamp { +func IDLT(id uuid.UUID) predicate.Timestamp { return predicate.Timestamp(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.Timestamp { +func IDLTE(id uuid.UUID) predicate.Timestamp { return predicate.Timestamp(sql.FieldLTE(FieldID, id)) } diff --git a/ent/timestamp_create.go b/ent/timestamp_create.go index f98406ca..d7163085 100644 --- a/ent/timestamp_create.go +++ b/ent/timestamp_create.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/signature" "github.com/in-toto/archivista/ent/timestamp" ) @@ -33,14 +34,28 @@ func (tc *TimestampCreate) SetTimestamp(t time.Time) *TimestampCreate { return tc } +// SetID sets the "id" field. +func (tc *TimestampCreate) SetID(u uuid.UUID) *TimestampCreate { + tc.mutation.SetID(u) + return tc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (tc *TimestampCreate) SetNillableID(u *uuid.UUID) *TimestampCreate { + if u != nil { + tc.SetID(*u) + } + return tc +} + // SetSignatureID sets the "signature" edge to the Signature entity by ID. -func (tc *TimestampCreate) SetSignatureID(id int) *TimestampCreate { +func (tc *TimestampCreate) SetSignatureID(id uuid.UUID) *TimestampCreate { tc.mutation.SetSignatureID(id) return tc } // SetNillableSignatureID sets the "signature" edge to the Signature entity by ID if the given value is not nil. -func (tc *TimestampCreate) SetNillableSignatureID(id *int) *TimestampCreate { +func (tc *TimestampCreate) SetNillableSignatureID(id *uuid.UUID) *TimestampCreate { if id != nil { tc = tc.SetSignatureID(*id) } @@ -59,6 +74,7 @@ func (tc *TimestampCreate) Mutation() *TimestampMutation { // Save creates the Timestamp in the database. func (tc *TimestampCreate) Save(ctx context.Context) (*Timestamp, error) { + tc.defaults() return withHooks(ctx, tc.sqlSave, tc.mutation, tc.hooks) } @@ -84,6 +100,14 @@ func (tc *TimestampCreate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (tc *TimestampCreate) defaults() { + if _, ok := tc.mutation.ID(); !ok { + v := timestamp.DefaultID() + tc.mutation.SetID(v) + } +} + // check runs all checks and user-defined validators on the builder. func (tc *TimestampCreate) check() error { if _, ok := tc.mutation.GetType(); !ok { @@ -106,8 +130,13 @@ func (tc *TimestampCreate) sqlSave(ctx context.Context) (*Timestamp, error) { } return nil, err } - id := _spec.ID.Value.(int64) - _node.ID = int(id) + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } tc.mutation.id = &_node.ID tc.mutation.done = true return _node, nil @@ -116,8 +145,12 @@ func (tc *TimestampCreate) sqlSave(ctx context.Context) (*Timestamp, error) { func (tc *TimestampCreate) createSpec() (*Timestamp, *sqlgraph.CreateSpec) { var ( _node = &Timestamp{config: tc.config} - _spec = sqlgraph.NewCreateSpec(timestamp.Table, sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeInt)) + _spec = sqlgraph.NewCreateSpec(timestamp.Table, sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeUUID)) ) + if id, ok := tc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } if value, ok := tc.mutation.GetType(); ok { _spec.SetField(timestamp.FieldType, field.TypeString, value) _node.Type = value @@ -134,7 +167,7 @@ func (tc *TimestampCreate) createSpec() (*Timestamp, *sqlgraph.CreateSpec) { Columns: []string{timestamp.SignatureColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -164,6 +197,7 @@ func (tcb *TimestampCreateBulk) Save(ctx context.Context) ([]*Timestamp, error) for i := range tcb.builders { func(i int, root context.Context) { builder := tcb.builders[i] + builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*TimestampMutation) if !ok { @@ -190,10 +224,6 @@ func (tcb *TimestampCreateBulk) Save(ctx context.Context) ([]*Timestamp, error) return nil, err } mutation.id = &nodes[i].ID - if specs[i].ID.Value != nil { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int(id) - } mutation.done = true return nodes[i], nil }) diff --git a/ent/timestamp_delete.go b/ent/timestamp_delete.go index 991bff4d..973b596c 100644 --- a/ent/timestamp_delete.go +++ b/ent/timestamp_delete.go @@ -40,7 +40,7 @@ func (td *TimestampDelete) ExecX(ctx context.Context) int { } func (td *TimestampDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(timestamp.Table, sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeInt)) + _spec := sqlgraph.NewDeleteSpec(timestamp.Table, sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeUUID)) if ps := td.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { diff --git a/ent/timestamp_query.go b/ent/timestamp_query.go index 9f820923..809250ff 100644 --- a/ent/timestamp_query.go +++ b/ent/timestamp_query.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/predicate" "github.com/in-toto/archivista/ent/signature" "github.com/in-toto/archivista/ent/timestamp" @@ -108,8 +109,8 @@ func (tq *TimestampQuery) FirstX(ctx context.Context) *Timestamp { // FirstID returns the first Timestamp ID from the query. // Returns a *NotFoundError when no Timestamp ID was found. -func (tq *TimestampQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -121,7 +122,7 @@ func (tq *TimestampQuery) FirstID(ctx context.Context) (id int, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (tq *TimestampQuery) FirstIDX(ctx context.Context) int { +func (tq *TimestampQuery) FirstIDX(ctx context.Context) uuid.UUID { id, err := tq.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) @@ -159,8 +160,8 @@ func (tq *TimestampQuery) OnlyX(ctx context.Context) *Timestamp { // OnlyID is like Only, but returns the only Timestamp ID in the query. // Returns a *NotSingularError when more than one Timestamp ID is found. // Returns a *NotFoundError when no entities are found. -func (tq *TimestampQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int +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 { return } @@ -176,7 +177,7 @@ func (tq *TimestampQuery) OnlyID(ctx context.Context) (id int, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (tq *TimestampQuery) OnlyIDX(ctx context.Context) int { +func (tq *TimestampQuery) OnlyIDX(ctx context.Context) uuid.UUID { id, err := tq.OnlyID(ctx) if err != nil { panic(err) @@ -204,7 +205,7 @@ func (tq *TimestampQuery) AllX(ctx context.Context) []*Timestamp { } // IDs executes the query and returns a list of Timestamp IDs. -func (tq *TimestampQuery) IDs(ctx context.Context) (ids []int, err error) { +func (tq *TimestampQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if tq.ctx.Unique == nil && tq.path != nil { tq.Unique(true) } @@ -216,7 +217,7 @@ func (tq *TimestampQuery) IDs(ctx context.Context) (ids []int, err error) { } // IDsX is like IDs, but panics if an error occurs. -func (tq *TimestampQuery) IDsX(ctx context.Context) []int { +func (tq *TimestampQuery) IDsX(ctx context.Context) []uuid.UUID { ids, err := tq.IDs(ctx) if err != nil { panic(err) @@ -419,8 +420,8 @@ func (tq *TimestampQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Ti } func (tq *TimestampQuery) loadSignature(ctx context.Context, query *SignatureQuery, nodes []*Timestamp, init func(*Timestamp), assign func(*Timestamp, *Signature)) error { - ids := make([]int, 0, len(nodes)) - nodeids := make(map[int][]*Timestamp) + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*Timestamp) for i := range nodes { if nodes[i].signature_timestamps == nil { continue @@ -464,7 +465,7 @@ func (tq *TimestampQuery) sqlCount(ctx context.Context) (int, error) { } func (tq *TimestampQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(timestamp.Table, timestamp.Columns, sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeInt)) + _spec := sqlgraph.NewQuerySpec(timestamp.Table, timestamp.Columns, sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeUUID)) _spec.From = tq.sql if unique := tq.ctx.Unique; unique != nil { _spec.Unique = *unique diff --git a/ent/timestamp_update.go b/ent/timestamp_update.go index 84d191a9..f6f024e2 100644 --- a/ent/timestamp_update.go +++ b/ent/timestamp_update.go @@ -11,6 +11,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/google/uuid" "github.com/in-toto/archivista/ent/predicate" "github.com/in-toto/archivista/ent/signature" "github.com/in-toto/archivista/ent/timestamp" @@ -58,13 +59,13 @@ func (tu *TimestampUpdate) SetNillableTimestamp(t *time.Time) *TimestampUpdate { } // SetSignatureID sets the "signature" edge to the Signature entity by ID. -func (tu *TimestampUpdate) SetSignatureID(id int) *TimestampUpdate { +func (tu *TimestampUpdate) SetSignatureID(id uuid.UUID) *TimestampUpdate { tu.mutation.SetSignatureID(id) return tu } // SetNillableSignatureID sets the "signature" edge to the Signature entity by ID if the given value is not nil. -func (tu *TimestampUpdate) SetNillableSignatureID(id *int) *TimestampUpdate { +func (tu *TimestampUpdate) SetNillableSignatureID(id *uuid.UUID) *TimestampUpdate { if id != nil { tu = tu.SetSignatureID(*id) } @@ -115,7 +116,7 @@ func (tu *TimestampUpdate) ExecX(ctx context.Context) { } func (tu *TimestampUpdate) sqlSave(ctx context.Context) (n int, err error) { - _spec := sqlgraph.NewUpdateSpec(timestamp.Table, timestamp.Columns, sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(timestamp.Table, timestamp.Columns, sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeUUID)) if ps := tu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -137,7 +138,7 @@ func (tu *TimestampUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{timestamp.SignatureColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -150,7 +151,7 @@ func (tu *TimestampUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{timestamp.SignatureColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -207,13 +208,13 @@ func (tuo *TimestampUpdateOne) SetNillableTimestamp(t *time.Time) *TimestampUpda } // SetSignatureID sets the "signature" edge to the Signature entity by ID. -func (tuo *TimestampUpdateOne) SetSignatureID(id int) *TimestampUpdateOne { +func (tuo *TimestampUpdateOne) SetSignatureID(id uuid.UUID) *TimestampUpdateOne { tuo.mutation.SetSignatureID(id) return tuo } // SetNillableSignatureID sets the "signature" edge to the Signature entity by ID if the given value is not nil. -func (tuo *TimestampUpdateOne) SetNillableSignatureID(id *int) *TimestampUpdateOne { +func (tuo *TimestampUpdateOne) SetNillableSignatureID(id *uuid.UUID) *TimestampUpdateOne { if id != nil { tuo = tuo.SetSignatureID(*id) } @@ -277,7 +278,7 @@ func (tuo *TimestampUpdateOne) ExecX(ctx context.Context) { } func (tuo *TimestampUpdateOne) sqlSave(ctx context.Context) (_node *Timestamp, err error) { - _spec := sqlgraph.NewUpdateSpec(timestamp.Table, timestamp.Columns, sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeInt)) + _spec := sqlgraph.NewUpdateSpec(timestamp.Table, timestamp.Columns, sqlgraph.NewFieldSpec(timestamp.FieldID, field.TypeUUID)) id, ok := tuo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Timestamp.id" for update`)} @@ -316,7 +317,7 @@ func (tuo *TimestampUpdateOne) sqlSave(ctx context.Context) (_node *Timestamp, e Columns: []string{timestamp.SignatureColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -329,7 +330,7 @@ func (tuo *TimestampUpdateOne) sqlSave(ctx context.Context) (_node *Timestamp, e Columns: []string{timestamp.SignatureColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(signature.FieldID, field.TypeUUID), }, } for _, k := range nodes { diff --git a/generated.go b/generated.go index a3187b6d..a8502fd6 100644 --- a/generated.go +++ b/generated.go @@ -16,7 +16,9 @@ import ( "entgo.io/contrib/entgql" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" + "github.com/google/uuid" "github.com/in-toto/archivista/ent" + "github.com/in-toto/archivista/ent/schema/uuidgql" gqlparser "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" ) @@ -113,11 +115,11 @@ type ComplexityRoot struct { } Query struct { - AttestationPolicies func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, where *ent.AttestationPolicyWhereInput) int - Dsses func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, where *ent.DsseWhereInput) int - Node func(childComplexity int, id int) int - Nodes func(childComplexity int, ids []int) int - Subjects func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, where *ent.SubjectWhereInput) int + AttestationPolicies func(childComplexity int, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, where *ent.AttestationPolicyWhereInput) int + Dsses func(childComplexity int, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, where *ent.DsseWhereInput) int + Node func(childComplexity int, id uuid.UUID) int + Nodes func(childComplexity int, ids []uuid.UUID) int + Subjects func(childComplexity int, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, where *ent.SubjectWhereInput) int } Signature struct { @@ -134,7 +136,7 @@ type ComplexityRoot struct { ID func(childComplexity int) int Policy func(childComplexity int) int Predicate func(childComplexity int) int - Subjects func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, where *ent.SubjectWhereInput) int + Subjects func(childComplexity int, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, where *ent.SubjectWhereInput) int } Subject struct { @@ -171,11 +173,11 @@ type ComplexityRoot struct { } type QueryResolver interface { - Node(ctx context.Context, id int) (ent.Noder, error) - Nodes(ctx context.Context, ids []int) ([]ent.Noder, error) - AttestationPolicies(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, where *ent.AttestationPolicyWhereInput) (*ent.AttestationPolicyConnection, error) - Dsses(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, where *ent.DsseWhereInput) (*ent.DsseConnection, error) - Subjects(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, where *ent.SubjectWhereInput) (*ent.SubjectConnection, error) + Node(ctx context.Context, id uuid.UUID) (ent.Noder, error) + Nodes(ctx context.Context, ids []uuid.UUID) ([]ent.Noder, error) + AttestationPolicies(ctx context.Context, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, where *ent.AttestationPolicyWhereInput) (*ent.AttestationPolicyConnection, error) + Dsses(ctx context.Context, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, where *ent.DsseWhereInput) (*ent.DsseConnection, error) + Subjects(ctx context.Context, after *entgql.Cursor[uuid.UUID], first *int, before *entgql.Cursor[uuid.UUID], last *int, where *ent.SubjectWhereInput) (*ent.SubjectConnection, error) } type executableSchema struct { @@ -445,7 +447,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.AttestationPolicies(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["where"].(*ent.AttestationPolicyWhereInput)), true + return e.complexity.Query.AttestationPolicies(childComplexity, args["after"].(*entgql.Cursor[uuid.UUID]), args["first"].(*int), args["before"].(*entgql.Cursor[uuid.UUID]), args["last"].(*int), args["where"].(*ent.AttestationPolicyWhereInput)), true case "Query.dsses": if e.complexity.Query.Dsses == nil { @@ -457,7 +459,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.Dsses(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["where"].(*ent.DsseWhereInput)), true + return e.complexity.Query.Dsses(childComplexity, args["after"].(*entgql.Cursor[uuid.UUID]), args["first"].(*int), args["before"].(*entgql.Cursor[uuid.UUID]), args["last"].(*int), args["where"].(*ent.DsseWhereInput)), true case "Query.node": if e.complexity.Query.Node == nil { @@ -469,7 +471,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.Node(childComplexity, args["id"].(int)), true + return e.complexity.Query.Node(childComplexity, args["id"].(uuid.UUID)), true case "Query.nodes": if e.complexity.Query.Nodes == nil { @@ -481,7 +483,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.Nodes(childComplexity, args["ids"].([]int)), true + return e.complexity.Query.Nodes(childComplexity, args["ids"].([]uuid.UUID)), true case "Query.subjects": if e.complexity.Query.Subjects == nil { @@ -493,7 +495,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.Subjects(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["where"].(*ent.SubjectWhereInput)), true + return e.complexity.Query.Subjects(childComplexity, args["after"].(*entgql.Cursor[uuid.UUID]), args["first"].(*int), args["before"].(*entgql.Cursor[uuid.UUID]), args["last"].(*int), args["where"].(*ent.SubjectWhereInput)), true case "Signature.dsse": if e.complexity.Signature.Dsse == nil { @@ -575,7 +577,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Statement.Subjects(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["where"].(*ent.SubjectWhereInput)), true + return e.complexity.Statement.Subjects(childComplexity, args["after"].(*entgql.Cursor[uuid.UUID]), args["first"].(*int), args["before"].(*entgql.Cursor[uuid.UUID]), args["last"].(*int), args["where"].(*ent.SubjectWhereInput)), true case "Subject.id": if e.complexity.Subject.ID == nil { @@ -834,7 +836,7 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs func (ec *executionContext) field_Query_attestationPolicies_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 *entgql.Cursor[int] + var arg0 *entgql.Cursor[uuid.UUID] if tmp, ok := rawArgs["after"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) arg0, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) @@ -852,7 +854,7 @@ func (ec *executionContext) field_Query_attestationPolicies_args(ctx context.Con } } args["first"] = arg1 - var arg2 *entgql.Cursor[int] + var arg2 *entgql.Cursor[uuid.UUID] if tmp, ok := rawArgs["before"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) arg2, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) @@ -885,7 +887,7 @@ func (ec *executionContext) field_Query_attestationPolicies_args(ctx context.Con func (ec *executionContext) field_Query_dsses_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 *entgql.Cursor[int] + var arg0 *entgql.Cursor[uuid.UUID] if tmp, ok := rawArgs["after"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) arg0, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) @@ -903,7 +905,7 @@ func (ec *executionContext) field_Query_dsses_args(ctx context.Context, rawArgs } } args["first"] = arg1 - var arg2 *entgql.Cursor[int] + var arg2 *entgql.Cursor[uuid.UUID] if tmp, ok := rawArgs["before"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) arg2, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) @@ -936,10 +938,10 @@ func (ec *executionContext) field_Query_dsses_args(ctx context.Context, rawArgs func (ec *executionContext) field_Query_node_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 int + var arg0 uuid.UUID if tmp, ok := rawArgs["id"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - arg0, err = ec.unmarshalNID2int(ctx, tmp) + arg0, err = ec.unmarshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, tmp) if err != nil { return nil, err } @@ -951,10 +953,10 @@ func (ec *executionContext) field_Query_node_args(ctx context.Context, rawArgs m func (ec *executionContext) field_Query_nodes_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 []int + var arg0 []uuid.UUID if tmp, ok := rawArgs["ids"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ids")) - arg0, err = ec.unmarshalNID2ᚕintᚄ(ctx, tmp) + arg0, err = ec.unmarshalNID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, tmp) if err != nil { return nil, err } @@ -966,7 +968,7 @@ func (ec *executionContext) field_Query_nodes_args(ctx context.Context, rawArgs func (ec *executionContext) field_Query_subjects_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 *entgql.Cursor[int] + var arg0 *entgql.Cursor[uuid.UUID] if tmp, ok := rawArgs["after"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) arg0, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) @@ -984,7 +986,7 @@ func (ec *executionContext) field_Query_subjects_args(ctx context.Context, rawAr } } args["first"] = arg1 - var arg2 *entgql.Cursor[int] + var arg2 *entgql.Cursor[uuid.UUID] if tmp, ok := rawArgs["before"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) arg2, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) @@ -1017,7 +1019,7 @@ func (ec *executionContext) field_Query_subjects_args(ctx context.Context, rawAr func (ec *executionContext) field_Statement_subjects_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 *entgql.Cursor[int] + var arg0 *entgql.Cursor[uuid.UUID] if tmp, ok := rawArgs["after"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) arg0, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) @@ -1035,7 +1037,7 @@ func (ec *executionContext) field_Statement_subjects_args(ctx context.Context, r } } args["first"] = arg1 - var arg2 *entgql.Cursor[int] + var arg2 *entgql.Cursor[uuid.UUID] if tmp, ok := rawArgs["before"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) arg2, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) @@ -1129,12 +1131,12 @@ func (ec *executionContext) _Attestation_id(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.(int) + res := resTmp.(uuid.UUID) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Attestation_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Attestation_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Attestation", Field: field, @@ -1178,7 +1180,7 @@ func (ec *executionContext) _Attestation_type(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Attestation_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Attestation_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Attestation", Field: field, @@ -1222,7 +1224,7 @@ func (ec *executionContext) _Attestation_attestationCollection(ctx context.Conte return ec.marshalNAttestationCollection2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationCollection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Attestation_attestationCollection(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Attestation_attestationCollection(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Attestation", Field: field, @@ -1271,12 +1273,12 @@ func (ec *executionContext) _AttestationCollection_id(ctx context.Context, field } return graphql.Null } - res := resTmp.(int) + res := resTmp.(uuid.UUID) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationCollection_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationCollection_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationCollection", Field: field, @@ -1320,7 +1322,7 @@ func (ec *executionContext) _AttestationCollection_name(ctx context.Context, fie return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationCollection_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationCollection_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationCollection", Field: field, @@ -1361,7 +1363,7 @@ func (ec *executionContext) _AttestationCollection_attestations(ctx context.Cont return ec.marshalOAttestation2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationCollection_attestations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationCollection_attestations(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationCollection", Field: field, @@ -1413,7 +1415,7 @@ func (ec *executionContext) _AttestationCollection_statement(ctx context.Context return ec.marshalNStatement2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐStatement(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationCollection_statement(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationCollection_statement(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationCollection", Field: field, @@ -1466,12 +1468,12 @@ func (ec *executionContext) _AttestationPolicy_id(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(int) + res := resTmp.(uuid.UUID) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationPolicy_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationPolicy_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationPolicy", Field: field, @@ -1515,7 +1517,7 @@ func (ec *executionContext) _AttestationPolicy_name(ctx context.Context, field g return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationPolicy_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationPolicy_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationPolicy", Field: field, @@ -1556,7 +1558,7 @@ func (ec *executionContext) _AttestationPolicy_statement(ctx context.Context, fi return ec.marshalOStatement2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐStatement(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationPolicy_statement(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationPolicy_statement(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationPolicy", Field: field, @@ -1611,7 +1613,7 @@ func (ec *executionContext) _AttestationPolicyConnection_edges(ctx context.Conte return ec.marshalOAttestationPolicyEdge2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationPolicyEdge(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationPolicyConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationPolicyConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationPolicyConnection", Field: field, @@ -1656,12 +1658,12 @@ func (ec *executionContext) _AttestationPolicyConnection_pageInfo(ctx context.Co } return graphql.Null } - res := resTmp.(entgql.PageInfo[int]) + res := resTmp.(entgql.PageInfo[uuid.UUID]) fc.Result = res return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationPolicyConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationPolicyConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationPolicyConnection", Field: field, @@ -1715,7 +1717,7 @@ func (ec *executionContext) _AttestationPolicyConnection_totalCount(ctx context. return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationPolicyConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationPolicyConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationPolicyConnection", Field: field, @@ -1756,7 +1758,7 @@ func (ec *executionContext) _AttestationPolicyEdge_node(ctx context.Context, fie return ec.marshalOAttestationPolicy2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationPolicy(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationPolicyEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationPolicyEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationPolicyEdge", Field: field, @@ -1803,12 +1805,12 @@ func (ec *executionContext) _AttestationPolicyEdge_cursor(ctx context.Context, f } return graphql.Null } - res := resTmp.(entgql.Cursor[int]) + res := resTmp.(entgql.Cursor[uuid.UUID]) fc.Result = res return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_AttestationPolicyEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_AttestationPolicyEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AttestationPolicyEdge", Field: field, @@ -1847,12 +1849,12 @@ func (ec *executionContext) _Dsse_id(ctx context.Context, field graphql.Collecte } return graphql.Null } - res := resTmp.(int) + res := resTmp.(uuid.UUID) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Dsse_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Dsse_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dsse", Field: field, @@ -1896,7 +1898,7 @@ func (ec *executionContext) _Dsse_gitoidSha256(ctx context.Context, field graphq return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Dsse_gitoidSha256(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Dsse_gitoidSha256(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dsse", Field: field, @@ -1940,7 +1942,7 @@ func (ec *executionContext) _Dsse_payloadType(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Dsse_payloadType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Dsse_payloadType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dsse", Field: field, @@ -1981,7 +1983,7 @@ func (ec *executionContext) _Dsse_statement(ctx context.Context, field graphql.C return ec.marshalOStatement2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐStatement(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Dsse_statement(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Dsse_statement(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dsse", Field: field, @@ -2036,7 +2038,7 @@ func (ec *executionContext) _Dsse_signatures(ctx context.Context, field graphql. return ec.marshalOSignature2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSignatureᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Dsse_signatures(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Dsse_signatures(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dsse", Field: field, @@ -2089,7 +2091,7 @@ func (ec *executionContext) _Dsse_payloadDigests(ctx context.Context, field grap return ec.marshalOPayloadDigest2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐPayloadDigestᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Dsse_payloadDigests(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Dsse_payloadDigests(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dsse", Field: field, @@ -2140,7 +2142,7 @@ func (ec *executionContext) _DsseConnection_edges(ctx context.Context, field gra return ec.marshalODsseEdge2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsseEdge(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_DsseConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_DsseConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DsseConnection", Field: field, @@ -2185,12 +2187,12 @@ func (ec *executionContext) _DsseConnection_pageInfo(ctx context.Context, field } return graphql.Null } - res := resTmp.(entgql.PageInfo[int]) + res := resTmp.(entgql.PageInfo[uuid.UUID]) fc.Result = res return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_DsseConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_DsseConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DsseConnection", Field: field, @@ -2244,7 +2246,7 @@ func (ec *executionContext) _DsseConnection_totalCount(ctx context.Context, fiel return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_DsseConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_DsseConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DsseConnection", Field: field, @@ -2285,7 +2287,7 @@ func (ec *executionContext) _DsseEdge_node(ctx context.Context, field graphql.Co return ec.marshalODsse2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsse(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_DsseEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_DsseEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DsseEdge", Field: field, @@ -2338,12 +2340,12 @@ func (ec *executionContext) _DsseEdge_cursor(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.(entgql.Cursor[int]) + res := resTmp.(entgql.Cursor[uuid.UUID]) fc.Result = res return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_DsseEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_DsseEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DsseEdge", Field: field, @@ -2356,7 +2358,7 @@ func (ec *executionContext) fieldContext_DsseEdge_cursor(ctx context.Context, fi return fc, nil } -func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[uuid.UUID]) (ret graphql.Marshaler) { fc, err := ec.fieldContext_PageInfo_hasNextPage(ctx, field) if err != nil { return graphql.Null @@ -2387,7 +2389,7 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_hasNextPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PageInfo", Field: field, @@ -2400,7 +2402,7 @@ func (ec *executionContext) fieldContext_PageInfo_hasNextPage(ctx context.Contex return fc, nil } -func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[uuid.UUID]) (ret graphql.Marshaler) { fc, err := ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) if err != nil { return graphql.Null @@ -2431,7 +2433,7 @@ func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PageInfo", Field: field, @@ -2444,7 +2446,7 @@ func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(ctx context.Co return fc, nil } -func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[uuid.UUID]) (ret graphql.Marshaler) { fc, err := ec.fieldContext_PageInfo_startCursor(ctx, field) if err != nil { return graphql.Null @@ -2467,12 +2469,12 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra if resTmp == nil { return graphql.Null } - res := resTmp.(*entgql.Cursor[int]) + res := resTmp.(*entgql.Cursor[uuid.UUID]) fc.Result = res return ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_startCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_startCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PageInfo", Field: field, @@ -2485,7 +2487,7 @@ func (ec *executionContext) fieldContext_PageInfo_startCursor(ctx context.Contex return fc, nil } -func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { +func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[uuid.UUID]) (ret graphql.Marshaler) { fc, err := ec.fieldContext_PageInfo_endCursor(ctx, field) if err != nil { return graphql.Null @@ -2508,12 +2510,12 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph if resTmp == nil { return graphql.Null } - res := resTmp.(*entgql.Cursor[int]) + res := resTmp.(*entgql.Cursor[uuid.UUID]) fc.Result = res return ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_endCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_endCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PageInfo", Field: field, @@ -2552,12 +2554,12 @@ func (ec *executionContext) _PayloadDigest_id(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(int) + res := resTmp.(uuid.UUID) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PayloadDigest_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PayloadDigest_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PayloadDigest", Field: field, @@ -2601,7 +2603,7 @@ func (ec *executionContext) _PayloadDigest_algorithm(ctx context.Context, field return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PayloadDigest_algorithm(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PayloadDigest_algorithm(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PayloadDigest", Field: field, @@ -2645,7 +2647,7 @@ func (ec *executionContext) _PayloadDigest_value(ctx context.Context, field grap return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PayloadDigest_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PayloadDigest_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PayloadDigest", Field: field, @@ -2686,7 +2688,7 @@ func (ec *executionContext) _PayloadDigest_dsse(ctx context.Context, field graph return ec.marshalODsse2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsse(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PayloadDigest_dsse(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PayloadDigest_dsse(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PayloadDigest", Field: field, @@ -2727,7 +2729,7 @@ func (ec *executionContext) _Query_node(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Node(rctx, fc.Args["id"].(int)) + return ec.resolvers.Query().Node(rctx, fc.Args["id"].(uuid.UUID)) }) if err != nil { ec.Error(ctx, err) @@ -2779,7 +2781,7 @@ func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Nodes(rctx, fc.Args["ids"].([]int)) + return ec.resolvers.Query().Nodes(rctx, fc.Args["ids"].([]uuid.UUID)) }) if err != nil { ec.Error(ctx, err) @@ -2834,7 +2836,7 @@ func (ec *executionContext) _Query_attestationPolicies(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().AttestationPolicies(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["where"].(*ent.AttestationPolicyWhereInput)) + return ec.resolvers.Query().AttestationPolicies(rctx, fc.Args["after"].(*entgql.Cursor[uuid.UUID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[uuid.UUID]), fc.Args["last"].(*int), fc.Args["where"].(*ent.AttestationPolicyWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -2897,7 +2899,7 @@ func (ec *executionContext) _Query_dsses(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Dsses(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["where"].(*ent.DsseWhereInput)) + return ec.resolvers.Query().Dsses(rctx, fc.Args["after"].(*entgql.Cursor[uuid.UUID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[uuid.UUID]), fc.Args["last"].(*int), fc.Args["where"].(*ent.DsseWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -2960,7 +2962,7 @@ func (ec *executionContext) _Query_subjects(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Subjects(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["where"].(*ent.SubjectWhereInput)) + return ec.resolvers.Query().Subjects(rctx, fc.Args["after"].(*entgql.Cursor[uuid.UUID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[uuid.UUID]), fc.Args["last"].(*int), fc.Args["where"].(*ent.SubjectWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -3111,7 +3113,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___schema(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -3164,12 +3166,12 @@ func (ec *executionContext) _Signature_id(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(int) + res := resTmp.(uuid.UUID) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Signature_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Signature_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Signature", Field: field, @@ -3213,7 +3215,7 @@ func (ec *executionContext) _Signature_keyID(ctx context.Context, field graphql. return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Signature_keyID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Signature_keyID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Signature", Field: field, @@ -3257,7 +3259,7 @@ func (ec *executionContext) _Signature_signature(ctx context.Context, field grap return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Signature_signature(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Signature_signature(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Signature", Field: field, @@ -3298,7 +3300,7 @@ func (ec *executionContext) _Signature_dsse(ctx context.Context, field graphql.C return ec.marshalODsse2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsse(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Signature_dsse(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Signature_dsse(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Signature", Field: field, @@ -3353,7 +3355,7 @@ func (ec *executionContext) _Signature_timestamps(ctx context.Context, field gra return ec.marshalOTimestamp2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐTimestampᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Signature_timestamps(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Signature_timestamps(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Signature", Field: field, @@ -3402,12 +3404,12 @@ func (ec *executionContext) _Statement_id(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(int) + res := resTmp.(uuid.UUID) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Statement_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Statement_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Statement", Field: field, @@ -3451,7 +3453,7 @@ func (ec *executionContext) _Statement_predicate(ctx context.Context, field grap return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Statement_predicate(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Statement_predicate(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Statement", Field: field, @@ -3478,7 +3480,7 @@ func (ec *executionContext) _Statement_subjects(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Subjects(ctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["where"].(*ent.SubjectWhereInput)) + return obj.Subjects(ctx, fc.Args["after"].(*entgql.Cursor[uuid.UUID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[uuid.UUID]), fc.Args["last"].(*int), fc.Args["where"].(*ent.SubjectWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -3555,7 +3557,7 @@ func (ec *executionContext) _Statement_policy(ctx context.Context, field graphql return ec.marshalOAttestationPolicy2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationPolicy(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Statement_policy(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Statement_policy(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Statement", Field: field, @@ -3604,7 +3606,7 @@ func (ec *executionContext) _Statement_attestationCollections(ctx context.Contex return ec.marshalOAttestationCollection2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐAttestationCollection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Statement_attestationCollections(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Statement_attestationCollections(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Statement", Field: field, @@ -3655,7 +3657,7 @@ func (ec *executionContext) _Statement_dsse(ctx context.Context, field graphql.C return ec.marshalODsse2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐDsseᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Statement_dsse(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Statement_dsse(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Statement", Field: field, @@ -3708,12 +3710,12 @@ func (ec *executionContext) _Subject_id(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.(int) + res := resTmp.(uuid.UUID) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Subject_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Subject_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subject", Field: field, @@ -3757,7 +3759,7 @@ func (ec *executionContext) _Subject_name(ctx context.Context, field graphql.Col return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Subject_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Subject_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subject", Field: field, @@ -3798,7 +3800,7 @@ func (ec *executionContext) _Subject_subjectDigests(ctx context.Context, field g return ec.marshalOSubjectDigest2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSubjectDigestᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Subject_subjectDigests(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Subject_subjectDigests(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subject", Field: field, @@ -3849,7 +3851,7 @@ func (ec *executionContext) _Subject_statement(ctx context.Context, field graphq return ec.marshalOStatement2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐStatement(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Subject_statement(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Subject_statement(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subject", Field: field, @@ -3904,7 +3906,7 @@ func (ec *executionContext) _SubjectConnection_edges(ctx context.Context, field return ec.marshalOSubjectEdge2ᚕᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSubjectEdge(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SubjectConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SubjectConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "SubjectConnection", Field: field, @@ -3949,12 +3951,12 @@ func (ec *executionContext) _SubjectConnection_pageInfo(ctx context.Context, fie } return graphql.Null } - res := resTmp.(entgql.PageInfo[int]) + res := resTmp.(entgql.PageInfo[uuid.UUID]) fc.Result = res return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SubjectConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SubjectConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "SubjectConnection", Field: field, @@ -4008,7 +4010,7 @@ func (ec *executionContext) _SubjectConnection_totalCount(ctx context.Context, f return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SubjectConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SubjectConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "SubjectConnection", Field: field, @@ -4047,12 +4049,12 @@ func (ec *executionContext) _SubjectDigest_id(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(int) + res := resTmp.(uuid.UUID) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SubjectDigest_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SubjectDigest_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "SubjectDigest", Field: field, @@ -4096,7 +4098,7 @@ func (ec *executionContext) _SubjectDigest_algorithm(ctx context.Context, field return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SubjectDigest_algorithm(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SubjectDigest_algorithm(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "SubjectDigest", Field: field, @@ -4140,7 +4142,7 @@ func (ec *executionContext) _SubjectDigest_value(ctx context.Context, field grap return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SubjectDigest_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SubjectDigest_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "SubjectDigest", Field: field, @@ -4181,7 +4183,7 @@ func (ec *executionContext) _SubjectDigest_subject(ctx context.Context, field gr return ec.marshalOSubject2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSubject(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SubjectDigest_subject(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SubjectDigest_subject(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "SubjectDigest", Field: field, @@ -4232,7 +4234,7 @@ func (ec *executionContext) _SubjectEdge_node(ctx context.Context, field graphql return ec.marshalOSubject2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSubject(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SubjectEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SubjectEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "SubjectEdge", Field: field, @@ -4281,12 +4283,12 @@ func (ec *executionContext) _SubjectEdge_cursor(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(entgql.Cursor[int]) + res := resTmp.(entgql.Cursor[uuid.UUID]) fc.Result = res return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SubjectEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SubjectEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "SubjectEdge", Field: field, @@ -4325,12 +4327,12 @@ func (ec *executionContext) _Timestamp_id(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(int) + res := resTmp.(uuid.UUID) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Timestamp_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Timestamp_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Timestamp", Field: field, @@ -4374,7 +4376,7 @@ func (ec *executionContext) _Timestamp_type(ctx context.Context, field graphql.C return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Timestamp_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Timestamp_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Timestamp", Field: field, @@ -4418,7 +4420,7 @@ func (ec *executionContext) _Timestamp_timestamp(ctx context.Context, field grap return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Timestamp_timestamp(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Timestamp_timestamp(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Timestamp", Field: field, @@ -4459,7 +4461,7 @@ func (ec *executionContext) _Timestamp_signature(ctx context.Context, field grap return ec.marshalOSignature2ᚖgithubᚗcomᚋinᚑtotoᚋarchivistaᚋentᚐSignature(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Timestamp_signature(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Timestamp_signature(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Timestamp", Field: field, @@ -4515,7 +4517,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Directive", Field: field, @@ -4556,7 +4558,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Directive", Field: field, @@ -4600,7 +4602,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_locations(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Directive", Field: field, @@ -4644,7 +4646,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_args(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Directive", Field: field, @@ -4698,7 +4700,7 @@ func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_isRepeatable(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Directive", Field: field, @@ -4742,7 +4744,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__EnumValue", Field: field, @@ -4783,7 +4785,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__EnumValue", Field: field, @@ -4827,7 +4829,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__EnumValue", Field: field, @@ -4868,7 +4870,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__EnumValue", Field: field, @@ -4912,7 +4914,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Field", Field: field, @@ -4953,7 +4955,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Field", Field: field, @@ -4997,7 +4999,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_args(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Field", Field: field, @@ -5051,7 +5053,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Field", Field: field, @@ -5117,7 +5119,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Field", Field: field, @@ -5158,7 +5160,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Field", Field: field, @@ -5202,7 +5204,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___InputValue_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__InputValue", Field: field, @@ -5243,7 +5245,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___InputValue_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__InputValue", Field: field, @@ -5287,7 +5289,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___InputValue_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__InputValue", Field: field, @@ -5350,7 +5352,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___InputValue_defaultValue(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__InputValue", Field: field, @@ -5391,7 +5393,7 @@ func (ec *executionContext) ___Schema_description(ctx context.Context, field gra return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Schema_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Schema", Field: field, @@ -5435,7 +5437,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Schema_types(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Schema", Field: field, @@ -5501,7 +5503,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Schema_queryType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Schema", Field: field, @@ -5564,7 +5566,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Schema_mutationType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Schema", Field: field, @@ -5627,7 +5629,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Schema_subscriptionType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Schema", Field: field, @@ -5693,7 +5695,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Schema_directives(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Schema", Field: field, @@ -5749,7 +5751,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Type_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Type", Field: field, @@ -5790,7 +5792,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Type_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Type", Field: field, @@ -5831,7 +5833,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Type_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Type", Field: field, @@ -5938,7 +5940,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Type_interfaces(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Type", Field: field, @@ -6001,7 +6003,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Type_possibleTypes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Type", Field: field, @@ -6126,7 +6128,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Type_inputFields(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Type", Field: field, @@ -6177,7 +6179,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Type_ofType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Type", Field: field, @@ -6240,7 +6242,7 @@ func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field gr return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Type_specifiedByURL(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "__Type", Field: field, @@ -6294,56 +6296,56 @@ func (ec *executionContext) unmarshalInputAttestationCollectionWhereInput(ctx co it.Or = data case "id": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.ID = data case "idNEQ": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDNEQ = data case "idIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDIn = data case "idNotIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDNotIn = data case "idGT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGT = data case "idGTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGTE = data case "idLT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDLT = data case "idLTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } @@ -6510,56 +6512,56 @@ func (ec *executionContext) unmarshalInputAttestationPolicyWhereInput(ctx contex it.Or = data case "id": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.ID = data case "idNEQ": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDNEQ = data case "idIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDIn = data case "idNotIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDNotIn = data case "idGT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGT = data case "idGTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGTE = data case "idLT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDLT = data case "idLTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } @@ -6712,56 +6714,56 @@ func (ec *executionContext) unmarshalInputAttestationWhereInput(ctx context.Cont it.Or = data case "id": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.ID = data case "idNEQ": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDNEQ = data case "idIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDIn = data case "idNotIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDNotIn = data case "idGT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGT = data case "idGTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGTE = data case "idLT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDLT = data case "idLTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } @@ -6914,56 +6916,56 @@ func (ec *executionContext) unmarshalInputDsseWhereInput(ctx context.Context, ob it.Or = data case "id": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.ID = data case "idNEQ": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDNEQ = data case "idIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDIn = data case "idNotIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDNotIn = data case "idGT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGT = data case "idGTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGTE = data case "idLT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDLT = data case "idLTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } @@ -7235,56 +7237,56 @@ func (ec *executionContext) unmarshalInputPayloadDigestWhereInput(ctx context.Co it.Or = data case "id": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.ID = data case "idNEQ": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDNEQ = data case "idIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDIn = data case "idNotIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDNotIn = data case "idGT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGT = data case "idGTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGTE = data case "idLT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDLT = data case "idLTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } @@ -7528,56 +7530,56 @@ func (ec *executionContext) unmarshalInputSignatureWhereInput(ctx context.Contex it.Or = data case "id": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.ID = data case "idNEQ": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDNEQ = data case "idIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDIn = data case "idNotIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDNotIn = data case "idGT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGT = data case "idGTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGTE = data case "idLT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDLT = data case "idLTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } @@ -7835,56 +7837,56 @@ func (ec *executionContext) unmarshalInputStatementWhereInput(ctx context.Contex it.Or = data case "id": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.ID = data case "idNEQ": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDNEQ = data case "idIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDIn = data case "idNotIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDNotIn = data case "idGT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGT = data case "idGTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGTE = data case "idLT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDLT = data case "idLTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } @@ -8079,56 +8081,56 @@ func (ec *executionContext) unmarshalInputSubjectDigestWhereInput(ctx context.Co it.Or = data case "id": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.ID = data case "idNEQ": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDNEQ = data case "idIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDIn = data case "idNotIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDNotIn = data case "idGT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGT = data case "idGTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGTE = data case "idLT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDLT = data case "idLTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } @@ -8372,56 +8374,56 @@ func (ec *executionContext) unmarshalInputSubjectWhereInput(ctx context.Context, it.Or = data case "id": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.ID = data case "idNEQ": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDNEQ = data case "idIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDIn = data case "idNotIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDNotIn = data case "idGT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGT = data case "idGTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGTE = data case "idLT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDLT = data case "idLTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } @@ -8588,56 +8590,56 @@ func (ec *executionContext) unmarshalInputTimestampWhereInput(ctx context.Contex it.Or = data case "id": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.ID = data case "idNEQ": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDNEQ = data case "idIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDIn = data case "idNotIn": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx, v) if err != nil { return it, err } it.IDNotIn = data case "idGT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGT = data case "idGTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDGTE = data case "idLT": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.IDLT = data case "idLTE": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } @@ -8980,7 +8982,7 @@ func (ec *executionContext) _AttestationCollection(ctx context.Context, sel ast. case "attestations": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9093,7 +9095,7 @@ func (ec *executionContext) _AttestationPolicy(ctx context.Context, sel ast.Sele case "statement": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9262,7 +9264,7 @@ func (ec *executionContext) _Dsse(ctx context.Context, sel ast.SelectionSet, obj case "statement": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9295,7 +9297,7 @@ func (ec *executionContext) _Dsse(ctx context.Context, sel ast.SelectionSet, obj case "signatures": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9328,7 +9330,7 @@ func (ec *executionContext) _Dsse(ctx context.Context, sel ast.SelectionSet, obj case "payloadDigests": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9470,7 +9472,7 @@ func (ec *executionContext) _DsseEdge(ctx context.Context, sel ast.SelectionSet, var pageInfoImplementors = []string{"PageInfo"} -func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *entgql.PageInfo[int]) graphql.Marshaler { +func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *entgql.PageInfo[uuid.UUID]) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, pageInfoImplementors) out := graphql.NewFieldSet(fields) @@ -9545,7 +9547,7 @@ func (ec *executionContext) _PayloadDigest(ctx context.Context, sel ast.Selectio case "dsse": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9620,7 +9622,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "node": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9784,7 +9786,7 @@ func (ec *executionContext) _Signature(ctx context.Context, sel ast.SelectionSet case "dsse": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9817,7 +9819,7 @@ func (ec *executionContext) _Signature(ctx context.Context, sel ast.SelectionSet case "timestamps": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9930,7 +9932,7 @@ func (ec *executionContext) _Statement(ctx context.Context, sel ast.SelectionSet case "policy": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9963,7 +9965,7 @@ func (ec *executionContext) _Statement(ctx context.Context, sel ast.SelectionSet case "attestationCollections": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -9996,7 +9998,7 @@ func (ec *executionContext) _Statement(ctx context.Context, sel ast.SelectionSet case "dsse": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10073,7 +10075,7 @@ func (ec *executionContext) _Subject(ctx context.Context, sel ast.SelectionSet, case "subjectDigests": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10106,7 +10108,7 @@ func (ec *executionContext) _Subject(ctx context.Context, sel ast.SelectionSet, case "statement": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10234,7 +10236,7 @@ func (ec *executionContext) _SubjectDigest(ctx context.Context, sel ast.Selectio case "subject": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10357,7 +10359,7 @@ func (ec *executionContext) _Timestamp(ctx context.Context, sel ast.SelectionSet case "signature": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -10800,13 +10802,13 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return res } -func (ec *executionContext) unmarshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx context.Context, v interface{}) (entgql.Cursor[int], error) { - var res entgql.Cursor[int] +func (ec *executionContext) unmarshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx context.Context, v interface{}) (entgql.Cursor[uuid.UUID], error) { + var res entgql.Cursor[uuid.UUID] err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx context.Context, sel ast.SelectionSet, v entgql.Cursor[int]) graphql.Marshaler { +func (ec *executionContext) marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx context.Context, sel ast.SelectionSet, v entgql.Cursor[uuid.UUID]) graphql.Marshaler { return v } @@ -10839,13 +10841,13 @@ func (ec *executionContext) unmarshalNDsseWhereInput2ᚖgithubᚗcomᚋinᚑtoto return &res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalNID2int(ctx context.Context, v interface{}) (int, error) { - res, err := graphql.UnmarshalIntID(v) +func (ec *executionContext) unmarshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx context.Context, v interface{}) (uuid.UUID, error) { + res, err := uuidgql.UnmarshalUUID(v) return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - res := graphql.MarshalIntID(v) +func (ec *executionContext) marshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx context.Context, sel ast.SelectionSet, v uuid.UUID) graphql.Marshaler { + res := uuidgql.MarshalUUID(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") @@ -10854,16 +10856,16 @@ func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.Selectio return res } -func (ec *executionContext) unmarshalNID2ᚕintᚄ(ctx context.Context, v interface{}) ([]int, error) { +func (ec *executionContext) unmarshalNID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx context.Context, v interface{}) ([]uuid.UUID, error) { var vSlice []interface{} if v != nil { vSlice = graphql.CoerceList(v) } var err error - res := make([]int, len(vSlice)) + res := make([]uuid.UUID, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNID2int(ctx, vSlice[i]) + res[i], err = ec.unmarshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, vSlice[i]) if err != nil { return nil, err } @@ -10871,10 +10873,10 @@ func (ec *executionContext) unmarshalNID2ᚕintᚄ(ctx context.Context, v interf return res, nil } -func (ec *executionContext) marshalNID2ᚕintᚄ(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { +func (ec *executionContext) marshalNID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx context.Context, sel ast.SelectionSet, v []uuid.UUID) graphql.Marshaler { ret := make(graphql.Array, len(v)) for i := range v { - ret[i] = ec.marshalNID2int(ctx, sel, v[i]) + ret[i] = ec.marshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, sel, v[i]) } for _, e := range ret { @@ -10939,7 +10941,7 @@ func (ec *executionContext) marshalNNode2ᚕgithubᚗcomᚋinᚑtotoᚋarchivist return ret } -func (ec *executionContext) marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx context.Context, sel ast.SelectionSet, v entgql.PageInfo[int]) graphql.Marshaler { +func (ec *executionContext) marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx context.Context, sel ast.SelectionSet, v entgql.PageInfo[uuid.UUID]) graphql.Marshaler { return ec._PageInfo(ctx, sel, &v) } @@ -11539,16 +11541,16 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast return res } -func (ec *executionContext) unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx context.Context, v interface{}) (*entgql.Cursor[int], error) { +func (ec *executionContext) unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx context.Context, v interface{}) (*entgql.Cursor[uuid.UUID], error) { if v == nil { return nil, nil } - var res = new(entgql.Cursor[int]) + var res = new(entgql.Cursor[uuid.UUID]) err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx context.Context, sel ast.SelectionSet, v *entgql.Cursor[int]) graphql.Marshaler { +func (ec *executionContext) marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx context.Context, sel ast.SelectionSet, v *entgql.Cursor[uuid.UUID]) graphql.Marshaler { if v == nil { return graphql.Null } @@ -11685,7 +11687,7 @@ func (ec *executionContext) unmarshalODsseWhereInput2ᚖgithubᚗcomᚋinᚑtoto return &res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalOID2ᚕintᚄ(ctx context.Context, v interface{}) ([]int, error) { +func (ec *executionContext) unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx context.Context, v interface{}) ([]uuid.UUID, error) { if v == nil { return nil, nil } @@ -11694,10 +11696,10 @@ func (ec *executionContext) unmarshalOID2ᚕintᚄ(ctx context.Context, v interf vSlice = graphql.CoerceList(v) } var err error - res := make([]int, len(vSlice)) + res := make([]uuid.UUID, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNID2int(ctx, vSlice[i]) + res[i], err = ec.unmarshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, vSlice[i]) if err != nil { return nil, err } @@ -11705,13 +11707,13 @@ func (ec *executionContext) unmarshalOID2ᚕintᚄ(ctx context.Context, v interf return res, nil } -func (ec *executionContext) marshalOID2ᚕintᚄ(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { +func (ec *executionContext) marshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx context.Context, sel ast.SelectionSet, v []uuid.UUID) graphql.Marshaler { if v == nil { return graphql.Null } ret := make(graphql.Array, len(v)) for i := range v { - ret[i] = ec.marshalNID2int(ctx, sel, v[i]) + ret[i] = ec.marshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, sel, v[i]) } for _, e := range ret { @@ -11723,19 +11725,19 @@ func (ec *executionContext) marshalOID2ᚕintᚄ(ctx context.Context, sel ast.Se return ret } -func (ec *executionContext) unmarshalOID2ᚖint(ctx context.Context, v interface{}) (*int, error) { +func (ec *executionContext) unmarshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx context.Context, v interface{}) (*uuid.UUID, error) { if v == nil { return nil, nil } - res, err := graphql.UnmarshalIntID(v) + res, err := uuidgql.UnmarshalUUID(v) return &res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalOID2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { +func (ec *executionContext) marshalOID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID(ctx context.Context, sel ast.SelectionSet, v *uuid.UUID) graphql.Marshaler { if v == nil { return graphql.Null } - res := graphql.MarshalIntID(*v) + res := uuidgql.MarshalUUID(*v) return res } diff --git a/go.mod b/go.mod index fbe6902e..f1c65f4f 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,6 @@ require ( github.com/swaggo/http-swagger/v2 v2.0.2 github.com/swaggo/swag v1.16.3 github.com/vektah/gqlparser/v2 v2.5.12 - golang.org/x/sync v0.7.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -109,6 +108,7 @@ require ( golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect golang.org/x/mod v0.17.0 // indirect golang.org/x/net v0.25.0 // indirect + golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.20.0 // indirect golang.org/x/text v0.15.0 // indirect golang.org/x/tools v0.21.0 // indirect