Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

chore: ente update things

Matt Kilgore5d3698d0d84d
diff --git a/backend/internal/data/ent/attachment.go b/backend/internal/data/ent/attachment.go
index 1a28aa6a..8568b28e 100644
--- a/backend/internal/data/ent/attachment.go
+++ b/backend/internal/data/ent/attachment.go
@@ -50,12 +50,10 @@ type AttachmentEdges struct {
// ItemOrErr returns the Item value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e AttachmentEdges) ItemOrErr() (*Item, error) {
- if e.loadedTypes[0] {
- if e.Item == nil {
- // Edge was loaded but was not found.
- return nil, &NotFoundError{label: item.Label}
- }
+ if e.Item != nil {
return e.Item, nil
+ } else if e.loadedTypes[0] {
+ return nil, &NotFoundError{label: item.Label}
}
return nil, &NotLoadedError{edge: "item"}
}
@@ -63,12 +61,10 @@ func (e AttachmentEdges) ItemOrErr() (*Item, error) {
// DocumentOrErr returns the Document value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e AttachmentEdges) DocumentOrErr() (*Document, error) {
- if e.loadedTypes[1] {
- if e.Document == nil {
- // Edge was loaded but was not found.
- return nil, &NotFoundError{label: document.Label}
- }
+ if e.Document != nil {
return e.Document, nil
+ } else if e.loadedTypes[1] {
+ return nil, &NotFoundError{label: document.Label}
}
return nil, &NotLoadedError{edge: "document"}
}
diff --git a/backend/internal/data/ent/attachment_create.go b/backend/internal/data/ent/attachment_create.go
index 888a7141..3f154f12 100644
--- a/backend/internal/data/ent/attachment_create.go
+++ b/backend/internal/data/ent/attachment_create.go
@@ -191,10 +191,10 @@ func (ac *AttachmentCreate) check() error {
if _, ok := ac.mutation.Primary(); !ok {
return &ValidationError{Name: "primary", err: errors.New(`ent: missing required field "Attachment.primary"`)}
}
- if _, ok := ac.mutation.ItemID(); !ok {
+ if len(ac.mutation.ItemIDs()) == 0 {
return &ValidationError{Name: "item", err: errors.New(`ent: missing required edge "Attachment.item"`)}
}
- if _, ok := ac.mutation.DocumentID(); !ok {
+ if len(ac.mutation.DocumentIDs()) == 0 {
return &ValidationError{Name: "document", err: errors.New(`ent: missing required edge "Attachment.document"`)}
}
return nil
diff --git a/backend/internal/data/ent/attachment_query.go b/backend/internal/data/ent/attachment_query.go
index 0dc087db..70d5b428 100644
--- a/backend/internal/data/ent/attachment_query.go
+++ b/backend/internal/data/ent/attachment_query.go
@@ -7,6 +7,7 @@ import (
"fmt"
"math"
+ "entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -110,7 +111,7 @@ func (aq *AttachmentQuery) QueryDocument() *DocumentQuery {
// First returns the first Attachment entity from the query.
// Returns a *NotFoundError when no Attachment was found.
func (aq *AttachmentQuery) First(ctx context.Context) (*Attachment, error) {
- nodes, err := aq.Limit(1).All(setContextOp(ctx, aq.ctx, "First"))
+ nodes, err := aq.Limit(1).All(setContextOp(ctx, aq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@@ -133,7 +134,7 @@ func (aq *AttachmentQuery) FirstX(ctx context.Context) *Attachment {
// Returns a *NotFoundError when no Attachment ID was found.
func (aq *AttachmentQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = aq.Limit(1).IDs(setContextOp(ctx, aq.ctx, "FirstID")); err != nil {
+ if ids, err = aq.Limit(1).IDs(setContextOp(ctx, aq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@@ -156,7 +157,7 @@ func (aq *AttachmentQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one Attachment entity is found.
// Returns a *NotFoundError when no Attachment entities are found.
func (aq *AttachmentQuery) Only(ctx context.Context) (*Attachment, error) {
- nodes, err := aq.Limit(2).All(setContextOp(ctx, aq.ctx, "Only"))
+ nodes, err := aq.Limit(2).All(setContextOp(ctx, aq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@@ -184,7 +185,7 @@ func (aq *AttachmentQuery) OnlyX(ctx context.Context) *Attachment {
// Returns a *NotFoundError when no entities are found.
func (aq *AttachmentQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = aq.Limit(2).IDs(setContextOp(ctx, aq.ctx, "OnlyID")); err != nil {
+ if ids, err = aq.Limit(2).IDs(setContextOp(ctx, aq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@@ -209,7 +210,7 @@ func (aq *AttachmentQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of Attachments.
func (aq *AttachmentQuery) All(ctx context.Context) ([]*Attachment, error) {
- ctx = setContextOp(ctx, aq.ctx, "All")
+ ctx = setContextOp(ctx, aq.ctx, ent.OpQueryAll)
if err := aq.prepareQuery(ctx); err != nil {
return nil, err
}
@@ -231,7 +232,7 @@ func (aq *AttachmentQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error)
if aq.ctx.Unique == nil && aq.path != nil {
aq.Unique(true)
}
- ctx = setContextOp(ctx, aq.ctx, "IDs")
+ ctx = setContextOp(ctx, aq.ctx, ent.OpQueryIDs)
if err = aq.Select(attachment.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@@ -249,7 +250,7 @@ func (aq *AttachmentQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query.
func (aq *AttachmentQuery) Count(ctx context.Context) (int, error) {
- ctx = setContextOp(ctx, aq.ctx, "Count")
+ ctx = setContextOp(ctx, aq.ctx, ent.OpQueryCount)
if err := aq.prepareQuery(ctx); err != nil {
return 0, err
}
@@ -267,7 +268,7 @@ func (aq *AttachmentQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (aq *AttachmentQuery) Exist(ctx context.Context) (bool, error) {
- ctx = setContextOp(ctx, aq.ctx, "Exist")
+ ctx = setContextOp(ctx, aq.ctx, ent.OpQueryExist)
switch _, err := aq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@@ -612,7 +613,7 @@ func (agb *AttachmentGroupBy) Aggregate(fns ...AggregateFunc) *AttachmentGroupBy
// Scan applies the selector query and scans the result into the given value.
func (agb *AttachmentGroupBy) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, agb.build.ctx, "GroupBy")
+ ctx = setContextOp(ctx, agb.build.ctx, ent.OpQueryGroupBy)
if err := agb.build.prepareQuery(ctx); err != nil {
return err
}
@@ -660,7 +661,7 @@ func (as *AttachmentSelect) Aggregate(fns ...AggregateFunc) *AttachmentSelect {
// Scan applies the selector query and scans the result into the given value.
func (as *AttachmentSelect) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, as.ctx, "Select")
+ ctx = setContextOp(ctx, as.ctx, ent.OpQuerySelect)
if err := as.prepareQuery(ctx); err != nil {
return err
}
diff --git a/backend/internal/data/ent/attachment_update.go b/backend/internal/data/ent/attachment_update.go
index 611747f7..2e57847d 100644
--- a/backend/internal/data/ent/attachment_update.go
+++ b/backend/internal/data/ent/attachment_update.go
@@ -147,10 +147,10 @@ func (au *AttachmentUpdate) check() error {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Attachment.type": %w`, err)}
}
}
- if _, ok := au.mutation.ItemID(); au.mutation.ItemCleared() && !ok {
+ if au.mutation.ItemCleared() && len(au.mutation.ItemIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "Attachment.item"`)
}
- if _, ok := au.mutation.DocumentID(); au.mutation.DocumentCleared() && !ok {
+ if au.mutation.DocumentCleared() && len(au.mutation.DocumentIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "Attachment.document"`)
}
return nil
@@ -384,10 +384,10 @@ func (auo *AttachmentUpdateOne) check() error {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Attachment.type": %w`, err)}
}
}
- if _, ok := auo.mutation.ItemID(); auo.mutation.ItemCleared() && !ok {
+ if auo.mutation.ItemCleared() && len(auo.mutation.ItemIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "Attachment.item"`)
}
- if _, ok := auo.mutation.DocumentID(); auo.mutation.DocumentCleared() && !ok {
+ if auo.mutation.DocumentCleared() && len(auo.mutation.DocumentIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "Attachment.document"`)
}
return nil
diff --git a/backend/internal/data/ent/authroles.go b/backend/internal/data/ent/authroles.go
index e996839b..2192ef93 100644
--- a/backend/internal/data/ent/authroles.go
+++ b/backend/internal/data/ent/authroles.go
@@ -39,12 +39,10 @@ type AuthRolesEdges struct {
// TokenOrErr returns the Token value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e AuthRolesEdges) TokenOrErr() (*AuthTokens, error) {
- if e.loadedTypes[0] {
- if e.Token == nil {
- // Edge was loaded but was not found.
- return nil, &NotFoundError{label: authtokens.Label}
- }
+ if e.Token != nil {
return e.Token, nil
+ } else if e.loadedTypes[0] {
+ return nil, &NotFoundError{label: authtokens.Label}
}
return nil, &NotLoadedError{edge: "token"}
}
diff --git a/backend/internal/data/ent/authroles_query.go b/backend/internal/data/ent/authroles_query.go
index c850fd1d..ef361228 100644
--- a/backend/internal/data/ent/authroles_query.go
+++ b/backend/internal/data/ent/authroles_query.go
@@ -7,6 +7,7 @@ import (
"fmt"
"math"
+ "entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -86,7 +87,7 @@ func (arq *AuthRolesQuery) QueryToken() *AuthTokensQuery {
// First returns the first AuthRoles entity from the query.
// Returns a *NotFoundError when no AuthRoles was found.
func (arq *AuthRolesQuery) First(ctx context.Context) (*AuthRoles, error) {
- nodes, err := arq.Limit(1).All(setContextOp(ctx, arq.ctx, "First"))
+ nodes, err := arq.Limit(1).All(setContextOp(ctx, arq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@@ -109,7 +110,7 @@ func (arq *AuthRolesQuery) FirstX(ctx context.Context) *AuthRoles {
// Returns a *NotFoundError when no AuthRoles ID was found.
func (arq *AuthRolesQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
- if ids, err = arq.Limit(1).IDs(setContextOp(ctx, arq.ctx, "FirstID")); err != nil {
+ if ids, err = arq.Limit(1).IDs(setContextOp(ctx, arq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@@ -132,7 +133,7 @@ func (arq *AuthRolesQuery) FirstIDX(ctx context.Context) int {
// Returns a *NotSingularError when more than one AuthRoles entity is found.
// Returns a *NotFoundError when no AuthRoles entities are found.
func (arq *AuthRolesQuery) Only(ctx context.Context) (*AuthRoles, error) {
- nodes, err := arq.Limit(2).All(setContextOp(ctx, arq.ctx, "Only"))
+ nodes, err := arq.Limit(2).All(setContextOp(ctx, arq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@@ -160,7 +161,7 @@ func (arq *AuthRolesQuery) OnlyX(ctx context.Context) *AuthRoles {
// Returns a *NotFoundError when no entities are found.
func (arq *AuthRolesQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
- if ids, err = arq.Limit(2).IDs(setContextOp(ctx, arq.ctx, "OnlyID")); err != nil {
+ if ids, err = arq.Limit(2).IDs(setContextOp(ctx, arq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@@ -185,7 +186,7 @@ func (arq *AuthRolesQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of AuthRolesSlice.
func (arq *AuthRolesQuery) All(ctx context.Context) ([]*AuthRoles, error) {
- ctx = setContextOp(ctx, arq.ctx, "All")
+ ctx = setContextOp(ctx, arq.ctx, ent.OpQueryAll)
if err := arq.prepareQuery(ctx); err != nil {
return nil, err
}
@@ -207,7 +208,7 @@ func (arq *AuthRolesQuery) IDs(ctx context.Context) (ids []int, err error) {
if arq.ctx.Unique == nil && arq.path != nil {
arq.Unique(true)
}
- ctx = setContextOp(ctx, arq.ctx, "IDs")
+ ctx = setContextOp(ctx, arq.ctx, ent.OpQueryIDs)
if err = arq.Select(authroles.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@@ -225,7 +226,7 @@ func (arq *AuthRolesQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query.
func (arq *AuthRolesQuery) Count(ctx context.Context) (int, error) {
- ctx = setContextOp(ctx, arq.ctx, "Count")
+ ctx = setContextOp(ctx, arq.ctx, ent.OpQueryCount)
if err := arq.prepareQuery(ctx); err != nil {
return 0, err
}
@@ -243,7 +244,7 @@ func (arq *AuthRolesQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (arq *AuthRolesQuery) Exist(ctx context.Context) (bool, error) {
- ctx = setContextOp(ctx, arq.ctx, "Exist")
+ ctx = setContextOp(ctx, arq.ctx, ent.OpQueryExist)
switch _, err := arq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@@ -537,7 +538,7 @@ func (argb *AuthRolesGroupBy) Aggregate(fns ...AggregateFunc) *AuthRolesGroupBy
// Scan applies the selector query and scans the result into the given value.
func (argb *AuthRolesGroupBy) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, argb.build.ctx, "GroupBy")
+ ctx = setContextOp(ctx, argb.build.ctx, ent.OpQueryGroupBy)
if err := argb.build.prepareQuery(ctx); err != nil {
return err
}
@@ -585,7 +586,7 @@ func (ars *AuthRolesSelect) Aggregate(fns ...AggregateFunc) *AuthRolesSelect {
// Scan applies the selector query and scans the result into the given value.
func (ars *AuthRolesSelect) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, ars.ctx, "Select")
+ ctx = setContextOp(ctx, ars.ctx, ent.OpQuerySelect)
if err := ars.prepareQuery(ctx); err != nil {
return err
}
diff --git a/backend/internal/data/ent/authtokens.go b/backend/internal/data/ent/authtokens.go
index 40fdbb47..03845acd 100644
--- a/backend/internal/data/ent/authtokens.go
+++ b/backend/internal/data/ent/authtokens.go
@@ -49,12 +49,10 @@ type AuthTokensEdges struct {
// UserOrErr returns the User value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e AuthTokensEdges) UserOrErr() (*User, error) {
- if e.loadedTypes[0] {
- if e.User == nil {
- // Edge was loaded but was not found.
- return nil, &NotFoundError{label: user.Label}
- }
+ if e.User != nil {
return e.User, nil
+ } else if e.loadedTypes[0] {
+ return nil, &NotFoundError{label: user.Label}
}
return nil, &NotLoadedError{edge: "user"}
}
@@ -62,12 +60,10 @@ func (e AuthTokensEdges) UserOrErr() (*User, error) {
// RolesOrErr returns the Roles value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e AuthTokensEdges) RolesOrErr() (*AuthRoles, error) {
- if e.loadedTypes[1] {
- if e.Roles == nil {
- // Edge was loaded but was not found.
- return nil, &NotFoundError{label: authroles.Label}
- }
+ if e.Roles != nil {
return e.Roles, nil
+ } else if e.loadedTypes[1] {
+ return nil, &NotFoundError{label: authroles.Label}
}
return nil, &NotLoadedError{edge: "roles"}
}
diff --git a/backend/internal/data/ent/authtokens_query.go b/backend/internal/data/ent/authtokens_query.go
index 2f4bd563..e645e412 100644
--- a/backend/internal/data/ent/authtokens_query.go
+++ b/backend/internal/data/ent/authtokens_query.go
@@ -8,6 +8,7 @@ import (
"fmt"
"math"
+ "entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -111,7 +112,7 @@ func (atq *AuthTokensQuery) QueryRoles() *AuthRolesQuery {
// First returns the first AuthTokens entity from the query.
// Returns a *NotFoundError when no AuthTokens was found.
func (atq *AuthTokensQuery) First(ctx context.Context) (*AuthTokens, error) {
- nodes, err := atq.Limit(1).All(setContextOp(ctx, atq.ctx, "First"))
+ nodes, err := atq.Limit(1).All(setContextOp(ctx, atq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@@ -134,7 +135,7 @@ func (atq *AuthTokensQuery) FirstX(ctx context.Context) *AuthTokens {
// Returns a *NotFoundError when no AuthTokens ID was found.
func (atq *AuthTokensQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = atq.Limit(1).IDs(setContextOp(ctx, atq.ctx, "FirstID")); err != nil {
+ if ids, err = atq.Limit(1).IDs(setContextOp(ctx, atq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@@ -157,7 +158,7 @@ func (atq *AuthTokensQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one AuthTokens entity is found.
// Returns a *NotFoundError when no AuthTokens entities are found.
func (atq *AuthTokensQuery) Only(ctx context.Context) (*AuthTokens, error) {
- nodes, err := atq.Limit(2).All(setContextOp(ctx, atq.ctx, "Only"))
+ nodes, err := atq.Limit(2).All(setContextOp(ctx, atq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@@ -185,7 +186,7 @@ func (atq *AuthTokensQuery) OnlyX(ctx context.Context) *AuthTokens {
// Returns a *NotFoundError when no entities are found.
func (atq *AuthTokensQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = atq.Limit(2).IDs(setContextOp(ctx, atq.ctx, "OnlyID")); err != nil {
+ if ids, err = atq.Limit(2).IDs(setContextOp(ctx, atq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@@ -210,7 +211,7 @@ func (atq *AuthTokensQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of AuthTokensSlice.
func (atq *AuthTokensQuery) All(ctx context.Context) ([]*AuthTokens, error) {
- ctx = setContextOp(ctx, atq.ctx, "All")
+ ctx = setContextOp(ctx, atq.ctx, ent.OpQueryAll)
if err := atq.prepareQuery(ctx); err != nil {
return nil, err
}
@@ -232,7 +233,7 @@ func (atq *AuthTokensQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error
if atq.ctx.Unique == nil && atq.path != nil {
atq.Unique(true)
}
- ctx = setContextOp(ctx, atq.ctx, "IDs")
+ ctx = setContextOp(ctx, atq.ctx, ent.OpQueryIDs)
if err = atq.Select(authtokens.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@@ -250,7 +251,7 @@ func (atq *AuthTokensQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query.
func (atq *AuthTokensQuery) Count(ctx context.Context) (int, error) {
- ctx = setContextOp(ctx, atq.ctx, "Count")
+ ctx = setContextOp(ctx, atq.ctx, ent.OpQueryCount)
if err := atq.prepareQuery(ctx); err != nil {
return 0, err
}
@@ -268,7 +269,7 @@ func (atq *AuthTokensQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (atq *AuthTokensQuery) Exist(ctx context.Context) (bool, error) {
- ctx = setContextOp(ctx, atq.ctx, "Exist")
+ ctx = setContextOp(ctx, atq.ctx, ent.OpQueryExist)
switch _, err := atq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@@ -609,7 +610,7 @@ func (atgb *AuthTokensGroupBy) Aggregate(fns ...AggregateFunc) *AuthTokensGroupB
// Scan applies the selector query and scans the result into the given value.
func (atgb *AuthTokensGroupBy) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, atgb.build.ctx, "GroupBy")
+ ctx = setContextOp(ctx, atgb.build.ctx, ent.OpQueryGroupBy)
if err := atgb.build.prepareQuery(ctx); err != nil {
return err
}
@@ -657,7 +658,7 @@ func (ats *AuthTokensSelect) Aggregate(fns ...AggregateFunc) *AuthTokensSelect {
// Scan applies the selector query and scans the result into the given value.
func (ats *AuthTokensSelect) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, ats.ctx, "Select")
+ ctx = setContextOp(ctx, ats.ctx, ent.OpQuerySelect)
if err := ats.prepareQuery(ctx); err != nil {
return err
}
diff --git a/backend/internal/data/ent/document.go b/backend/internal/data/ent/document.go
index 5acc1c35..9455512d 100644
--- a/backend/internal/data/ent/document.go
+++ b/backend/internal/data/ent/document.go
@@ -48,12 +48,10 @@ type DocumentEdges struct {
// GroupOrErr returns the Group value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e DocumentEdges) GroupOrErr() (*Group, error) {
- if e.loadedTypes[0] {
- if e.Group == nil {
- // Edge was loaded but was not found.
- return nil, &NotFoundError{label: group.Label}
- }
+ if e.Group != nil {
return e.Group, nil
+ } else if e.loadedTypes[0] {
+ return nil, &NotFoundError{label: group.Label}
}
return nil, &NotLoadedError{edge: "group"}
}
diff --git a/backend/internal/data/ent/document_create.go b/backend/internal/data/ent/document_create.go
index 9d666381..715a669d 100644
--- a/backend/internal/data/ent/document_create.go
+++ b/backend/internal/data/ent/document_create.go
@@ -176,7 +176,7 @@ func (dc *DocumentCreate) check() error {
return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Document.path": %w`, err)}
}
}
- if _, ok := dc.mutation.GroupID(); !ok {
+ if len(dc.mutation.GroupIDs()) == 0 {
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "Document.group"`)}
}
return nil
diff --git a/backend/internal/data/ent/document_query.go b/backend/internal/data/ent/document_query.go
index 479eac71..b73ff46c 100644
--- a/backend/internal/data/ent/document_query.go
+++ b/backend/internal/data/ent/document_query.go
@@ -8,6 +8,7 @@ import (
"fmt"
"math"
+ "entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -111,7 +112,7 @@ func (dq *DocumentQuery) QueryAttachments() *AttachmentQuery {
// First returns the first Document entity from the query.
// Returns a *NotFoundError when no Document was found.
func (dq *DocumentQuery) First(ctx context.Context) (*Document, error) {
- nodes, err := dq.Limit(1).All(setContextOp(ctx, dq.ctx, "First"))
+ nodes, err := dq.Limit(1).All(setContextOp(ctx, dq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@@ -134,7 +135,7 @@ func (dq *DocumentQuery) FirstX(ctx context.Context) *Document {
// Returns a *NotFoundError when no Document ID was found.
func (dq *DocumentQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = dq.Limit(1).IDs(setContextOp(ctx, dq.ctx, "FirstID")); err != nil {
+ if ids, err = dq.Limit(1).IDs(setContextOp(ctx, dq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@@ -157,7 +158,7 @@ func (dq *DocumentQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one Document entity is found.
// Returns a *NotFoundError when no Document entities are found.
func (dq *DocumentQuery) Only(ctx context.Context) (*Document, error) {
- nodes, err := dq.Limit(2).All(setContextOp(ctx, dq.ctx, "Only"))
+ nodes, err := dq.Limit(2).All(setContextOp(ctx, dq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@@ -185,7 +186,7 @@ func (dq *DocumentQuery) OnlyX(ctx context.Context) *Document {
// Returns a *NotFoundError when no entities are found.
func (dq *DocumentQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = dq.Limit(2).IDs(setContextOp(ctx, dq.ctx, "OnlyID")); err != nil {
+ if ids, err = dq.Limit(2).IDs(setContextOp(ctx, dq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@@ -210,7 +211,7 @@ func (dq *DocumentQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of Documents.
func (dq *DocumentQuery) All(ctx context.Context) ([]*Document, error) {
- ctx = setContextOp(ctx, dq.ctx, "All")
+ ctx = setContextOp(ctx, dq.ctx, ent.OpQueryAll)
if err := dq.prepareQuery(ctx); err != nil {
return nil, err
}
@@ -232,7 +233,7 @@ func (dq *DocumentQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if dq.ctx.Unique == nil && dq.path != nil {
dq.Unique(true)
}
- ctx = setContextOp(ctx, dq.ctx, "IDs")
+ ctx = setContextOp(ctx, dq.ctx, ent.OpQueryIDs)
if err = dq.Select(document.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@@ -250,7 +251,7 @@ func (dq *DocumentQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query.
func (dq *DocumentQuery) Count(ctx context.Context) (int, error) {
- ctx = setContextOp(ctx, dq.ctx, "Count")
+ ctx = setContextOp(ctx, dq.ctx, ent.OpQueryCount)
if err := dq.prepareQuery(ctx); err != nil {
return 0, err
}
@@ -268,7 +269,7 @@ func (dq *DocumentQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (dq *DocumentQuery) Exist(ctx context.Context) (bool, error) {
- ctx = setContextOp(ctx, dq.ctx, "Exist")
+ ctx = setContextOp(ctx, dq.ctx, ent.OpQueryExist)
switch _, err := dq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@@ -613,7 +614,7 @@ func (dgb *DocumentGroupBy) Aggregate(fns ...AggregateFunc) *DocumentGroupBy {
// Scan applies the selector query and scans the result into the given value.
func (dgb *DocumentGroupBy) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, dgb.build.ctx, "GroupBy")
+ ctx = setContextOp(ctx, dgb.build.ctx, ent.OpQueryGroupBy)
if err := dgb.build.prepareQuery(ctx); err != nil {
return err
}
@@ -661,7 +662,7 @@ func (ds *DocumentSelect) Aggregate(fns ...AggregateFunc) *DocumentSelect {
// Scan applies the selector query and scans the result into the given value.
func (ds *DocumentSelect) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, ds.ctx, "Select")
+ ctx = setContextOp(ctx, ds.ctx, ent.OpQuerySelect)
if err := ds.prepareQuery(ctx); err != nil {
return err
}
diff --git a/backend/internal/data/ent/document_update.go b/backend/internal/data/ent/document_update.go
index fac957b5..0cef5c97 100644
--- a/backend/internal/data/ent/document_update.go
+++ b/backend/internal/data/ent/document_update.go
@@ -171,7 +171,7 @@ func (du *DocumentUpdate) check() error {
return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Document.path": %w`, err)}
}
}
- if _, ok := du.mutation.GroupID(); du.mutation.GroupCleared() && !ok {
+ if du.mutation.GroupCleared() && len(du.mutation.GroupIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "Document.group"`)
}
return nil
@@ -445,7 +445,7 @@ func (duo *DocumentUpdateOne) check() error {
return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Document.path": %w`, err)}
}
}
- if _, ok := duo.mutation.GroupID(); duo.mutation.GroupCleared() && !ok {
+ if duo.mutation.GroupCleared() && len(duo.mutation.GroupIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "Document.group"`)
}
return nil
diff --git a/backend/internal/data/ent/ent.go b/backend/internal/data/ent/ent.go
index 8a0ddc4e..0532cd23 100644
--- a/backend/internal/data/ent/ent.go
+++ b/backend/internal/data/ent/ent.go
@@ -81,7 +81,7 @@ var (
columnCheck sql.ColumnCheck
)
-// columnChecker checks if the column exists in the given table.
+// checkColumn checks if the column exists in the given table.
func checkColumn(table, column string) error {
initCheck.Do(func() {
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
diff --git a/backend/internal/data/ent/group_query.go b/backend/internal/data/ent/group_query.go
index 6f8aa70f..7067c169 100644
--- a/backend/internal/data/ent/group_query.go
+++ b/backend/internal/data/ent/group_query.go
@@ -8,6 +8,7 @@ import (
"fmt"
"math"
+ "entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -230,7 +231,7 @@ func (gq *GroupQuery) QueryNotifiers() *NotifierQuery {
// First returns the first Group entity from the query.
// Returns a *NotFoundError when no Group was found.
func (gq *GroupQuery) First(ctx context.Context) (*Group, error) {
- nodes, err := gq.Limit(1).All(setContextOp(ctx, gq.ctx, "First"))
+ nodes, err := gq.Limit(1).All(setContextOp(ctx, gq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@@ -253,7 +254,7 @@ func (gq *GroupQuery) FirstX(ctx context.Context) *Group {
// Returns a *NotFoundError when no Group ID was found.
func (gq *GroupQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = gq.Limit(1).IDs(setContextOp(ctx, gq.ctx, "FirstID")); err != nil {
+ if ids, err = gq.Limit(1).IDs(setContextOp(ctx, gq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@@ -276,7 +277,7 @@ func (gq *GroupQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one Group entity is found.
// Returns a *NotFoundError when no Group entities are found.
func (gq *GroupQuery) Only(ctx context.Context) (*Group, error) {
- nodes, err := gq.Limit(2).All(setContextOp(ctx, gq.ctx, "Only"))
+ nodes, err := gq.Limit(2).All(setContextOp(ctx, gq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@@ -304,7 +305,7 @@ func (gq *GroupQuery) OnlyX(ctx context.Context) *Group {
// Returns a *NotFoundError when no entities are found.
func (gq *GroupQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = gq.Limit(2).IDs(setContextOp(ctx, gq.ctx, "OnlyID")); err != nil {
+ if ids, err = gq.Limit(2).IDs(setContextOp(ctx, gq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@@ -329,7 +330,7 @@ func (gq *GroupQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of Groups.
func (gq *GroupQuery) All(ctx context.Context) ([]*Group, error) {
- ctx = setContextOp(ctx, gq.ctx, "All")
+ ctx = setContextOp(ctx, gq.ctx, ent.OpQueryAll)
if err := gq.prepareQuery(ctx); err != nil {
return nil, err
}
@@ -351,7 +352,7 @@ func (gq *GroupQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if gq.ctx.Unique == nil && gq.path != nil {
gq.Unique(true)
}
- ctx = setContextOp(ctx, gq.ctx, "IDs")
+ ctx = setContextOp(ctx, gq.ctx, ent.OpQueryIDs)
if err = gq.Select(group.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@@ -369,7 +370,7 @@ func (gq *GroupQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query.
func (gq *GroupQuery) Count(ctx context.Context) (int, error) {
- ctx = setContextOp(ctx, gq.ctx, "Count")
+ ctx = setContextOp(ctx, gq.ctx, ent.OpQueryCount)
if err := gq.prepareQuery(ctx); err != nil {
return 0, err
}
@@ -387,7 +388,7 @@ func (gq *GroupQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (gq *GroupQuery) Exist(ctx context.Context) (bool, error) {
- ctx = setContextOp(ctx, gq.ctx, "Exist")
+ ctx = setContextOp(ctx, gq.ctx, ent.OpQueryExist)
switch _, err := gq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@@ -981,7 +982,7 @@ func (ggb *GroupGroupBy) Aggregate(fns ...AggregateFunc) *GroupGroupBy {
// Scan applies the selector query and scans the result into the given value.
func (ggb *GroupGroupBy) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, ggb.build.ctx, "GroupBy")
+ ctx = setContextOp(ctx, ggb.build.ctx, ent.OpQueryGroupBy)
if err := ggb.build.prepareQuery(ctx); err != nil {
return err
}
@@ -1029,7 +1030,7 @@ func (gs *GroupSelect) Aggregate(fns ...AggregateFunc) *GroupSelect {
// Scan applies the selector query and scans the result into the given value.
func (gs *GroupSelect) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, gs.ctx, "Select")
+ ctx = setContextOp(ctx, gs.ctx, ent.OpQuerySelect)
if err := gs.prepareQuery(ctx); err != nil {
return err
}
diff --git a/backend/internal/data/ent/groupinvitationtoken.go b/backend/internal/data/ent/groupinvitationtoken.go
index 239614a9..4e5d3d5c 100644
--- a/backend/internal/data/ent/groupinvitationtoken.go
+++ b/backend/internal/data/ent/groupinvitationtoken.go
@@ -48,12 +48,10 @@ type GroupInvitationTokenEdges struct {
// GroupOrErr returns the Group value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e GroupInvitationTokenEdges) GroupOrErr() (*Group, error) {
- if e.loadedTypes[0] {
- if e.Group == nil {
- // Edge was loaded but was not found.
- return nil, &NotFoundError{label: group.Label}
- }
+ if e.Group != nil {
return e.Group, nil
+ } else if e.loadedTypes[0] {
+ return nil, &NotFoundError{label: group.Label}
}
return nil, &NotLoadedError{edge: "group"}
}
diff --git a/backend/internal/data/ent/groupinvitationtoken_query.go b/backend/internal/data/ent/groupinvitationtoken_query.go
index bebf8533..dfd78746 100644
--- a/backend/internal/data/ent/groupinvitationtoken_query.go
+++ b/backend/internal/data/ent/groupinvitationtoken_query.go
@@ -7,6 +7,7 @@ import (
"fmt"
"math"
+ "entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -86,7 +87,7 @@ func (gitq *GroupInvitationTokenQuery) QueryGroup() *GroupQuery {
// First returns the first GroupInvitationToken entity from the query.
// Returns a *NotFoundError when no GroupInvitationToken was found.
func (gitq *GroupInvitationTokenQuery) First(ctx context.Context) (*GroupInvitationToken, error) {
- nodes, err := gitq.Limit(1).All(setContextOp(ctx, gitq.ctx, "First"))
+ nodes, err := gitq.Limit(1).All(setContextOp(ctx, gitq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@@ -109,7 +110,7 @@ func (gitq *GroupInvitationTokenQuery) FirstX(ctx context.Context) *GroupInvitat
// Returns a *NotFoundError when no GroupInvitationToken ID was found.
func (gitq *GroupInvitationTokenQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = gitq.Limit(1).IDs(setContextOp(ctx, gitq.ctx, "FirstID")); err != nil {
+ if ids, err = gitq.Limit(1).IDs(setContextOp(ctx, gitq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@@ -132,7 +133,7 @@ func (gitq *GroupInvitationTokenQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one GroupInvitationToken entity is found.
// Returns a *NotFoundError when no GroupInvitationToken entities are found.
func (gitq *GroupInvitationTokenQuery) Only(ctx context.Context) (*GroupInvitationToken, error) {
- nodes, err := gitq.Limit(2).All(setContextOp(ctx, gitq.ctx, "Only"))
+ nodes, err := gitq.Limit(2).All(setContextOp(ctx, gitq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@@ -160,7 +161,7 @@ func (gitq *GroupInvitationTokenQuery) OnlyX(ctx context.Context) *GroupInvitati
// Returns a *NotFoundError when no entities are found.
func (gitq *GroupInvitationTokenQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = gitq.Limit(2).IDs(setContextOp(ctx, gitq.ctx, "OnlyID")); err != nil {
+ if ids, err = gitq.Limit(2).IDs(setContextOp(ctx, gitq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@@ -185,7 +186,7 @@ func (gitq *GroupInvitationTokenQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of GroupInvitationTokens.
func (gitq *GroupInvitationTokenQuery) All(ctx context.Context) ([]*GroupInvitationToken, error) {
- ctx = setContextOp(ctx, gitq.ctx, "All")
+ ctx = setContextOp(ctx, gitq.ctx, ent.OpQueryAll)
if err := gitq.prepareQuery(ctx); err != nil {
return nil, err
}
@@ -207,7 +208,7 @@ func (gitq *GroupInvitationTokenQuery) IDs(ctx context.Context) (ids []uuid.UUID
if gitq.ctx.Unique == nil && gitq.path != nil {
gitq.Unique(true)
}
- ctx = setContextOp(ctx, gitq.ctx, "IDs")
+ ctx = setContextOp(ctx, gitq.ctx, ent.OpQueryIDs)
if err = gitq.Select(groupinvitationtoken.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@@ -225,7 +226,7 @@ func (gitq *GroupInvitationTokenQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query.
func (gitq *GroupInvitationTokenQuery) Count(ctx context.Context) (int, error) {
- ctx = setContextOp(ctx, gitq.ctx, "Count")
+ ctx = setContextOp(ctx, gitq.ctx, ent.OpQueryCount)
if err := gitq.prepareQuery(ctx); err != nil {
return 0, err
}
@@ -243,7 +244,7 @@ func (gitq *GroupInvitationTokenQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (gitq *GroupInvitationTokenQuery) Exist(ctx context.Context) (bool, error) {
- ctx = setContextOp(ctx, gitq.ctx, "Exist")
+ ctx = setContextOp(ctx, gitq.ctx, ent.OpQueryExist)
switch _, err := gitq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@@ -537,7 +538,7 @@ func (gitgb *GroupInvitationTokenGroupBy) Aggregate(fns ...AggregateFunc) *Group
// Scan applies the selector query and scans the result into the given value.
func (gitgb *GroupInvitationTokenGroupBy) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, gitgb.build.ctx, "GroupBy")
+ ctx = setContextOp(ctx, gitgb.build.ctx, ent.OpQueryGroupBy)
if err := gitgb.build.prepareQuery(ctx); err != nil {
return err
}
@@ -585,7 +586,7 @@ func (gits *GroupInvitationTokenSelect) Aggregate(fns ...AggregateFunc) *GroupIn
// Scan applies the selector query and scans the result into the given value.
func (gits *GroupInvitationTokenSelect) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, gits.ctx, "Select")
+ ctx = setContextOp(ctx, gits.ctx, ent.OpQuerySelect)
if err := gits.prepareQuery(ctx); err != nil {
return err
}
diff --git a/backend/internal/data/ent/item.go b/backend/internal/data/ent/item.go
index 8ce24934..682616b0 100644
--- a/backend/internal/data/ent/item.go
+++ b/backend/internal/data/ent/item.go
@@ -101,12 +101,10 @@ type ItemEdges struct {
// GroupOrErr returns the Group value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e ItemEdges) GroupOrErr() (*Group, error) {
- if e.loadedTypes[0] {
- if e.Group == nil {
- // Edge was loaded but was not found.
- return nil, &NotFoundError{label: group.Label}
- }
+ if e.Group != nil {
return e.Group, nil
+ } else if e.loadedTypes[0] {
+ return nil, &NotFoundError{label: group.Label}
}
return nil, &NotLoadedError{edge: "group"}
}
@@ -114,12 +112,10 @@ func (e ItemEdges) GroupOrErr() (*Group, error) {
// ParentOrErr returns the Parent value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e ItemEdges) ParentOrErr() (*Item, error) {
- if e.loadedTypes[1] {
- if e.Parent == nil {
- // Edge was loaded but was not found.
- return nil, &NotFoundError{label: item.Label}
- }
+ if e.Parent != nil {
return e.Parent, nil
+ } else if e.loadedTypes[1] {
+ return nil, &NotFoundError{label: item.Label}
}
return nil, &NotLoadedError{edge: "parent"}
}
@@ -145,12 +141,10 @@ func (e ItemEdges) LabelOrErr() ([]*Label, error) {
// LocationOrErr returns the Location value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e ItemEdges) LocationOrErr() (*Location, error) {
- if e.loadedTypes[4] {
- if e.Location == nil {
- // Edge was loaded but was not found.
- return nil, &NotFoundError{label: location.Label}
- }
+ if e.Location != nil {
return e.Location, nil
+ } else if e.loadedTypes[4] {
+ return nil, &NotFoundError{label: location.Label}
}
return nil, &NotLoadedError{edge: "location"}
}
diff --git a/backend/internal/data/ent/item_create.go b/backend/internal/data/ent/item_create.go
index 0bdc2c79..97ed01ea 100644
--- a/backend/internal/data/ent/item_create.go
+++ b/backend/internal/data/ent/item_create.go
@@ -633,7 +633,7 @@ func (ic *ItemCreate) check() error {
return &ValidationError{Name: "sold_notes", err: fmt.Errorf(`ent: validator failed for field "Item.sold_notes": %w`, err)}
}
}
- if _, ok := ic.mutation.GroupID(); !ok {
+ if len(ic.mutation.GroupIDs()) == 0 {
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "Item.group"`)}
}
return nil
diff --git a/backend/internal/data/ent/item_query.go b/backend/internal/data/ent/item_query.go
index 15028b84..d83ddb89 100644
--- a/backend/internal/data/ent/item_query.go
+++ b/backend/internal/data/ent/item_query.go
@@ -8,6 +8,7 @@ import (
"fmt"
"math"
+ "entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -253,7 +254,7 @@ func (iq *ItemQuery) QueryAttachments() *AttachmentQuery {
// First returns the first Item entity from the query.
// Returns a *NotFoundError when no Item was found.
func (iq *ItemQuery) First(ctx context.Context) (*Item, error) {
- nodes, err := iq.Limit(1).All(setContextOp(ctx, iq.ctx, "First"))
+ nodes, err := iq.Limit(1).All(setContextOp(ctx, iq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@@ -276,7 +277,7 @@ func (iq *ItemQuery) FirstX(ctx context.Context) *Item {
// Returns a *NotFoundError when no Item ID was found.
func (iq *ItemQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = iq.Limit(1).IDs(setContextOp(ctx, iq.ctx, "FirstID")); err != nil {
+ if ids, err = iq.Limit(1).IDs(setContextOp(ctx, iq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@@ -299,7 +300,7 @@ func (iq *ItemQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one Item entity is found.
// Returns a *NotFoundError when no Item entities are found.
func (iq *ItemQuery) Only(ctx context.Context) (*Item, error) {
- nodes, err := iq.Limit(2).All(setContextOp(ctx, iq.ctx, "Only"))
+ nodes, err := iq.Limit(2).All(setContextOp(ctx, iq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@@ -327,7 +328,7 @@ func (iq *ItemQuery) OnlyX(ctx context.Context) *Item {
// Returns a *NotFoundError when no entities are found.
func (iq *ItemQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = iq.Limit(2).IDs(setContextOp(ctx, iq.ctx, "OnlyID")); err != nil {
+ if ids, err = iq.Limit(2).IDs(setContextOp(ctx, iq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@@ -352,7 +353,7 @@ func (iq *ItemQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of Items.
func (iq *ItemQuery) All(ctx context.Context) ([]*Item, error) {
- ctx = setContextOp(ctx, iq.ctx, "All")
+ ctx = setContextOp(ctx, iq.ctx, ent.OpQueryAll)
if err := iq.prepareQuery(ctx); err != nil {
return nil, err
}
@@ -374,7 +375,7 @@ func (iq *ItemQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if iq.ctx.Unique == nil && iq.path != nil {
iq.Unique(true)
}
- ctx = setContextOp(ctx, iq.ctx, "IDs")
+ ctx = setContextOp(ctx, iq.ctx, ent.OpQueryIDs)
if err = iq.Select(item.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@@ -392,7 +393,7 @@ func (iq *ItemQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query.
func (iq *ItemQuery) Count(ctx context.Context) (int, error) {
- ctx = setContextOp(ctx, iq.ctx, "Count")
+ ctx = setContextOp(ctx, iq.ctx, ent.OpQueryCount)
if err := iq.prepareQuery(ctx); err != nil {
return 0, err
}
@@ -410,7 +411,7 @@ func (iq *ItemQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (iq *ItemQuery) Exist(ctx context.Context) (bool, error) {
- ctx = setContextOp(ctx, iq.ctx, "Exist")
+ ctx = setContextOp(ctx, iq.ctx, ent.OpQueryExist)
switch _, err := iq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@@ -1090,7 +1091,7 @@ func (igb *ItemGroupBy) Aggregate(fns ...AggregateFunc) *ItemGroupBy {
// Scan applies the selector query and scans the result into the given value.
func (igb *ItemGroupBy) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, igb.build.ctx, "GroupBy")
+ ctx = setContextOp(ctx, igb.build.ctx, ent.OpQueryGroupBy)
if err := igb.build.prepareQuery(ctx); err != nil {
return err
}
@@ -1138,7 +1139,7 @@ func (is *ItemSelect) Aggregate(fns ...AggregateFunc) *ItemSelect {
// Scan applies the selector query and scans the result into the given value.
func (is *ItemSelect) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, is.ctx, "Select")
+ ctx = setContextOp(ctx, is.ctx, ent.OpQuerySelect)
if err := is.prepareQuery(ctx); err != nil {
return err
}
diff --git a/backend/internal/data/ent/item_update.go b/backend/internal/data/ent/item_update.go
index 57616ab4..16c3464b 100644
--- a/backend/internal/data/ent/item_update.go
+++ b/backend/internal/data/ent/item_update.go
@@ -776,7 +776,7 @@ func (iu *ItemUpdate) check() error {
return &ValidationError{Name: "sold_notes", err: fmt.Errorf(`ent: validator failed for field "Item.sold_notes": %w`, err)}
}
}
- if _, ok := iu.mutation.GroupID(); iu.mutation.GroupCleared() && !ok {
+ if iu.mutation.GroupCleared() && len(iu.mutation.GroupIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "Item.group"`)
}
return nil
@@ -1997,7 +1997,7 @@ func (iuo *ItemUpdateOne) check() error {
return &ValidationError{Name: "sold_notes", err: fmt.Errorf(`ent: validator failed for field "Item.sold_notes": %w`, err)}
}
}
- if _, ok := iuo.mutation.GroupID(); iuo.mutation.GroupCleared() && !ok {
+ if iuo.mutation.GroupCleared() && len(iuo.mutation.GroupIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "Item.group"`)
}
return nil
diff --git a/backend/internal/data/ent/itemfield.go b/backend/internal/data/ent/itemfield.go
index 0c1690cc..f29dcc0d 100644
--- a/backend/internal/data/ent/itemfield.go
+++ b/backend/internal/data/ent/itemfield.go
@@ -56,12 +56,10 @@ type ItemFieldEdges struct {
// ItemOrErr returns the Item value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e ItemFieldEdges) ItemOrErr() (*Item, error) {
- if e.loadedTypes[0] {
- if e.Item == nil {
- // Edge was loaded but was not found.
- return nil, &NotFoundError{label: item.Label}
- }
+ if e.Item != nil {
return e.Item, nil
+ } else if e.loadedTypes[0] {
+ return nil, &NotFoundError{label: item.Label}
}
return nil, &NotLoadedError{edge: "item"}
}
diff --git a/backend/internal/data/ent/itemfield_query.go b/backend/internal/data/ent/itemfield_query.go
index 3c6072a8..a11a1840 100644
--- a/backend/internal/data/ent/itemfield_query.go
+++ b/backend/internal/data/ent/itemfield_query.go
@@ -7,6 +7,7 @@ import (
"fmt"
"math"
+ "entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -86,7 +87,7 @@ func (ifq *ItemFieldQuery) QueryItem() *ItemQuery {
// First returns the first ItemField entity from the query.
// Returns a *NotFoundError when no ItemField was found.
func (ifq *ItemFieldQuery) First(ctx context.Context) (*ItemField, error) {
- nodes, err := ifq.Limit(1).All(setContextOp(ctx, ifq.ctx, "First"))
+ nodes, err := ifq.Limit(1).All(setContextOp(ctx, ifq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@@ -109,7 +110,7 @@ func (ifq *ItemFieldQuery) FirstX(ctx context.Context) *ItemField {
// Returns a *NotFoundError when no ItemField ID was found.
func (ifq *ItemFieldQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = ifq.Limit(1).IDs(setContextOp(ctx, ifq.ctx, "FirstID")); err != nil {
+ if ids, err = ifq.Limit(1).IDs(setContextOp(ctx, ifq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@@ -132,7 +133,7 @@ func (ifq *ItemFieldQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one ItemField entity is found.
// Returns a *NotFoundError when no ItemField entities are found.
func (ifq *ItemFieldQuery) Only(ctx context.Context) (*ItemField, error) {
- nodes, err := ifq.Limit(2).All(setContextOp(ctx, ifq.ctx, "Only"))
+ nodes, err := ifq.Limit(2).All(setContextOp(ctx, ifq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@@ -160,7 +161,7 @@ func (ifq *ItemFieldQuery) OnlyX(ctx context.Context) *ItemField {
// Returns a *NotFoundError when no entities are found.
func (ifq *ItemFieldQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = ifq.Limit(2).IDs(setContextOp(ctx, ifq.ctx, "OnlyID")); err != nil {
+ if ids, err = ifq.Limit(2).IDs(setContextOp(ctx, ifq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@@ -185,7 +186,7 @@ func (ifq *ItemFieldQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of ItemFields.
func (ifq *ItemFieldQuery) All(ctx context.Context) ([]*ItemField, error) {
- ctx = setContextOp(ctx, ifq.ctx, "All")
+ ctx = setContextOp(ctx, ifq.ctx, ent.OpQueryAll)
if err := ifq.prepareQuery(ctx); err != nil {
return nil, err
}
@@ -207,7 +208,7 @@ func (ifq *ItemFieldQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error)
if ifq.ctx.Unique == nil && ifq.path != nil {
ifq.Unique(true)
}
- ctx = setContextOp(ctx, ifq.ctx, "IDs")
+ ctx = setContextOp(ctx, ifq.ctx, ent.OpQueryIDs)
if err = ifq.Select(itemfield.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@@ -225,7 +226,7 @@ func (ifq *ItemFieldQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query.
func (ifq *ItemFieldQuery) Count(ctx context.Context) (int, error) {
- ctx = setContextOp(ctx, ifq.ctx, "Count")
+ ctx = setContextOp(ctx, ifq.ctx, ent.OpQueryCount)
if err := ifq.prepareQuery(ctx); err != nil {
return 0, err
}
@@ -243,7 +244,7 @@ func (ifq *ItemFieldQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (ifq *ItemFieldQuery) Exist(ctx context.Context) (bool, error) {
- ctx = setContextOp(ctx, ifq.ctx, "Exist")
+ ctx = setContextOp(ctx, ifq.ctx, ent.OpQueryExist)
switch _, err := ifq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@@ -537,7 +538,7 @@ func (ifgb *ItemFieldGroupBy) Aggregate(fns ...AggregateFunc) *ItemFieldGroupBy
// Scan applies the selector query and scans the result into the given value.
func (ifgb *ItemFieldGroupBy) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, ifgb.build.ctx, "GroupBy")
+ ctx = setContextOp(ctx, ifgb.build.ctx, ent.OpQueryGroupBy)
if err := ifgb.build.prepareQuery(ctx); err != nil {
return err
}
@@ -585,7 +586,7 @@ func (ifs *ItemFieldSelect) Aggregate(fns ...AggregateFunc) *ItemFieldSelect {
// Scan applies the selector query and scans the result into the given value.
func (ifs *ItemFieldSelect) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, ifs.ctx, "Select")
+ ctx = setContextOp(ctx, ifs.ctx, ent.OpQuerySelect)
if err := ifs.prepareQuery(ctx); err != nil {
return err
}
diff --git a/backend/internal/data/ent/label.go b/backend/internal/data/ent/label.go
index 8af41d34..e2a82a56 100644
--- a/backend/internal/data/ent/label.go
+++ b/backend/internal/data/ent/label.go
@@ -50,12 +50,10 @@ type LabelEdges struct {
// GroupOrErr returns the Group value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e LabelEdges) GroupOrErr() (*Group, error) {
- if e.loadedTypes[0] {
- if e.Group == nil {
- // Edge was loaded but was not found.
- return nil, &NotFoundError{label: group.Label}
- }
+ if e.Group != nil {
return e.Group, nil
+ } else if e.loadedTypes[0] {
+ return nil, &NotFoundError{label: group.Label}
}
return nil, &NotLoadedError{edge: "group"}
}
diff --git a/backend/internal/data/ent/label_create.go b/backend/internal/data/ent/label_create.go
index 42dab66b..7434b815 100644
--- a/backend/internal/data/ent/label_create.go
+++ b/backend/internal/data/ent/label_create.go
@@ -200,7 +200,7 @@ func (lc *LabelCreate) check() error {
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "Label.color": %w`, err)}
}
}
- if _, ok := lc.mutation.GroupID(); !ok {
+ if len(lc.mutation.GroupIDs()) == 0 {
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "Label.group"`)}
}
return nil
diff --git a/backend/internal/data/ent/label_query.go b/backend/internal/data/ent/label_query.go
index e0964fbb..b03c9bfc 100644
--- a/backend/internal/data/ent/label_query.go
+++ b/backend/internal/data/ent/label_query.go
@@ -8,6 +8,7 @@ import (
"fmt"
"math"
+ "entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -111,7 +112,7 @@ func (lq *LabelQuery) QueryItems() *ItemQuery {
// First returns the first Label entity from the query.
// Returns a *NotFoundError when no Label was found.
func (lq *LabelQuery) First(ctx context.Context) (*Label, error) {
- nodes, err := lq.Limit(1).All(setContextOp(ctx, lq.ctx, "First"))
+ nodes, err := lq.Limit(1).All(setContextOp(ctx, lq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@@ -134,7 +135,7 @@ func (lq *LabelQuery) FirstX(ctx context.Context) *Label {
// Returns a *NotFoundError when no Label ID was found.
func (lq *LabelQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = lq.Limit(1).IDs(setContextOp(ctx, lq.ctx, "FirstID")); err != nil {
+ if ids, err = lq.Limit(1).IDs(setContextOp(ctx, lq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@@ -157,7 +158,7 @@ func (lq *LabelQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one Label entity is found.
// Returns a *NotFoundError when no Label entities are found.
func (lq *LabelQuery) Only(ctx context.Context) (*Label, error) {
- nodes, err := lq.Limit(2).All(setContextOp(ctx, lq.ctx, "Only"))
+ nodes, err := lq.Limit(2).All(setContextOp(ctx, lq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@@ -185,7 +186,7 @@ func (lq *LabelQuery) OnlyX(ctx context.Context) *Label {
// Returns a *NotFoundError when no entities are found.
func (lq *LabelQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = lq.Limit(2).IDs(setContextOp(ctx, lq.ctx, "OnlyID")); err != nil {
+ if ids, err = lq.Limit(2).IDs(setContextOp(ctx, lq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@@ -210,7 +211,7 @@ func (lq *LabelQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of Labels.
func (lq *LabelQuery) All(ctx context.Context) ([]*Label, error) {
- ctx = setContextOp(ctx, lq.ctx, "All")
+ ctx = setContextOp(ctx, lq.ctx, ent.OpQueryAll)
if err := lq.prepareQuery(ctx); err != nil {
return nil, err
}
@@ -232,7 +233,7 @@ func (lq *LabelQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if lq.ctx.Unique == nil && lq.path != nil {
lq.Unique(true)
}
- ctx = setContextOp(ctx, lq.ctx, "IDs")
+ ctx = setContextOp(ctx, lq.ctx, ent.OpQueryIDs)
if err = lq.Select(label.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@@ -250,7 +251,7 @@ func (lq *LabelQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query.
func (lq *LabelQuery) Count(ctx context.Context) (int, error) {
- ctx = setContextOp(ctx, lq.ctx, "Count")
+ ctx = setContextOp(ctx, lq.ctx, ent.OpQueryCount)
if err := lq.prepareQuery(ctx); err != nil {
return 0, err
}
@@ -268,7 +269,7 @@ func (lq *LabelQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (lq *LabelQuery) Exist(ctx context.Context) (bool, error) {
- ctx = setContextOp(ctx, lq.ctx, "Exist")
+ ctx = setContextOp(ctx, lq.ctx, ent.OpQueryExist)
switch _, err := lq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@@ -643,7 +644,7 @@ func (lgb *LabelGroupBy) Aggregate(fns ...AggregateFunc) *LabelGroupBy {
// Scan applies the selector query and scans the result into the given value.
func (lgb *LabelGroupBy) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, lgb.build.ctx, "GroupBy")
+ ctx = setContextOp(ctx, lgb.build.ctx, ent.OpQueryGroupBy)
if err := lgb.build.prepareQuery(ctx); err != nil {
return err
}
@@ -691,7 +692,7 @@ func (ls *LabelSelect) Aggregate(fns ...AggregateFunc) *LabelSelect {
// Scan applies the selector query and scans the result into the given value.
func (ls *LabelSelect) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, ls.ctx, "Select")
+ ctx = setContextOp(ctx, ls.ctx, ent.OpQuerySelect)
if err := ls.prepareQuery(ctx); err != nil {
return err
}
diff --git a/backend/internal/data/ent/label_update.go b/backend/internal/data/ent/label_update.go
index 10475eea..1827d392 100644
--- a/backend/internal/data/ent/label_update.go
+++ b/backend/internal/data/ent/label_update.go
@@ -202,7 +202,7 @@ func (lu *LabelUpdate) check() error {
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "Label.color": %w`, err)}
}
}
- if _, ok := lu.mutation.GroupID(); lu.mutation.GroupCleared() && !ok {
+ if lu.mutation.GroupCleared() && len(lu.mutation.GroupIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "Label.group"`)
}
return nil
@@ -516,7 +516,7 @@ func (luo *LabelUpdateOne) check() error {
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "Label.color": %w`, err)}
}
}
- if _, ok := luo.mutation.GroupID(); luo.mutation.GroupCleared() && !ok {
+ if luo.mutation.GroupCleared() && len(luo.mutation.GroupIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "Label.group"`)
}
return nil
diff --git a/backend/internal/data/ent/location.go b/backend/internal/data/ent/location.go
index 784b4056..ce52b2bb 100644
--- a/backend/internal/data/ent/location.go
+++ b/backend/internal/data/ent/location.go
@@ -53,12 +53,10 @@ type LocationEdges struct {
// GroupOrErr returns the Group value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e LocationEdges) GroupOrErr() (*Group, error) {
- if e.loadedTypes[0] {
- if e.Group == nil {
- // Edge was loaded but was not found.
- return nil, &NotFoundError{label: group.Label}
- }
+ if e.Group != nil {
return e.Group, nil
+ } else if e.loadedTypes[0] {
+ return nil, &NotFoundError{label: group.Label}
}
return nil, &NotLoadedError{edge: "group"}
}
@@ -66,12 +64,10 @@ func (e LocationEdges) GroupOrErr() (*Group, error) {
// ParentOrErr returns the Parent value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e LocationEdges) ParentOrErr() (*Location, error) {
- if e.loadedTypes[1] {
- if e.Parent == nil {
- // Edge was loaded but was not found.
- return nil, &NotFoundError{label: location.Label}
- }
+ if e.Parent != nil {
return e.Parent, nil
+ } else if e.loadedTypes[1] {
+ return nil, &NotFoundError{label: location.Label}
}
return nil, &NotLoadedError{edge: "parent"}
}
diff --git a/backend/internal/data/ent/location_create.go b/backend/internal/data/ent/location_create.go
index 675de7a1..7a7cdbda 100644
--- a/backend/internal/data/ent/location_create.go
+++ b/backend/internal/data/ent/location_create.go
@@ -215,7 +215,7 @@ func (lc *LocationCreate) check() error {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Location.description": %w`, err)}
}
}
- if _, ok := lc.mutation.GroupID(); !ok {
+ if len(lc.mutation.GroupIDs()) == 0 {
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "Location.group"`)}
}
return nil
diff --git a/backend/internal/data/ent/location_query.go b/backend/internal/data/ent/location_query.go
index 8c7c3e98..42dae357 100644
--- a/backend/internal/data/ent/location_query.go
+++ b/backend/internal/data/ent/location_query.go
@@ -8,6 +8,7 @@ import (
"fmt"
"math"
+ "entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -157,7 +158,7 @@ func (lq *LocationQuery) QueryItems() *ItemQuery {
// First returns the first Location entity from the query.
// Returns a *NotFoundError when no Location was found.
func (lq *LocationQuery) First(ctx context.Context) (*Location, error) {
- nodes, err := lq.Limit(1).All(setContextOp(ctx, lq.ctx, "First"))
+ nodes, err := lq.Limit(1).All(setContextOp(ctx, lq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@@ -180,7 +181,7 @@ func (lq *LocationQuery) FirstX(ctx context.Context) *Location {
// Returns a *NotFoundError when no Location ID was found.
func (lq *LocationQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = lq.Limit(1).IDs(setContextOp(ctx, lq.ctx, "FirstID")); err != nil {
+ if ids, err = lq.Limit(1).IDs(setContextOp(ctx, lq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@@ -203,7 +204,7 @@ func (lq *LocationQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one Location entity is found.
// Returns a *NotFoundError when no Location entities are found.
func (lq *LocationQuery) Only(ctx context.Context) (*Location, error) {
- nodes, err := lq.Limit(2).All(setContextOp(ctx, lq.ctx, "Only"))
+ nodes, err := lq.Limit(2).All(setContextOp(ctx, lq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@@ -231,7 +232,7 @@ func (lq *LocationQuery) OnlyX(ctx context.Context) *Location {
// Returns a *NotFoundError when no entities are found.
func (lq *LocationQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = lq.Limit(2).IDs(setContextOp(ctx, lq.ctx, "OnlyID")); err != nil {
+ if ids, err = lq.Limit(2).IDs(setContextOp(ctx, lq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@@ -256,7 +257,7 @@ func (lq *LocationQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of Locations.
func (lq *LocationQuery) All(ctx context.Context) ([]*Location, error) {
- ctx = setContextOp(ctx, lq.ctx, "All")
+ ctx = setContextOp(ctx, lq.ctx, ent.OpQueryAll)
if err := lq.prepareQuery(ctx); err != nil {
return nil, err
}
@@ -278,7 +279,7 @@ func (lq *LocationQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if lq.ctx.Unique == nil && lq.path != nil {
lq.Unique(true)
}
- ctx = setContextOp(ctx, lq.ctx, "IDs")
+ ctx = setContextOp(ctx, lq.ctx, ent.OpQueryIDs)
if err = lq.Select(location.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@@ -296,7 +297,7 @@ func (lq *LocationQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query.
func (lq *LocationQuery) Count(ctx context.Context) (int, error) {
- ctx = setContextOp(ctx, lq.ctx, "Count")
+ ctx = setContextOp(ctx, lq.ctx, ent.OpQueryCount)
if err := lq.prepareQuery(ctx); err != nil {
return 0, err
}
@@ -314,7 +315,7 @@ func (lq *LocationQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (lq *LocationQuery) Exist(ctx context.Context) (bool, error) {
- ctx = setContextOp(ctx, lq.ctx, "Exist")
+ ctx = setContextOp(ctx, lq.ctx, ent.OpQueryExist)
switch _, err := lq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@@ -761,7 +762,7 @@ func (lgb *LocationGroupBy) Aggregate(fns ...AggregateFunc) *LocationGroupBy {
// Scan applies the selector query and scans the result into the given value.
func (lgb *LocationGroupBy) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, lgb.build.ctx, "GroupBy")
+ ctx = setContextOp(ctx, lgb.build.ctx, ent.OpQueryGroupBy)
if err := lgb.build.prepareQuery(ctx); err != nil {
return err
}
@@ -809,7 +810,7 @@ func (ls *LocationSelect) Aggregate(fns ...AggregateFunc) *LocationSelect {
// Scan applies the selector query and scans the result into the given value.
func (ls *LocationSelect) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, ls.ctx, "Select")
+ ctx = setContextOp(ctx, ls.ctx, ent.OpQuerySelect)
if err := ls.prepareQuery(ctx); err != nil {
return err
}
diff --git a/backend/internal/data/ent/location_update.go b/backend/internal/data/ent/location_update.go
index a937d4ad..f89d50b3 100644
--- a/backend/internal/data/ent/location_update.go
+++ b/backend/internal/data/ent/location_update.go
@@ -238,7 +238,7 @@ func (lu *LocationUpdate) check() error {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Location.description": %w`, err)}
}
}
- if _, ok := lu.mutation.GroupID(); lu.mutation.GroupCleared() && !ok {
+ if lu.mutation.GroupCleared() && len(lu.mutation.GroupIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "Location.group"`)
}
return nil
@@ -656,7 +656,7 @@ func (luo *LocationUpdateOne) check() error {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Location.description": %w`, err)}
}
}
- if _, ok := luo.mutation.GroupID(); luo.mutation.GroupCleared() && !ok {
+ if luo.mutation.GroupCleared() && len(luo.mutation.GroupIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "Location.group"`)
}
return nil
diff --git a/backend/internal/data/ent/maintenanceentry.go b/backend/internal/data/ent/maintenanceentry.go
index 106ec318..c5417d21 100644
--- a/backend/internal/data/ent/maintenanceentry.go
+++ b/backend/internal/data/ent/maintenanceentry.go
@@ -53,12 +53,10 @@ type MaintenanceEntryEdges struct {
// ItemOrErr returns the Item value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e MaintenanceEntryEdges) ItemOrErr() (*Item, error) {
- if e.loadedTypes[0] {
- if e.Item == nil {
- // Edge was loaded but was not found.
- return nil, &NotFoundError{label: item.Label}
- }
+ if e.Item != nil {
return e.Item, nil
+ } else if e.loadedTypes[0] {
+ return nil, &NotFoundError{label: item.Label}
}
return nil, &NotLoadedError{edge: "item"}
}
diff --git a/backend/internal/data/ent/maintenanceentry_create.go b/backend/internal/data/ent/maintenanceentry_create.go
index ceeeb2b3..b8df2734 100644
--- a/backend/internal/data/ent/maintenanceentry_create.go
+++ b/backend/internal/data/ent/maintenanceentry_create.go
@@ -217,7 +217,7 @@ func (mec *MaintenanceEntryCreate) check() error {
if _, ok := mec.mutation.Cost(); !ok {
return &ValidationError{Name: "cost", err: errors.New(`ent: missing required field "MaintenanceEntry.cost"`)}
}
- if _, ok := mec.mutation.ItemID(); !ok {
+ if len(mec.mutation.ItemIDs()) == 0 {
return &ValidationError{Name: "item", err: errors.New(`ent: missing required edge "MaintenanceEntry.item"`)}
}
return nil
diff --git a/backend/internal/data/ent/maintenanceentry_query.go b/backend/internal/data/ent/maintenanceentry_query.go
index 3c68c1ab..1879e6b7 100644
--- a/backend/internal/data/ent/maintenanceentry_query.go
+++ b/backend/internal/data/ent/maintenanceentry_query.go
@@ -7,6 +7,7 @@ import (
"fmt"
"math"
+ "entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -85,7 +86,7 @@ func (meq *MaintenanceEntryQuery) QueryItem() *ItemQuery {
// First returns the first MaintenanceEntry entity from the query.
// Returns a *NotFoundError when no MaintenanceEntry was found.
func (meq *MaintenanceEntryQuery) First(ctx context.Context) (*MaintenanceEntry, error) {
- nodes, err := meq.Limit(1).All(setContextOp(ctx, meq.ctx, "First"))
+ nodes, err := meq.Limit(1).All(setContextOp(ctx, meq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@@ -108,7 +109,7 @@ func (meq *MaintenanceEntryQuery) FirstX(ctx context.Context) *MaintenanceEntry
// Returns a *NotFoundError when no MaintenanceEntry ID was found.
func (meq *MaintenanceEntryQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = meq.Limit(1).IDs(setContextOp(ctx, meq.ctx, "FirstID")); err != nil {
+ if ids, err = meq.Limit(1).IDs(setContextOp(ctx, meq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@@ -131,7 +132,7 @@ func (meq *MaintenanceEntryQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one MaintenanceEntry entity is found.
// Returns a *NotFoundError when no MaintenanceEntry entities are found.
func (meq *MaintenanceEntryQuery) Only(ctx context.Context) (*MaintenanceEntry, error) {
- nodes, err := meq.Limit(2).All(setContextOp(ctx, meq.ctx, "Only"))
+ nodes, err := meq.Limit(2).All(setContextOp(ctx, meq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@@ -159,7 +160,7 @@ func (meq *MaintenanceEntryQuery) OnlyX(ctx context.Context) *MaintenanceEntry {
// Returns a *NotFoundError when no entities are found.
func (meq *MaintenanceEntryQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = meq.Limit(2).IDs(setContextOp(ctx, meq.ctx, "OnlyID")); err != nil {
+ if ids, err = meq.Limit(2).IDs(setContextOp(ctx, meq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@@ -184,7 +185,7 @@ func (meq *MaintenanceEntryQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of MaintenanceEntries.
func (meq *MaintenanceEntryQuery) All(ctx context.Context) ([]*MaintenanceEntry, error) {
- ctx = setContextOp(ctx, meq.ctx, "All")
+ ctx = setContextOp(ctx, meq.ctx, ent.OpQueryAll)
if err := meq.prepareQuery(ctx); err != nil {
return nil, err
}
@@ -206,7 +207,7 @@ func (meq *MaintenanceEntryQuery) IDs(ctx context.Context) (ids []uuid.UUID, err
if meq.ctx.Unique == nil && meq.path != nil {
meq.Unique(true)
}
- ctx = setContextOp(ctx, meq.ctx, "IDs")
+ ctx = setContextOp(ctx, meq.ctx, ent.OpQueryIDs)
if err = meq.Select(maintenanceentry.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@@ -224,7 +225,7 @@ func (meq *MaintenanceEntryQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query.
func (meq *MaintenanceEntryQuery) Count(ctx context.Context) (int, error) {
- ctx = setContextOp(ctx, meq.ctx, "Count")
+ ctx = setContextOp(ctx, meq.ctx, ent.OpQueryCount)
if err := meq.prepareQuery(ctx); err != nil {
return 0, err
}
@@ -242,7 +243,7 @@ func (meq *MaintenanceEntryQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (meq *MaintenanceEntryQuery) Exist(ctx context.Context) (bool, error) {
- ctx = setContextOp(ctx, meq.ctx, "Exist")
+ ctx = setContextOp(ctx, meq.ctx, ent.OpQueryExist)
switch _, err := meq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@@ -529,7 +530,7 @@ func (megb *MaintenanceEntryGroupBy) Aggregate(fns ...AggregateFunc) *Maintenanc
// Scan applies the selector query and scans the result into the given value.
func (megb *MaintenanceEntryGroupBy) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, megb.build.ctx, "GroupBy")
+ ctx = setContextOp(ctx, megb.build.ctx, ent.OpQueryGroupBy)
if err := megb.build.prepareQuery(ctx); err != nil {
return err
}
@@ -577,7 +578,7 @@ func (mes *MaintenanceEntrySelect) Aggregate(fns ...AggregateFunc) *MaintenanceE
// Scan applies the selector query and scans the result into the given value.
func (mes *MaintenanceEntrySelect) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, mes.ctx, "Select")
+ ctx = setContextOp(ctx, mes.ctx, ent.OpQuerySelect)
if err := mes.prepareQuery(ctx); err != nil {
return err
}
diff --git a/backend/internal/data/ent/maintenanceentry_update.go b/backend/internal/data/ent/maintenanceentry_update.go
index 5aeb6e0d..813cd189 100644
--- a/backend/internal/data/ent/maintenanceentry_update.go
+++ b/backend/internal/data/ent/maintenanceentry_update.go
@@ -209,7 +209,7 @@ func (meu *MaintenanceEntryUpdate) check() error {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "MaintenanceEntry.description": %w`, err)}
}
}
- if _, ok := meu.mutation.ItemID(); meu.mutation.ItemCleared() && !ok {
+ if meu.mutation.ItemCleared() && len(meu.mutation.ItemIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.item"`)
}
return nil
@@ -498,7 +498,7 @@ func (meuo *MaintenanceEntryUpdateOne) check() error {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "MaintenanceEntry.description": %w`, err)}
}
}
- if _, ok := meuo.mutation.ItemID(); meuo.mutation.ItemCleared() && !ok {
+ if meuo.mutation.ItemCleared() && len(meuo.mutation.ItemIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.item"`)
}
return nil
diff --git a/backend/internal/data/ent/notifier.go b/backend/internal/data/ent/notifier.go
index 55b062b9..03b4920e 100644
--- a/backend/internal/data/ent/notifier.go
+++ b/backend/internal/data/ent/notifier.go
@@ -54,12 +54,10 @@ type NotifierEdges struct {
// GroupOrErr returns the Group value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e NotifierEdges) GroupOrErr() (*Group, error) {
- if e.loadedTypes[0] {
- if e.Group == nil {
- // Edge was loaded but was not found.
- return nil, &NotFoundError{label: group.Label}
- }
+ if e.Group != nil {
return e.Group, nil
+ } else if e.loadedTypes[0] {
+ return nil, &NotFoundError{label: group.Label}
}
return nil, &NotLoadedError{edge: "group"}
}
@@ -67,12 +65,10 @@ func (e NotifierEdges) GroupOrErr() (*Group, error) {
// UserOrErr returns the User value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e NotifierEdges) UserOrErr() (*User, error) {
- if e.loadedTypes[1] {
- if e.User == nil {
- // Edge was loaded but was not found.
- return nil, &NotFoundError{label: user.Label}
- }
+ if e.User != nil {
return e.User, nil
+ } else if e.loadedTypes[1] {
+ return nil, &NotFoundError{label: user.Label}
}
return nil, &NotLoadedError{edge: "user"}
}
diff --git a/backend/internal/data/ent/notifier_create.go b/backend/internal/data/ent/notifier_create.go
index 20debb82..03e72335 100644
--- a/backend/internal/data/ent/notifier_create.go
+++ b/backend/internal/data/ent/notifier_create.go
@@ -199,10 +199,10 @@ func (nc *NotifierCreate) check() error {
if _, ok := nc.mutation.IsActive(); !ok {
return &ValidationError{Name: "is_active", err: errors.New(`ent: missing required field "Notifier.is_active"`)}
}
- if _, ok := nc.mutation.GroupID(); !ok {
+ if len(nc.mutation.GroupIDs()) == 0 {
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "Notifier.group"`)}
}
- if _, ok := nc.mutation.UserID(); !ok {
+ if len(nc.mutation.UserIDs()) == 0 {
return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "Notifier.user"`)}
}
return nil
diff --git a/backend/internal/data/ent/notifier_query.go b/backend/internal/data/ent/notifier_query.go
index dcde6dc3..232b8113 100644
--- a/backend/internal/data/ent/notifier_query.go
+++ b/backend/internal/data/ent/notifier_query.go
@@ -7,6 +7,7 @@ import (
"fmt"
"math"
+ "entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -109,7 +110,7 @@ func (nq *NotifierQuery) QueryUser() *UserQuery {
// First returns the first Notifier entity from the query.
// Returns a *NotFoundError when no Notifier was found.
func (nq *NotifierQuery) First(ctx context.Context) (*Notifier, error) {
- nodes, err := nq.Limit(1).All(setContextOp(ctx, nq.ctx, "First"))
+ nodes, err := nq.Limit(1).All(setContextOp(ctx, nq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@@ -132,7 +133,7 @@ func (nq *NotifierQuery) FirstX(ctx context.Context) *Notifier {
// Returns a *NotFoundError when no Notifier ID was found.
func (nq *NotifierQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = nq.Limit(1).IDs(setContextOp(ctx, nq.ctx, "FirstID")); err != nil {
+ if ids, err = nq.Limit(1).IDs(setContextOp(ctx, nq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@@ -155,7 +156,7 @@ func (nq *NotifierQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one Notifier entity is found.
// Returns a *NotFoundError when no Notifier entities are found.
func (nq *NotifierQuery) Only(ctx context.Context) (*Notifier, error) {
- nodes, err := nq.Limit(2).All(setContextOp(ctx, nq.ctx, "Only"))
+ nodes, err := nq.Limit(2).All(setContextOp(ctx, nq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@@ -183,7 +184,7 @@ func (nq *NotifierQuery) OnlyX(ctx context.Context) *Notifier {
// Returns a *NotFoundError when no entities are found.
func (nq *NotifierQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = nq.Limit(2).IDs(setContextOp(ctx, nq.ctx, "OnlyID")); err != nil {
+ if ids, err = nq.Limit(2).IDs(setContextOp(ctx, nq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@@ -208,7 +209,7 @@ func (nq *NotifierQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of Notifiers.
func (nq *NotifierQuery) All(ctx context.Context) ([]*Notifier, error) {
- ctx = setContextOp(ctx, nq.ctx, "All")
+ ctx = setContextOp(ctx, nq.ctx, ent.OpQueryAll)
if err := nq.prepareQuery(ctx); err != nil {
return nil, err
}
@@ -230,7 +231,7 @@ func (nq *NotifierQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if nq.ctx.Unique == nil && nq.path != nil {
nq.Unique(true)
}
- ctx = setContextOp(ctx, nq.ctx, "IDs")
+ ctx = setContextOp(ctx, nq.ctx, ent.OpQueryIDs)
if err = nq.Select(notifier.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@@ -248,7 +249,7 @@ func (nq *NotifierQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query.
func (nq *NotifierQuery) Count(ctx context.Context) (int, error) {
- ctx = setContextOp(ctx, nq.ctx, "Count")
+ ctx = setContextOp(ctx, nq.ctx, ent.OpQueryCount)
if err := nq.prepareQuery(ctx); err != nil {
return 0, err
}
@@ -266,7 +267,7 @@ func (nq *NotifierQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (nq *NotifierQuery) Exist(ctx context.Context) (bool, error) {
- ctx = setContextOp(ctx, nq.ctx, "Exist")
+ ctx = setContextOp(ctx, nq.ctx, ent.OpQueryExist)
switch _, err := nq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@@ -604,7 +605,7 @@ func (ngb *NotifierGroupBy) Aggregate(fns ...AggregateFunc) *NotifierGroupBy {
// Scan applies the selector query and scans the result into the given value.
func (ngb *NotifierGroupBy) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, ngb.build.ctx, "GroupBy")
+ ctx = setContextOp(ctx, ngb.build.ctx, ent.OpQueryGroupBy)
if err := ngb.build.prepareQuery(ctx); err != nil {
return err
}
@@ -652,7 +653,7 @@ func (ns *NotifierSelect) Aggregate(fns ...AggregateFunc) *NotifierSelect {
// Scan applies the selector query and scans the result into the given value.
func (ns *NotifierSelect) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, ns.ctx, "Select")
+ ctx = setContextOp(ctx, ns.ctx, ent.OpQuerySelect)
if err := ns.prepareQuery(ctx); err != nil {
return err
}
diff --git a/backend/internal/data/ent/notifier_update.go b/backend/internal/data/ent/notifier_update.go
index 92b87be1..683c413c 100644
--- a/backend/internal/data/ent/notifier_update.go
+++ b/backend/internal/data/ent/notifier_update.go
@@ -182,10 +182,10 @@ func (nu *NotifierUpdate) check() error {
return &ValidationError{Name: "url", err: fmt.Errorf(`ent: validator failed for field "Notifier.url": %w`, err)}
}
}
- if _, ok := nu.mutation.GroupID(); nu.mutation.GroupCleared() && !ok {
+ if nu.mutation.GroupCleared() && len(nu.mutation.GroupIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "Notifier.group"`)
}
- if _, ok := nu.mutation.UserID(); nu.mutation.UserCleared() && !ok {
+ if nu.mutation.UserCleared() && len(nu.mutation.UserIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "Notifier.user"`)
}
return nil
@@ -457,10 +457,10 @@ func (nuo *NotifierUpdateOne) check() error {
return &ValidationError{Name: "url", err: fmt.Errorf(`ent: validator failed for field "Notifier.url": %w`, err)}
}
}
- if _, ok := nuo.mutation.GroupID(); nuo.mutation.GroupCleared() && !ok {
+ if nuo.mutation.GroupCleared() && len(nuo.mutation.GroupIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "Notifier.group"`)
}
- if _, ok := nuo.mutation.UserID(); nuo.mutation.UserCleared() && !ok {
+ if nuo.mutation.UserCleared() && len(nuo.mutation.UserIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "Notifier.user"`)
}
return nil
diff --git a/backend/internal/data/ent/runtime/runtime.go b/backend/internal/data/ent/runtime/runtime.go
index dcbee86e..bb04574c 100644
--- a/backend/internal/data/ent/runtime/runtime.go
+++ b/backend/internal/data/ent/runtime/runtime.go
@@ -5,6 +5,6 @@ package runtime
// The schema-stitching logic is generated in github.com/sysadminsmedia/homebox/backend/internal/data/ent/runtime.go
const (
- Version = "v0.12.5" // Version of ent codegen.
- Sum = "h1:KREM5E4CSoej4zeGa88Ou/gfturAnpUv0mzAjch1sj4=" // Sum of ent codegen.
+ Version = "v0.14.1" // Version of ent codegen.
+ Sum = "h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s=" // Sum of ent codegen.
)
diff --git a/backend/internal/data/ent/user.go b/backend/internal/data/ent/user.go
index b00f838b..c8d9b99b 100644
--- a/backend/internal/data/ent/user.go
+++ b/backend/internal/data/ent/user.go
@@ -60,12 +60,10 @@ type UserEdges struct {
// GroupOrErr returns the Group value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e UserEdges) GroupOrErr() (*Group, error) {
- if e.loadedTypes[0] {
- if e.Group == nil {
- // Edge was loaded but was not found.
- return nil, &NotFoundError{label: group.Label}
- }
+ if e.Group != nil {
return e.Group, nil
+ } else if e.loadedTypes[0] {
+ return nil, &NotFoundError{label: group.Label}
}
return nil, &NotLoadedError{edge: "group"}
}
diff --git a/backend/internal/data/ent/user_create.go b/backend/internal/data/ent/user_create.go
index 7367ddb7..529ce637 100644
--- a/backend/internal/data/ent/user_create.go
+++ b/backend/internal/data/ent/user_create.go
@@ -288,7 +288,7 @@ func (uc *UserCreate) check() error {
return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "User.role": %w`, err)}
}
}
- if _, ok := uc.mutation.GroupID(); !ok {
+ if len(uc.mutation.GroupIDs()) == 0 {
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "User.group"`)}
}
return nil
diff --git a/backend/internal/data/ent/user_query.go b/backend/internal/data/ent/user_query.go
index dce4037d..bd75ecd8 100644
--- a/backend/internal/data/ent/user_query.go
+++ b/backend/internal/data/ent/user_query.go
@@ -8,6 +8,7 @@ import (
"fmt"
"math"
+ "entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -135,7 +136,7 @@ func (uq *UserQuery) QueryNotifiers() *NotifierQuery {
// First returns the first User entity from the query.
// Returns a *NotFoundError when no User was found.
func (uq *UserQuery) First(ctx context.Context) (*User, error) {
- nodes, err := uq.Limit(1).All(setContextOp(ctx, uq.ctx, "First"))
+ nodes, err := uq.Limit(1).All(setContextOp(ctx, uq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
@@ -158,7 +159,7 @@ func (uq *UserQuery) FirstX(ctx context.Context) *User {
// Returns a *NotFoundError when no User ID was found.
func (uq *UserQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = uq.Limit(1).IDs(setContextOp(ctx, uq.ctx, "FirstID")); err != nil {
+ if ids, err = uq.Limit(1).IDs(setContextOp(ctx, uq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
@@ -181,7 +182,7 @@ func (uq *UserQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one User entity is found.
// Returns a *NotFoundError when no User entities are found.
func (uq *UserQuery) Only(ctx context.Context) (*User, error) {
- nodes, err := uq.Limit(2).All(setContextOp(ctx, uq.ctx, "Only"))
+ nodes, err := uq.Limit(2).All(setContextOp(ctx, uq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
@@ -209,7 +210,7 @@ func (uq *UserQuery) OnlyX(ctx context.Context) *User {
// Returns a *NotFoundError when no entities are found.
func (uq *UserQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
- if ids, err = uq.Limit(2).IDs(setContextOp(ctx, uq.ctx, "OnlyID")); err != nil {
+ if ids, err = uq.Limit(2).IDs(setContextOp(ctx, uq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
@@ -234,7 +235,7 @@ func (uq *UserQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of Users.
func (uq *UserQuery) All(ctx context.Context) ([]*User, error) {
- ctx = setContextOp(ctx, uq.ctx, "All")
+ ctx = setContextOp(ctx, uq.ctx, ent.OpQueryAll)
if err := uq.prepareQuery(ctx); err != nil {
return nil, err
}
@@ -256,7 +257,7 @@ func (uq *UserQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if uq.ctx.Unique == nil && uq.path != nil {
uq.Unique(true)
}
- ctx = setContextOp(ctx, uq.ctx, "IDs")
+ ctx = setContextOp(ctx, uq.ctx, ent.OpQueryIDs)
if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
@@ -274,7 +275,7 @@ func (uq *UserQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query.
func (uq *UserQuery) Count(ctx context.Context) (int, error) {
- ctx = setContextOp(ctx, uq.ctx, "Count")
+ ctx = setContextOp(ctx, uq.ctx, ent.OpQueryCount)
if err := uq.prepareQuery(ctx); err != nil {
return 0, err
}
@@ -292,7 +293,7 @@ func (uq *UserQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph.
func (uq *UserQuery) Exist(ctx context.Context) (bool, error) {
- ctx = setContextOp(ctx, uq.ctx, "Exist")
+ ctx = setContextOp(ctx, uq.ctx, ent.OpQueryExist)
switch _, err := uq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
@@ -687,7 +688,7 @@ func (ugb *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy {
// Scan applies the selector query and scans the result into the given value.
func (ugb *UserGroupBy) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, ugb.build.ctx, "GroupBy")
+ ctx = setContextOp(ctx, ugb.build.ctx, ent.OpQueryGroupBy)
if err := ugb.build.prepareQuery(ctx); err != nil {
return err
}
@@ -735,7 +736,7 @@ func (us *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect {
// Scan applies the selector query and scans the result into the given value.
func (us *UserSelect) Scan(ctx context.Context, v any) error {
- ctx = setContextOp(ctx, us.ctx, "Select")
+ ctx = setContextOp(ctx, us.ctx, ent.OpQuerySelect)
if err := us.prepareQuery(ctx); err != nil {
return err
}
diff --git a/backend/internal/data/ent/user_update.go b/backend/internal/data/ent/user_update.go
index 3277713d..8697a637 100644
--- a/backend/internal/data/ent/user_update.go
+++ b/backend/internal/data/ent/user_update.go
@@ -294,7 +294,7 @@ func (uu *UserUpdate) check() error {
return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "User.role": %w`, err)}
}
}
- if _, ok := uu.mutation.GroupID(); uu.mutation.GroupCleared() && !ok {
+ if uu.mutation.GroupCleared() && len(uu.mutation.GroupIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "User.group"`)
}
return nil
@@ -753,7 +753,7 @@ func (uuo *UserUpdateOne) check() error {
return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "User.role": %w`, err)}
}
}
- if _, ok := uuo.mutation.GroupID(); uuo.mutation.GroupCleared() && !ok {
+ if uuo.mutation.GroupCleared() && len(uuo.mutation.GroupIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "User.group"`)
}
return nil