Debian Codegraph @

ent/attestation.go

raw
1 // Code generated by ent, DO NOT EDIT.
2
3 package ent
4
5 import (
6 "fmt"
7 "strings"
8
9 "entgo.io/ent"
10 "entgo.io/ent/dialect/sql"
11 "github.com/google/uuid"
12 "github.com/in-toto/archivista/ent/attestation"
13 "github.com/in-toto/archivista/ent/attestationcollection"
14 )
15
16 // Attestation is the model entity for the Attestation schema.
17 type Attestation struct {
18 config `json:"-"`
19 // ID of the ent.
20 ID uuid.UUID `json:"id,omitempty"`
21 // Type holds the value of the "type" field.
22 Type string `json:"type,omitempty"`
23 // Edges holds the relations/edges for other nodes in the graph.
24 // The values are being populated by the AttestationQuery when eager-loading is set.
25 Edges AttestationEdges `json:"edges"`
26 attestation_collection_attestations *uuid.UUID
27 selectValues sql.SelectValues
28 }
29
30 // AttestationEdges holds the relations/edges for other nodes in the graph.
31 type AttestationEdges struct {
32 // AttestationCollection holds the value of the attestation_collection edge.
33 AttestationCollection *AttestationCollection `json:"attestation_collection,omitempty"`
34 // loadedTypes holds the information for reporting if a
35 // type was loaded (or requested) in eager-loading or not.
36 loadedTypes [1]bool
37 // totalCount holds the count of the edges above.
38 totalCount [1]map[string]int
39 }
40
41 // AttestationCollectionOrErr returns the AttestationCollection value or an error if the edge
42 // was not loaded in eager-loading, or loaded but was not found.
43 func (e AttestationEdges) AttestationCollectionOrErr() (*AttestationCollection, error) {
44 if e.AttestationCollection != nil {
45 return e.AttestationCollection, nil
46 } else if e.loadedTypes[0] {
47 return nil, &NotFoundError{label: attestationcollection.Label}
48 }
49 return nil, &NotLoadedError{edge: "attestation_collection"}
50 }
51
52 // scanValues returns the types for scanning values from sql.Rows.
53 func (*Attestation) scanValues(columns []string) ([]any, error) {
54 values := make([]any, len(columns))
55 for i := range columns {
56 switch columns[i] {
57 case attestation.FieldType:
58 values[i] = new(sql.NullString)
59 case attestation.FieldID:
60 values[i] = new(uuid.UUID)
61 case attestation.ForeignKeys[0]: // attestation_collection_attestations
62 values[i] = &sql.NullScanner{S: new(uuid.UUID)}
63 default:
64 values[i] = new(sql.UnknownType)
65 }
66 }
67 return values, nil
68 }
69
70 // assignValues assigns the values that were returned from sql.Rows (after scanning)
71 // to the Attestation fields.
72 func (_m *Attestation) assignValues(columns []string, values []any) error {
73 if m, n := len(values), len(columns); m < n {
74 return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
75 }
76 for i := range columns {
77 switch columns[i] {
78 case attestation.FieldID:
79 if value, ok := values[i].(*uuid.UUID); !ok {
80 return fmt.Errorf("unexpected type %T for field id", values[i])
81 } else if value != nil {
82 _m.ID = *value
83 }
84 case attestation.FieldType:
85 if value, ok := values[i].(*sql.NullString); !ok {
86 return fmt.Errorf("unexpected type %T for field type", values[i])
87 } else if value.Valid {
88 _m.Type = value.String
89 }
90 case attestation.ForeignKeys[0]:
91 if value, ok := values[i].(*sql.NullScanner); !ok {
92 return fmt.Errorf("unexpected type %T for field attestation_collection_attestations", values[i])
93 } else if value.Valid {
94 _m.attestation_collection_attestations = new(uuid.UUID)
95 *_m.attestation_collection_attestations = *value.S.(*uuid.UUID)
96 }
97 default:
98 _m.selectValues.Set(columns[i], values[i])
99 }
100 }
101 return nil
102 }
103
104 // Value returns the ent.Value that was dynamically selected and assigned to the Attestation.
105 // This includes values selected through modifiers, order, etc.
106 func (_m *Attestation) Value(name string) (ent.Value, error) {
107 return _m.selectValues.Get(name)
108 }
109
110 // QueryAttestationCollection queries the "attestation_collection" edge of the Attestation entity.
111 func (_m *Attestation) QueryAttestationCollection() *AttestationCollectionQuery {
112 return NewAttestationClient(_m.config).QueryAttestationCollection(_m)
113 }
114
115 // Update returns a builder for updating this Attestation.
116 // Note that you need to call Attestation.Unwrap() before calling this method if this Attestation
117 // was returned from a transaction, and the transaction was committed or rolled back.
118 func (_m *Attestation) Update() *AttestationUpdateOne {
119 return NewAttestationClient(_m.config).UpdateOne(_m)
120 }
121
122 // Unwrap unwraps the Attestation entity that was returned from a transaction after it was closed,
123 // so that all future queries will be executed through the driver which created the transaction.
124 func (_m *Attestation) Unwrap() *Attestation {
125 _tx, ok := _m.config.driver.(*txDriver)
126 if !ok {
127 panic("ent: Attestation is not a transactional entity")
128 }
129 _m.config.driver = _tx.drv
130 return _m
131 }
132
133 // String implements the fmt.Stringer.
134 func (_m *Attestation) String() string {
135 var builder strings.Builder
136 builder.WriteString("Attestation(")
137 builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
138 builder.WriteString("type=")
139 builder.WriteString(_m.Type)
140 builder.WriteByte(')')
141 return builder.String()
142 }
143
144 // Attestations is a parsable slice of Attestation.
145 type Attestations []*Attestation