code gen updates

This commit is contained in:
Hayden 2023-01-18 15:17:50 -09:00
parent f532b39c46
commit 552370e0da
No known key found for this signature in database
GPG key ID: 17CF79474E257545
66 changed files with 2806 additions and 6328 deletions

View file

@ -13,251 +13,157 @@ import (
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.
func ID(id uuid.UUID) predicate.Attachment { func ID(id uuid.UUID) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDEQ applies the EQ predicate on the ID field. // IDEQ applies the EQ predicate on the ID field.
func IDEQ(id uuid.UUID) predicate.Attachment { func IDEQ(id uuid.UUID) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDNEQ applies the NEQ predicate on the ID field. // IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id uuid.UUID) predicate.Attachment { func IDNEQ(id uuid.UUID) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldNEQ(FieldID, id))
s.Where(sql.NEQ(s.C(FieldID), id))
})
} }
// IDIn applies the In predicate on the ID field. // IDIn applies the In predicate on the ID field.
func IDIn(ids ...uuid.UUID) predicate.Attachment { func IDIn(ids ...uuid.UUID) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.In(s.C(FieldID), v...))
})
} }
// IDNotIn applies the NotIn predicate on the ID field. // IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...uuid.UUID) predicate.Attachment { func IDNotIn(ids ...uuid.UUID) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldNotIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.NotIn(s.C(FieldID), v...))
})
} }
// IDGT applies the GT predicate on the ID field. // IDGT applies the GT predicate on the ID field.
func IDGT(id uuid.UUID) predicate.Attachment { func IDGT(id uuid.UUID) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldGT(FieldID, id))
s.Where(sql.GT(s.C(FieldID), id))
})
} }
// IDGTE applies the GTE predicate on the ID field. // IDGTE applies the GTE predicate on the ID field.
func IDGTE(id uuid.UUID) predicate.Attachment { func IDGTE(id uuid.UUID) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldGTE(FieldID, id))
s.Where(sql.GTE(s.C(FieldID), id))
})
} }
// IDLT applies the LT predicate on the ID field. // IDLT applies the LT predicate on the ID field.
func IDLT(id uuid.UUID) predicate.Attachment { func IDLT(id uuid.UUID) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldLT(FieldID, id))
s.Where(sql.LT(s.C(FieldID), id))
})
} }
// IDLTE applies the LTE predicate on the ID field. // IDLTE applies the LTE predicate on the ID field.
func IDLTE(id uuid.UUID) predicate.Attachment { func IDLTE(id uuid.UUID) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldLTE(FieldID, id))
s.Where(sql.LTE(s.C(FieldID), id))
})
} }
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. // CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.Attachment { func CreatedAt(v time.Time) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. // UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.Attachment { func UpdatedAt(v time.Time) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// CreatedAtEQ applies the EQ predicate on the "created_at" field. // CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.Attachment { func CreatedAtEQ(v time.Time) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. // CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.Attachment { func CreatedAtNEQ(v time.Time) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldNEQ(FieldCreatedAt, v))
s.Where(sql.NEQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtIn applies the In predicate on the "created_at" field. // CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.Attachment { func CreatedAtIn(vs ...time.Time) predicate.Attachment {
v := make([]any, len(vs)) return predicate.Attachment(sql.FieldIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Attachment(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. // CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.Attachment { func CreatedAtNotIn(vs ...time.Time) predicate.Attachment {
v := make([]any, len(vs)) return predicate.Attachment(sql.FieldNotIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Attachment(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtGT applies the GT predicate on the "created_at" field. // CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.Attachment { func CreatedAtGT(v time.Time) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldGT(FieldCreatedAt, v))
s.Where(sql.GT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtGTE applies the GTE predicate on the "created_at" field. // CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.Attachment { func CreatedAtGTE(v time.Time) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldGTE(FieldCreatedAt, v))
s.Where(sql.GTE(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLT applies the LT predicate on the "created_at" field. // CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.Attachment { func CreatedAtLT(v time.Time) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldLT(FieldCreatedAt, v))
s.Where(sql.LT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLTE applies the LTE predicate on the "created_at" field. // CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.Attachment { func CreatedAtLTE(v time.Time) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldLTE(FieldCreatedAt, v))
s.Where(sql.LTE(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. // UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.Attachment { func UpdatedAtEQ(v time.Time) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. // UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.Attachment { func UpdatedAtNEQ(v time.Time) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldNEQ(FieldUpdatedAt, v))
s.Where(sql.NEQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtIn applies the In predicate on the "updated_at" field. // UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.Attachment { func UpdatedAtIn(vs ...time.Time) predicate.Attachment {
v := make([]any, len(vs)) return predicate.Attachment(sql.FieldIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Attachment(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. // UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.Attachment { func UpdatedAtNotIn(vs ...time.Time) predicate.Attachment {
v := make([]any, len(vs)) return predicate.Attachment(sql.FieldNotIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Attachment(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtGT applies the GT predicate on the "updated_at" field. // UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.Attachment { func UpdatedAtGT(v time.Time) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldGT(FieldUpdatedAt, v))
s.Where(sql.GT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. // UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.Attachment { func UpdatedAtGTE(v time.Time) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldGTE(FieldUpdatedAt, v))
s.Where(sql.GTE(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLT applies the LT predicate on the "updated_at" field. // UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.Attachment { func UpdatedAtLT(v time.Time) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldLT(FieldUpdatedAt, v))
s.Where(sql.LT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. // UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.Attachment { func UpdatedAtLTE(v time.Time) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldLTE(FieldUpdatedAt, v))
s.Where(sql.LTE(s.C(FieldUpdatedAt), v))
})
} }
// TypeEQ applies the EQ predicate on the "type" field. // TypeEQ applies the EQ predicate on the "type" field.
func TypeEQ(v Type) predicate.Attachment { func TypeEQ(v Type) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldEQ(FieldType, v))
s.Where(sql.EQ(s.C(FieldType), v))
})
} }
// TypeNEQ applies the NEQ predicate on the "type" field. // TypeNEQ applies the NEQ predicate on the "type" field.
func TypeNEQ(v Type) predicate.Attachment { func TypeNEQ(v Type) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(sql.FieldNEQ(FieldType, v))
s.Where(sql.NEQ(s.C(FieldType), v))
})
} }
// TypeIn applies the In predicate on the "type" field. // TypeIn applies the In predicate on the "type" field.
func TypeIn(vs ...Type) predicate.Attachment { func TypeIn(vs ...Type) predicate.Attachment {
v := make([]any, len(vs)) return predicate.Attachment(sql.FieldIn(FieldType, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Attachment(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldType), v...))
})
} }
// TypeNotIn applies the NotIn predicate on the "type" field. // TypeNotIn applies the NotIn predicate on the "type" field.
func TypeNotIn(vs ...Type) predicate.Attachment { func TypeNotIn(vs ...Type) predicate.Attachment {
v := make([]any, len(vs)) return predicate.Attachment(sql.FieldNotIn(FieldType, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Attachment(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldType), v...))
})
} }
// HasItem applies the HasEdge predicate on the "item" edge. // HasItem applies the HasEdge predicate on the "item" edge.
@ -265,7 +171,6 @@ func HasItem() predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(ItemTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ItemTable, ItemColumn), sqlgraph.Edge(sqlgraph.M2O, true, ItemTable, ItemColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)
@ -293,7 +198,6 @@ func HasDocument() predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) { return predicate.Attachment(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(DocumentTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, DocumentTable, DocumentColumn), sqlgraph.Edge(sqlgraph.M2O, true, DocumentTable, DocumentColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)

View file

@ -108,50 +108,8 @@ func (ac *AttachmentCreate) Mutation() *AttachmentMutation {
// Save creates the Attachment in the database. // Save creates the Attachment in the database.
func (ac *AttachmentCreate) Save(ctx context.Context) (*Attachment, error) { func (ac *AttachmentCreate) Save(ctx context.Context) (*Attachment, error) {
var (
err error
node *Attachment
)
ac.defaults() ac.defaults()
if len(ac.hooks) == 0 { return withHooks[*Attachment, AttachmentMutation](ctx, ac.sqlSave, ac.mutation, ac.hooks)
if err = ac.check(); err != nil {
return nil, err
}
node, err = ac.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AttachmentMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = ac.check(); err != nil {
return nil, err
}
ac.mutation = mutation
if node, err = ac.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(ac.hooks) - 1; i >= 0; i-- {
if ac.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = ac.hooks[i](mut)
}
v, err := mut.Mutate(ctx, ac.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Attachment)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from AttachmentMutation", v)
}
node = nv
}
return node, err
} }
// SaveX calls Save and panics if Save returns an error. // SaveX calls Save and panics if Save returns an error.
@ -222,6 +180,9 @@ func (ac *AttachmentCreate) check() error {
} }
func (ac *AttachmentCreate) sqlSave(ctx context.Context) (*Attachment, error) { func (ac *AttachmentCreate) sqlSave(ctx context.Context) (*Attachment, error) {
if err := ac.check(); err != nil {
return nil, err
}
_node, _spec := ac.createSpec() _node, _spec := ac.createSpec()
if err := sqlgraph.CreateNode(ctx, ac.driver, _spec); err != nil { if err := sqlgraph.CreateNode(ctx, ac.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) { if sqlgraph.IsConstraintError(err) {
@ -236,6 +197,8 @@ func (ac *AttachmentCreate) sqlSave(ctx context.Context) (*Attachment, error) {
return nil, err return nil, err
} }
} }
ac.mutation.id = &_node.ID
ac.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -4,7 +4,6 @@ package ent
import ( import (
"context" "context"
"fmt"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
@ -28,34 +27,7 @@ func (ad *AttachmentDelete) Where(ps ...predicate.Attachment) *AttachmentDelete
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (ad *AttachmentDelete) Exec(ctx context.Context) (int, error) { func (ad *AttachmentDelete) Exec(ctx context.Context) (int, error) {
var ( return withHooks[int, AttachmentMutation](ctx, ad.sqlExec, ad.mutation, ad.hooks)
err error
affected int
)
if len(ad.hooks) == 0 {
affected, err = ad.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AttachmentMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
ad.mutation = mutation
affected, err = ad.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(ad.hooks) - 1; i >= 0; i-- {
if ad.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = ad.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, ad.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
@ -88,6 +60,7 @@ func (ad *AttachmentDelete) sqlExec(ctx context.Context) (int, error) {
if err != nil && sqlgraph.IsConstraintError(err) { if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
ad.mutation.done = true
return affected, err return affected, err
} }

View file

@ -25,6 +25,7 @@ type AttachmentQuery struct {
unique *bool unique *bool
order []OrderFunc order []OrderFunc
fields []string fields []string
inters []Interceptor
predicates []predicate.Attachment predicates []predicate.Attachment
withItem *ItemQuery withItem *ItemQuery
withDocument *DocumentQuery withDocument *DocumentQuery
@ -40,13 +41,13 @@ func (aq *AttachmentQuery) Where(ps ...predicate.Attachment) *AttachmentQuery {
return aq return aq
} }
// Limit adds a limit step to the query. // Limit the number of records to be returned by this query.
func (aq *AttachmentQuery) Limit(limit int) *AttachmentQuery { func (aq *AttachmentQuery) Limit(limit int) *AttachmentQuery {
aq.limit = &limit aq.limit = &limit
return aq return aq
} }
// Offset adds an offset step to the query. // Offset to start from.
func (aq *AttachmentQuery) Offset(offset int) *AttachmentQuery { func (aq *AttachmentQuery) Offset(offset int) *AttachmentQuery {
aq.offset = &offset aq.offset = &offset
return aq return aq
@ -59,7 +60,7 @@ func (aq *AttachmentQuery) Unique(unique bool) *AttachmentQuery {
return aq return aq
} }
// Order adds an order step to the query. // Order specifies how the records should be ordered.
func (aq *AttachmentQuery) Order(o ...OrderFunc) *AttachmentQuery { func (aq *AttachmentQuery) Order(o ...OrderFunc) *AttachmentQuery {
aq.order = append(aq.order, o...) aq.order = append(aq.order, o...)
return aq return aq
@ -67,7 +68,7 @@ func (aq *AttachmentQuery) Order(o ...OrderFunc) *AttachmentQuery {
// QueryItem chains the current query on the "item" edge. // QueryItem chains the current query on the "item" edge.
func (aq *AttachmentQuery) QueryItem() *ItemQuery { func (aq *AttachmentQuery) QueryItem() *ItemQuery {
query := &ItemQuery{config: aq.config} query := (&ItemClient{config: aq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := aq.prepareQuery(ctx); err != nil { if err := aq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -89,7 +90,7 @@ func (aq *AttachmentQuery) QueryItem() *ItemQuery {
// QueryDocument chains the current query on the "document" edge. // QueryDocument chains the current query on the "document" edge.
func (aq *AttachmentQuery) QueryDocument() *DocumentQuery { func (aq *AttachmentQuery) QueryDocument() *DocumentQuery {
query := &DocumentQuery{config: aq.config} query := (&DocumentClient{config: aq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := aq.prepareQuery(ctx); err != nil { if err := aq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -112,7 +113,7 @@ func (aq *AttachmentQuery) QueryDocument() *DocumentQuery {
// First returns the first Attachment entity from the query. // First returns the first Attachment entity from the query.
// Returns a *NotFoundError when no Attachment was found. // Returns a *NotFoundError when no Attachment was found.
func (aq *AttachmentQuery) First(ctx context.Context) (*Attachment, error) { func (aq *AttachmentQuery) First(ctx context.Context) (*Attachment, error) {
nodes, err := aq.Limit(1).All(ctx) nodes, err := aq.Limit(1).All(newQueryContext(ctx, TypeAttachment, "First"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -135,7 +136,7 @@ func (aq *AttachmentQuery) FirstX(ctx context.Context) *Attachment {
// Returns a *NotFoundError when no Attachment ID was found. // Returns a *NotFoundError when no Attachment ID was found.
func (aq *AttachmentQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { func (aq *AttachmentQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = aq.Limit(1).IDs(ctx); err != nil { if ids, err = aq.Limit(1).IDs(newQueryContext(ctx, TypeAttachment, "FirstID")); err != nil {
return return
} }
if len(ids) == 0 { if len(ids) == 0 {
@ -158,7 +159,7 @@ func (aq *AttachmentQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one Attachment entity is found. // Returns a *NotSingularError when more than one Attachment entity is found.
// Returns a *NotFoundError when no Attachment entities are found. // Returns a *NotFoundError when no Attachment entities are found.
func (aq *AttachmentQuery) Only(ctx context.Context) (*Attachment, error) { func (aq *AttachmentQuery) Only(ctx context.Context) (*Attachment, error) {
nodes, err := aq.Limit(2).All(ctx) nodes, err := aq.Limit(2).All(newQueryContext(ctx, TypeAttachment, "Only"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -186,7 +187,7 @@ func (aq *AttachmentQuery) OnlyX(ctx context.Context) *Attachment {
// Returns a *NotFoundError when no entities are found. // Returns a *NotFoundError when no entities are found.
func (aq *AttachmentQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { func (aq *AttachmentQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = aq.Limit(2).IDs(ctx); err != nil { if ids, err = aq.Limit(2).IDs(newQueryContext(ctx, TypeAttachment, "OnlyID")); err != nil {
return return
} }
switch len(ids) { switch len(ids) {
@ -211,10 +212,12 @@ func (aq *AttachmentQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of Attachments. // All executes the query and returns a list of Attachments.
func (aq *AttachmentQuery) All(ctx context.Context) ([]*Attachment, error) { func (aq *AttachmentQuery) All(ctx context.Context) ([]*Attachment, error) {
ctx = newQueryContext(ctx, TypeAttachment, "All")
if err := aq.prepareQuery(ctx); err != nil { if err := aq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return aq.sqlAll(ctx) qr := querierAll[[]*Attachment, *AttachmentQuery]()
return withInterceptors[[]*Attachment](ctx, aq, qr, aq.inters)
} }
// AllX is like All, but panics if an error occurs. // AllX is like All, but panics if an error occurs.
@ -229,6 +232,7 @@ func (aq *AttachmentQuery) AllX(ctx context.Context) []*Attachment {
// IDs executes the query and returns a list of Attachment IDs. // IDs executes the query and returns a list of Attachment IDs.
func (aq *AttachmentQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (aq *AttachmentQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID var ids []uuid.UUID
ctx = newQueryContext(ctx, TypeAttachment, "IDs")
if err := aq.Select(attachment.FieldID).Scan(ctx, &ids); err != nil { if err := aq.Select(attachment.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
@ -246,10 +250,11 @@ func (aq *AttachmentQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query. // Count returns the count of the given query.
func (aq *AttachmentQuery) Count(ctx context.Context) (int, error) { func (aq *AttachmentQuery) Count(ctx context.Context) (int, error) {
ctx = newQueryContext(ctx, TypeAttachment, "Count")
if err := aq.prepareQuery(ctx); err != nil { if err := aq.prepareQuery(ctx); err != nil {
return 0, err return 0, err
} }
return aq.sqlCount(ctx) return withInterceptors[int](ctx, aq, querierCount[*AttachmentQuery](), aq.inters)
} }
// CountX is like Count, but panics if an error occurs. // CountX is like Count, but panics if an error occurs.
@ -263,10 +268,15 @@ func (aq *AttachmentQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph. // Exist returns true if the query has elements in the graph.
func (aq *AttachmentQuery) Exist(ctx context.Context) (bool, error) { func (aq *AttachmentQuery) Exist(ctx context.Context) (bool, error) {
if err := aq.prepareQuery(ctx); err != nil { ctx = newQueryContext(ctx, TypeAttachment, "Exist")
return false, err switch _, err := aq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
} }
return aq.sqlExist(ctx)
} }
// ExistX is like Exist, but panics if an error occurs. // ExistX is like Exist, but panics if an error occurs.
@ -289,6 +299,7 @@ func (aq *AttachmentQuery) Clone() *AttachmentQuery {
limit: aq.limit, limit: aq.limit,
offset: aq.offset, offset: aq.offset,
order: append([]OrderFunc{}, aq.order...), order: append([]OrderFunc{}, aq.order...),
inters: append([]Interceptor{}, aq.inters...),
predicates: append([]predicate.Attachment{}, aq.predicates...), predicates: append([]predicate.Attachment{}, aq.predicates...),
withItem: aq.withItem.Clone(), withItem: aq.withItem.Clone(),
withDocument: aq.withDocument.Clone(), withDocument: aq.withDocument.Clone(),
@ -302,7 +313,7 @@ func (aq *AttachmentQuery) Clone() *AttachmentQuery {
// WithItem tells the query-builder to eager-load the nodes that are connected to // WithItem tells the query-builder to eager-load the nodes that are connected to
// the "item" edge. The optional arguments are used to configure the query builder of the edge. // the "item" edge. The optional arguments are used to configure the query builder of the edge.
func (aq *AttachmentQuery) WithItem(opts ...func(*ItemQuery)) *AttachmentQuery { func (aq *AttachmentQuery) WithItem(opts ...func(*ItemQuery)) *AttachmentQuery {
query := &ItemQuery{config: aq.config} query := (&ItemClient{config: aq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -313,7 +324,7 @@ func (aq *AttachmentQuery) WithItem(opts ...func(*ItemQuery)) *AttachmentQuery {
// WithDocument tells the query-builder to eager-load the nodes that are connected to // WithDocument tells the query-builder to eager-load the nodes that are connected to
// the "document" edge. The optional arguments are used to configure the query builder of the edge. // the "document" edge. The optional arguments are used to configure the query builder of the edge.
func (aq *AttachmentQuery) WithDocument(opts ...func(*DocumentQuery)) *AttachmentQuery { func (aq *AttachmentQuery) WithDocument(opts ...func(*DocumentQuery)) *AttachmentQuery {
query := &DocumentQuery{config: aq.config} query := (&DocumentClient{config: aq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -336,16 +347,11 @@ func (aq *AttachmentQuery) WithDocument(opts ...func(*DocumentQuery)) *Attachmen
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (aq *AttachmentQuery) GroupBy(field string, fields ...string) *AttachmentGroupBy { func (aq *AttachmentQuery) GroupBy(field string, fields ...string) *AttachmentGroupBy {
grbuild := &AttachmentGroupBy{config: aq.config} aq.fields = append([]string{field}, fields...)
grbuild.fields = append([]string{field}, fields...) grbuild := &AttachmentGroupBy{build: aq}
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { grbuild.flds = &aq.fields
if err := aq.prepareQuery(ctx); err != nil {
return nil, err
}
return aq.sqlQuery(ctx), nil
}
grbuild.label = attachment.Label grbuild.label = attachment.Label
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan grbuild.scan = grbuild.Scan
return grbuild return grbuild
} }
@ -363,10 +369,10 @@ func (aq *AttachmentQuery) GroupBy(field string, fields ...string) *AttachmentGr
// Scan(ctx, &v) // Scan(ctx, &v)
func (aq *AttachmentQuery) Select(fields ...string) *AttachmentSelect { func (aq *AttachmentQuery) Select(fields ...string) *AttachmentSelect {
aq.fields = append(aq.fields, fields...) aq.fields = append(aq.fields, fields...)
selbuild := &AttachmentSelect{AttachmentQuery: aq} sbuild := &AttachmentSelect{AttachmentQuery: aq}
selbuild.label = attachment.Label sbuild.label = attachment.Label
selbuild.flds, selbuild.scan = &aq.fields, selbuild.Scan sbuild.flds, sbuild.scan = &aq.fields, sbuild.Scan
return selbuild return sbuild
} }
// Aggregate returns a AttachmentSelect configured with the given aggregations. // Aggregate returns a AttachmentSelect configured with the given aggregations.
@ -375,6 +381,16 @@ func (aq *AttachmentQuery) Aggregate(fns ...AggregateFunc) *AttachmentSelect {
} }
func (aq *AttachmentQuery) prepareQuery(ctx context.Context) error { func (aq *AttachmentQuery) prepareQuery(ctx context.Context) error {
for _, inter := range aq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, aq); err != nil {
return err
}
}
}
for _, f := range aq.fields { for _, f := range aq.fields {
if !attachment.ValidColumn(f) { if !attachment.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
@ -507,17 +523,6 @@ func (aq *AttachmentQuery) sqlCount(ctx context.Context) (int, error) {
return sqlgraph.CountNodes(ctx, aq.driver, _spec) return sqlgraph.CountNodes(ctx, aq.driver, _spec)
} }
func (aq *AttachmentQuery) sqlExist(ctx context.Context) (bool, error) {
switch _, err := aq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
func (aq *AttachmentQuery) querySpec() *sqlgraph.QuerySpec { func (aq *AttachmentQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
@ -600,13 +605,8 @@ func (aq *AttachmentQuery) sqlQuery(ctx context.Context) *sql.Selector {
// AttachmentGroupBy is the group-by builder for Attachment entities. // AttachmentGroupBy is the group-by builder for Attachment entities.
type AttachmentGroupBy struct { type AttachmentGroupBy struct {
config
selector selector
fields []string build *AttachmentQuery
fns []AggregateFunc
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
} }
// Aggregate adds the given aggregation functions to the group-by query. // Aggregate adds the given aggregation functions to the group-by query.
@ -615,58 +615,46 @@ func (agb *AttachmentGroupBy) Aggregate(fns ...AggregateFunc) *AttachmentGroupBy
return agb return agb
} }
// Scan applies the group-by query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (agb *AttachmentGroupBy) Scan(ctx context.Context, v any) error { func (agb *AttachmentGroupBy) Scan(ctx context.Context, v any) error {
query, err := agb.path(ctx) ctx = newQueryContext(ctx, TypeAttachment, "GroupBy")
if err != nil { if err := agb.build.prepareQuery(ctx); err != nil {
return err return err
} }
agb.sql = query return scanWithInterceptors[*AttachmentQuery, *AttachmentGroupBy](ctx, agb.build, agb, agb.build.inters, v)
return agb.sqlScan(ctx, v)
} }
func (agb *AttachmentGroupBy) sqlScan(ctx context.Context, v any) error { func (agb *AttachmentGroupBy) sqlScan(ctx context.Context, root *AttachmentQuery, v any) error {
for _, f := range agb.fields { selector := root.sqlQuery(ctx).Select()
if !attachment.ValidColumn(f) { aggregation := make([]string, 0, len(agb.fns))
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} for _, fn := range agb.fns {
} aggregation = append(aggregation, fn(selector))
} }
selector := agb.sqlQuery() if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*agb.flds)+len(agb.fns))
for _, f := range *agb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*agb.flds...)...)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return err return err
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() query, args := selector.Query()
if err := agb.driver.Query(ctx, query, args, rows); err != nil { if err := agb.build.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }
defer rows.Close() defer rows.Close()
return sql.ScanSlice(rows, v) return sql.ScanSlice(rows, v)
} }
func (agb *AttachmentGroupBy) sqlQuery() *sql.Selector {
selector := agb.sql.Select()
aggregation := make([]string, 0, len(agb.fns))
for _, fn := range agb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(agb.fields)+len(agb.fns))
for _, f := range agb.fields {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
return selector.GroupBy(selector.Columns(agb.fields...)...)
}
// AttachmentSelect is the builder for selecting fields of Attachment entities. // AttachmentSelect is the builder for selecting fields of Attachment entities.
type AttachmentSelect struct { type AttachmentSelect struct {
*AttachmentQuery *AttachmentQuery
selector selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
@ -677,26 +665,27 @@ func (as *AttachmentSelect) Aggregate(fns ...AggregateFunc) *AttachmentSelect {
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (as *AttachmentSelect) Scan(ctx context.Context, v any) error { func (as *AttachmentSelect) Scan(ctx context.Context, v any) error {
ctx = newQueryContext(ctx, TypeAttachment, "Select")
if err := as.prepareQuery(ctx); err != nil { if err := as.prepareQuery(ctx); err != nil {
return err return err
} }
as.sql = as.AttachmentQuery.sqlQuery(ctx) return scanWithInterceptors[*AttachmentQuery, *AttachmentSelect](ctx, as.AttachmentQuery, as, as.inters, v)
return as.sqlScan(ctx, v)
} }
func (as *AttachmentSelect) sqlScan(ctx context.Context, v any) error { func (as *AttachmentSelect) sqlScan(ctx context.Context, root *AttachmentQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(as.fns)) aggregation := make([]string, 0, len(as.fns))
for _, fn := range as.fns { for _, fn := range as.fns {
aggregation = append(aggregation, fn(as.sql)) aggregation = append(aggregation, fn(selector))
} }
switch n := len(*as.selector.flds); { switch n := len(*as.selector.flds); {
case n == 0 && len(aggregation) > 0: case n == 0 && len(aggregation) > 0:
as.sql.Select(aggregation...) selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0: case n != 0 && len(aggregation) > 0:
as.sql.AppendSelect(aggregation...) selector.AppendSelect(aggregation...)
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := as.sql.Query() query, args := selector.Query()
if err := as.driver.Query(ctx, query, args, rows); err != nil { if err := as.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }

View file

@ -92,41 +92,8 @@ func (au *AttachmentUpdate) ClearDocument() *AttachmentUpdate {
// Save executes the query and returns the number of nodes affected by the update operation. // Save executes the query and returns the number of nodes affected by the update operation.
func (au *AttachmentUpdate) Save(ctx context.Context) (int, error) { func (au *AttachmentUpdate) Save(ctx context.Context) (int, error) {
var (
err error
affected int
)
au.defaults() au.defaults()
if len(au.hooks) == 0 { return withHooks[int, AttachmentMutation](ctx, au.sqlSave, au.mutation, au.hooks)
if err = au.check(); err != nil {
return 0, err
}
affected, err = au.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AttachmentMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = au.check(); err != nil {
return 0, err
}
au.mutation = mutation
affected, err = au.sqlSave(ctx)
mutation.done = true
return affected, err
})
for i := len(au.hooks) - 1; i >= 0; i-- {
if au.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = au.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, au.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -176,6 +143,9 @@ func (au *AttachmentUpdate) check() error {
} }
func (au *AttachmentUpdate) sqlSave(ctx context.Context) (n int, err error) { func (au *AttachmentUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := au.check(); err != nil {
return n, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: attachment.Table, Table: attachment.Table,
@ -277,6 +247,7 @@ func (au *AttachmentUpdate) sqlSave(ctx context.Context) (n int, err error) {
} }
return 0, err return 0, err
} }
au.mutation.done = true
return n, nil return n, nil
} }
@ -356,47 +327,8 @@ func (auo *AttachmentUpdateOne) Select(field string, fields ...string) *Attachme
// Save executes the query and returns the updated Attachment entity. // Save executes the query and returns the updated Attachment entity.
func (auo *AttachmentUpdateOne) Save(ctx context.Context) (*Attachment, error) { func (auo *AttachmentUpdateOne) Save(ctx context.Context) (*Attachment, error) {
var (
err error
node *Attachment
)
auo.defaults() auo.defaults()
if len(auo.hooks) == 0 { return withHooks[*Attachment, AttachmentMutation](ctx, auo.sqlSave, auo.mutation, auo.hooks)
if err = auo.check(); err != nil {
return nil, err
}
node, err = auo.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AttachmentMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = auo.check(); err != nil {
return nil, err
}
auo.mutation = mutation
node, err = auo.sqlSave(ctx)
mutation.done = true
return node, err
})
for i := len(auo.hooks) - 1; i >= 0; i-- {
if auo.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = auo.hooks[i](mut)
}
v, err := mut.Mutate(ctx, auo.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Attachment)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from AttachmentMutation", v)
}
node = nv
}
return node, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -446,6 +378,9 @@ func (auo *AttachmentUpdateOne) check() error {
} }
func (auo *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment, err error) { func (auo *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment, err error) {
if err := auo.check(); err != nil {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: attachment.Table, Table: attachment.Table,
@ -567,5 +502,6 @@ func (auo *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment,
} }
return nil, err return nil, err
} }
auo.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -10,109 +10,67 @@ import (
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.
func ID(id int) predicate.AuthRoles { func ID(id int) predicate.AuthRoles {
return predicate.AuthRoles(func(s *sql.Selector) { return predicate.AuthRoles(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDEQ applies the EQ predicate on the ID field. // IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int) predicate.AuthRoles { func IDEQ(id int) predicate.AuthRoles {
return predicate.AuthRoles(func(s *sql.Selector) { return predicate.AuthRoles(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDNEQ applies the NEQ predicate on the ID field. // IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int) predicate.AuthRoles { func IDNEQ(id int) predicate.AuthRoles {
return predicate.AuthRoles(func(s *sql.Selector) { return predicate.AuthRoles(sql.FieldNEQ(FieldID, id))
s.Where(sql.NEQ(s.C(FieldID), id))
})
} }
// IDIn applies the In predicate on the ID field. // IDIn applies the In predicate on the ID field.
func IDIn(ids ...int) predicate.AuthRoles { func IDIn(ids ...int) predicate.AuthRoles {
return predicate.AuthRoles(func(s *sql.Selector) { return predicate.AuthRoles(sql.FieldIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.In(s.C(FieldID), v...))
})
} }
// IDNotIn applies the NotIn predicate on the ID field. // IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int) predicate.AuthRoles { func IDNotIn(ids ...int) predicate.AuthRoles {
return predicate.AuthRoles(func(s *sql.Selector) { return predicate.AuthRoles(sql.FieldNotIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.NotIn(s.C(FieldID), v...))
})
} }
// IDGT applies the GT predicate on the ID field. // IDGT applies the GT predicate on the ID field.
func IDGT(id int) predicate.AuthRoles { func IDGT(id int) predicate.AuthRoles {
return predicate.AuthRoles(func(s *sql.Selector) { return predicate.AuthRoles(sql.FieldGT(FieldID, id))
s.Where(sql.GT(s.C(FieldID), id))
})
} }
// IDGTE applies the GTE predicate on the ID field. // IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int) predicate.AuthRoles { func IDGTE(id int) predicate.AuthRoles {
return predicate.AuthRoles(func(s *sql.Selector) { return predicate.AuthRoles(sql.FieldGTE(FieldID, id))
s.Where(sql.GTE(s.C(FieldID), id))
})
} }
// IDLT applies the LT predicate on the ID field. // IDLT applies the LT predicate on the ID field.
func IDLT(id int) predicate.AuthRoles { func IDLT(id int) predicate.AuthRoles {
return predicate.AuthRoles(func(s *sql.Selector) { return predicate.AuthRoles(sql.FieldLT(FieldID, id))
s.Where(sql.LT(s.C(FieldID), id))
})
} }
// IDLTE applies the LTE predicate on the ID field. // IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int) predicate.AuthRoles { func IDLTE(id int) predicate.AuthRoles {
return predicate.AuthRoles(func(s *sql.Selector) { return predicate.AuthRoles(sql.FieldLTE(FieldID, id))
s.Where(sql.LTE(s.C(FieldID), id))
})
} }
// RoleEQ applies the EQ predicate on the "role" field. // RoleEQ applies the EQ predicate on the "role" field.
func RoleEQ(v Role) predicate.AuthRoles { func RoleEQ(v Role) predicate.AuthRoles {
return predicate.AuthRoles(func(s *sql.Selector) { return predicate.AuthRoles(sql.FieldEQ(FieldRole, v))
s.Where(sql.EQ(s.C(FieldRole), v))
})
} }
// RoleNEQ applies the NEQ predicate on the "role" field. // RoleNEQ applies the NEQ predicate on the "role" field.
func RoleNEQ(v Role) predicate.AuthRoles { func RoleNEQ(v Role) predicate.AuthRoles {
return predicate.AuthRoles(func(s *sql.Selector) { return predicate.AuthRoles(sql.FieldNEQ(FieldRole, v))
s.Where(sql.NEQ(s.C(FieldRole), v))
})
} }
// RoleIn applies the In predicate on the "role" field. // RoleIn applies the In predicate on the "role" field.
func RoleIn(vs ...Role) predicate.AuthRoles { func RoleIn(vs ...Role) predicate.AuthRoles {
v := make([]any, len(vs)) return predicate.AuthRoles(sql.FieldIn(FieldRole, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.AuthRoles(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldRole), v...))
})
} }
// RoleNotIn applies the NotIn predicate on the "role" field. // RoleNotIn applies the NotIn predicate on the "role" field.
func RoleNotIn(vs ...Role) predicate.AuthRoles { func RoleNotIn(vs ...Role) predicate.AuthRoles {
v := make([]any, len(vs)) return predicate.AuthRoles(sql.FieldNotIn(FieldRole, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.AuthRoles(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldRole), v...))
})
} }
// HasToken applies the HasEdge predicate on the "token" edge. // HasToken applies the HasEdge predicate on the "token" edge.
@ -120,7 +78,6 @@ func HasToken() predicate.AuthRoles {
return predicate.AuthRoles(func(s *sql.Selector) { return predicate.AuthRoles(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(TokenTable, FieldID),
sqlgraph.Edge(sqlgraph.O2O, true, TokenTable, TokenColumn), sqlgraph.Edge(sqlgraph.O2O, true, TokenTable, TokenColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)

View file

@ -61,50 +61,8 @@ func (arc *AuthRolesCreate) Mutation() *AuthRolesMutation {
// Save creates the AuthRoles in the database. // Save creates the AuthRoles in the database.
func (arc *AuthRolesCreate) Save(ctx context.Context) (*AuthRoles, error) { func (arc *AuthRolesCreate) Save(ctx context.Context) (*AuthRoles, error) {
var (
err error
node *AuthRoles
)
arc.defaults() arc.defaults()
if len(arc.hooks) == 0 { return withHooks[*AuthRoles, AuthRolesMutation](ctx, arc.sqlSave, arc.mutation, arc.hooks)
if err = arc.check(); err != nil {
return nil, err
}
node, err = arc.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AuthRolesMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = arc.check(); err != nil {
return nil, err
}
arc.mutation = mutation
if node, err = arc.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(arc.hooks) - 1; i >= 0; i-- {
if arc.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = arc.hooks[i](mut)
}
v, err := mut.Mutate(ctx, arc.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*AuthRoles)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from AuthRolesMutation", v)
}
node = nv
}
return node, err
} }
// SaveX calls Save and panics if Save returns an error. // SaveX calls Save and panics if Save returns an error.
@ -151,6 +109,9 @@ func (arc *AuthRolesCreate) check() error {
} }
func (arc *AuthRolesCreate) sqlSave(ctx context.Context) (*AuthRoles, error) { func (arc *AuthRolesCreate) sqlSave(ctx context.Context) (*AuthRoles, error) {
if err := arc.check(); err != nil {
return nil, err
}
_node, _spec := arc.createSpec() _node, _spec := arc.createSpec()
if err := sqlgraph.CreateNode(ctx, arc.driver, _spec); err != nil { if err := sqlgraph.CreateNode(ctx, arc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) { if sqlgraph.IsConstraintError(err) {
@ -160,6 +121,8 @@ func (arc *AuthRolesCreate) sqlSave(ctx context.Context) (*AuthRoles, error) {
} }
id := _spec.ID.Value.(int64) id := _spec.ID.Value.(int64)
_node.ID = int(id) _node.ID = int(id)
arc.mutation.id = &_node.ID
arc.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -4,7 +4,6 @@ package ent
import ( import (
"context" "context"
"fmt"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
@ -28,34 +27,7 @@ func (ard *AuthRolesDelete) Where(ps ...predicate.AuthRoles) *AuthRolesDelete {
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (ard *AuthRolesDelete) Exec(ctx context.Context) (int, error) { func (ard *AuthRolesDelete) Exec(ctx context.Context) (int, error) {
var ( return withHooks[int, AuthRolesMutation](ctx, ard.sqlExec, ard.mutation, ard.hooks)
err error
affected int
)
if len(ard.hooks) == 0 {
affected, err = ard.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AuthRolesMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
ard.mutation = mutation
affected, err = ard.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(ard.hooks) - 1; i >= 0; i-- {
if ard.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = ard.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, ard.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
@ -88,6 +60,7 @@ func (ard *AuthRolesDelete) sqlExec(ctx context.Context) (int, error) {
if err != nil && sqlgraph.IsConstraintError(err) { if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
ard.mutation.done = true
return affected, err return affected, err
} }

View file

@ -24,6 +24,7 @@ type AuthRolesQuery struct {
unique *bool unique *bool
order []OrderFunc order []OrderFunc
fields []string fields []string
inters []Interceptor
predicates []predicate.AuthRoles predicates []predicate.AuthRoles
withToken *AuthTokensQuery withToken *AuthTokensQuery
withFKs bool withFKs bool
@ -38,13 +39,13 @@ func (arq *AuthRolesQuery) Where(ps ...predicate.AuthRoles) *AuthRolesQuery {
return arq return arq
} }
// Limit adds a limit step to the query. // Limit the number of records to be returned by this query.
func (arq *AuthRolesQuery) Limit(limit int) *AuthRolesQuery { func (arq *AuthRolesQuery) Limit(limit int) *AuthRolesQuery {
arq.limit = &limit arq.limit = &limit
return arq return arq
} }
// Offset adds an offset step to the query. // Offset to start from.
func (arq *AuthRolesQuery) Offset(offset int) *AuthRolesQuery { func (arq *AuthRolesQuery) Offset(offset int) *AuthRolesQuery {
arq.offset = &offset arq.offset = &offset
return arq return arq
@ -57,7 +58,7 @@ func (arq *AuthRolesQuery) Unique(unique bool) *AuthRolesQuery {
return arq return arq
} }
// Order adds an order step to the query. // Order specifies how the records should be ordered.
func (arq *AuthRolesQuery) Order(o ...OrderFunc) *AuthRolesQuery { func (arq *AuthRolesQuery) Order(o ...OrderFunc) *AuthRolesQuery {
arq.order = append(arq.order, o...) arq.order = append(arq.order, o...)
return arq return arq
@ -65,7 +66,7 @@ func (arq *AuthRolesQuery) Order(o ...OrderFunc) *AuthRolesQuery {
// QueryToken chains the current query on the "token" edge. // QueryToken chains the current query on the "token" edge.
func (arq *AuthRolesQuery) QueryToken() *AuthTokensQuery { func (arq *AuthRolesQuery) QueryToken() *AuthTokensQuery {
query := &AuthTokensQuery{config: arq.config} query := (&AuthTokensClient{config: arq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := arq.prepareQuery(ctx); err != nil { if err := arq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -88,7 +89,7 @@ func (arq *AuthRolesQuery) QueryToken() *AuthTokensQuery {
// First returns the first AuthRoles entity from the query. // First returns the first AuthRoles entity from the query.
// Returns a *NotFoundError when no AuthRoles was found. // Returns a *NotFoundError when no AuthRoles was found.
func (arq *AuthRolesQuery) First(ctx context.Context) (*AuthRoles, error) { func (arq *AuthRolesQuery) First(ctx context.Context) (*AuthRoles, error) {
nodes, err := arq.Limit(1).All(ctx) nodes, err := arq.Limit(1).All(newQueryContext(ctx, TypeAuthRoles, "First"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -111,7 +112,7 @@ func (arq *AuthRolesQuery) FirstX(ctx context.Context) *AuthRoles {
// Returns a *NotFoundError when no AuthRoles ID was found. // Returns a *NotFoundError when no AuthRoles ID was found.
func (arq *AuthRolesQuery) FirstID(ctx context.Context) (id int, err error) { func (arq *AuthRolesQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int var ids []int
if ids, err = arq.Limit(1).IDs(ctx); err != nil { if ids, err = arq.Limit(1).IDs(newQueryContext(ctx, TypeAuthRoles, "FirstID")); err != nil {
return return
} }
if len(ids) == 0 { if len(ids) == 0 {
@ -134,7 +135,7 @@ func (arq *AuthRolesQuery) FirstIDX(ctx context.Context) int {
// Returns a *NotSingularError when more than one AuthRoles entity is found. // Returns a *NotSingularError when more than one AuthRoles entity is found.
// Returns a *NotFoundError when no AuthRoles entities are found. // Returns a *NotFoundError when no AuthRoles entities are found.
func (arq *AuthRolesQuery) Only(ctx context.Context) (*AuthRoles, error) { func (arq *AuthRolesQuery) Only(ctx context.Context) (*AuthRoles, error) {
nodes, err := arq.Limit(2).All(ctx) nodes, err := arq.Limit(2).All(newQueryContext(ctx, TypeAuthRoles, "Only"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -162,7 +163,7 @@ func (arq *AuthRolesQuery) OnlyX(ctx context.Context) *AuthRoles {
// Returns a *NotFoundError when no entities are found. // Returns a *NotFoundError when no entities are found.
func (arq *AuthRolesQuery) OnlyID(ctx context.Context) (id int, err error) { func (arq *AuthRolesQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int var ids []int
if ids, err = arq.Limit(2).IDs(ctx); err != nil { if ids, err = arq.Limit(2).IDs(newQueryContext(ctx, TypeAuthRoles, "OnlyID")); err != nil {
return return
} }
switch len(ids) { switch len(ids) {
@ -187,10 +188,12 @@ func (arq *AuthRolesQuery) OnlyIDX(ctx context.Context) int {
// All executes the query and returns a list of AuthRolesSlice. // All executes the query and returns a list of AuthRolesSlice.
func (arq *AuthRolesQuery) All(ctx context.Context) ([]*AuthRoles, error) { func (arq *AuthRolesQuery) All(ctx context.Context) ([]*AuthRoles, error) {
ctx = newQueryContext(ctx, TypeAuthRoles, "All")
if err := arq.prepareQuery(ctx); err != nil { if err := arq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return arq.sqlAll(ctx) qr := querierAll[[]*AuthRoles, *AuthRolesQuery]()
return withInterceptors[[]*AuthRoles](ctx, arq, qr, arq.inters)
} }
// AllX is like All, but panics if an error occurs. // AllX is like All, but panics if an error occurs.
@ -205,6 +208,7 @@ func (arq *AuthRolesQuery) AllX(ctx context.Context) []*AuthRoles {
// IDs executes the query and returns a list of AuthRoles IDs. // IDs executes the query and returns a list of AuthRoles IDs.
func (arq *AuthRolesQuery) IDs(ctx context.Context) ([]int, error) { func (arq *AuthRolesQuery) IDs(ctx context.Context) ([]int, error) {
var ids []int var ids []int
ctx = newQueryContext(ctx, TypeAuthRoles, "IDs")
if err := arq.Select(authroles.FieldID).Scan(ctx, &ids); err != nil { if err := arq.Select(authroles.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
@ -222,10 +226,11 @@ func (arq *AuthRolesQuery) IDsX(ctx context.Context) []int {
// Count returns the count of the given query. // Count returns the count of the given query.
func (arq *AuthRolesQuery) Count(ctx context.Context) (int, error) { func (arq *AuthRolesQuery) Count(ctx context.Context) (int, error) {
ctx = newQueryContext(ctx, TypeAuthRoles, "Count")
if err := arq.prepareQuery(ctx); err != nil { if err := arq.prepareQuery(ctx); err != nil {
return 0, err return 0, err
} }
return arq.sqlCount(ctx) return withInterceptors[int](ctx, arq, querierCount[*AuthRolesQuery](), arq.inters)
} }
// CountX is like Count, but panics if an error occurs. // CountX is like Count, but panics if an error occurs.
@ -239,10 +244,15 @@ func (arq *AuthRolesQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph. // Exist returns true if the query has elements in the graph.
func (arq *AuthRolesQuery) Exist(ctx context.Context) (bool, error) { func (arq *AuthRolesQuery) Exist(ctx context.Context) (bool, error) {
if err := arq.prepareQuery(ctx); err != nil { ctx = newQueryContext(ctx, TypeAuthRoles, "Exist")
return false, err switch _, err := arq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
} }
return arq.sqlExist(ctx)
} }
// ExistX is like Exist, but panics if an error occurs. // ExistX is like Exist, but panics if an error occurs.
@ -265,6 +275,7 @@ func (arq *AuthRolesQuery) Clone() *AuthRolesQuery {
limit: arq.limit, limit: arq.limit,
offset: arq.offset, offset: arq.offset,
order: append([]OrderFunc{}, arq.order...), order: append([]OrderFunc{}, arq.order...),
inters: append([]Interceptor{}, arq.inters...),
predicates: append([]predicate.AuthRoles{}, arq.predicates...), predicates: append([]predicate.AuthRoles{}, arq.predicates...),
withToken: arq.withToken.Clone(), withToken: arq.withToken.Clone(),
// clone intermediate query. // clone intermediate query.
@ -277,7 +288,7 @@ func (arq *AuthRolesQuery) Clone() *AuthRolesQuery {
// WithToken tells the query-builder to eager-load the nodes that are connected to // WithToken tells the query-builder to eager-load the nodes that are connected to
// the "token" edge. The optional arguments are used to configure the query builder of the edge. // the "token" edge. The optional arguments are used to configure the query builder of the edge.
func (arq *AuthRolesQuery) WithToken(opts ...func(*AuthTokensQuery)) *AuthRolesQuery { func (arq *AuthRolesQuery) WithToken(opts ...func(*AuthTokensQuery)) *AuthRolesQuery {
query := &AuthTokensQuery{config: arq.config} query := (&AuthTokensClient{config: arq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -300,16 +311,11 @@ func (arq *AuthRolesQuery) WithToken(opts ...func(*AuthTokensQuery)) *AuthRolesQ
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (arq *AuthRolesQuery) GroupBy(field string, fields ...string) *AuthRolesGroupBy { func (arq *AuthRolesQuery) GroupBy(field string, fields ...string) *AuthRolesGroupBy {
grbuild := &AuthRolesGroupBy{config: arq.config} arq.fields = append([]string{field}, fields...)
grbuild.fields = append([]string{field}, fields...) grbuild := &AuthRolesGroupBy{build: arq}
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { grbuild.flds = &arq.fields
if err := arq.prepareQuery(ctx); err != nil {
return nil, err
}
return arq.sqlQuery(ctx), nil
}
grbuild.label = authroles.Label grbuild.label = authroles.Label
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan grbuild.scan = grbuild.Scan
return grbuild return grbuild
} }
@ -327,10 +333,10 @@ func (arq *AuthRolesQuery) GroupBy(field string, fields ...string) *AuthRolesGro
// Scan(ctx, &v) // Scan(ctx, &v)
func (arq *AuthRolesQuery) Select(fields ...string) *AuthRolesSelect { func (arq *AuthRolesQuery) Select(fields ...string) *AuthRolesSelect {
arq.fields = append(arq.fields, fields...) arq.fields = append(arq.fields, fields...)
selbuild := &AuthRolesSelect{AuthRolesQuery: arq} sbuild := &AuthRolesSelect{AuthRolesQuery: arq}
selbuild.label = authroles.Label sbuild.label = authroles.Label
selbuild.flds, selbuild.scan = &arq.fields, selbuild.Scan sbuild.flds, sbuild.scan = &arq.fields, sbuild.Scan
return selbuild return sbuild
} }
// Aggregate returns a AuthRolesSelect configured with the given aggregations. // Aggregate returns a AuthRolesSelect configured with the given aggregations.
@ -339,6 +345,16 @@ func (arq *AuthRolesQuery) Aggregate(fns ...AggregateFunc) *AuthRolesSelect {
} }
func (arq *AuthRolesQuery) prepareQuery(ctx context.Context) error { func (arq *AuthRolesQuery) prepareQuery(ctx context.Context) error {
for _, inter := range arq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, arq); err != nil {
return err
}
}
}
for _, f := range arq.fields { for _, f := range arq.fields {
if !authroles.ValidColumn(f) { if !authroles.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
@ -435,17 +451,6 @@ func (arq *AuthRolesQuery) sqlCount(ctx context.Context) (int, error) {
return sqlgraph.CountNodes(ctx, arq.driver, _spec) return sqlgraph.CountNodes(ctx, arq.driver, _spec)
} }
func (arq *AuthRolesQuery) sqlExist(ctx context.Context) (bool, error) {
switch _, err := arq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
func (arq *AuthRolesQuery) querySpec() *sqlgraph.QuerySpec { func (arq *AuthRolesQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
@ -528,13 +533,8 @@ func (arq *AuthRolesQuery) sqlQuery(ctx context.Context) *sql.Selector {
// AuthRolesGroupBy is the group-by builder for AuthRoles entities. // AuthRolesGroupBy is the group-by builder for AuthRoles entities.
type AuthRolesGroupBy struct { type AuthRolesGroupBy struct {
config
selector selector
fields []string build *AuthRolesQuery
fns []AggregateFunc
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
} }
// Aggregate adds the given aggregation functions to the group-by query. // Aggregate adds the given aggregation functions to the group-by query.
@ -543,58 +543,46 @@ func (argb *AuthRolesGroupBy) Aggregate(fns ...AggregateFunc) *AuthRolesGroupBy
return argb return argb
} }
// Scan applies the group-by query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (argb *AuthRolesGroupBy) Scan(ctx context.Context, v any) error { func (argb *AuthRolesGroupBy) Scan(ctx context.Context, v any) error {
query, err := argb.path(ctx) ctx = newQueryContext(ctx, TypeAuthRoles, "GroupBy")
if err != nil { if err := argb.build.prepareQuery(ctx); err != nil {
return err return err
} }
argb.sql = query return scanWithInterceptors[*AuthRolesQuery, *AuthRolesGroupBy](ctx, argb.build, argb, argb.build.inters, v)
return argb.sqlScan(ctx, v)
} }
func (argb *AuthRolesGroupBy) sqlScan(ctx context.Context, v any) error { func (argb *AuthRolesGroupBy) sqlScan(ctx context.Context, root *AuthRolesQuery, v any) error {
for _, f := range argb.fields { selector := root.sqlQuery(ctx).Select()
if !authroles.ValidColumn(f) { aggregation := make([]string, 0, len(argb.fns))
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} for _, fn := range argb.fns {
} aggregation = append(aggregation, fn(selector))
} }
selector := argb.sqlQuery() if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*argb.flds)+len(argb.fns))
for _, f := range *argb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*argb.flds...)...)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return err return err
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() query, args := selector.Query()
if err := argb.driver.Query(ctx, query, args, rows); err != nil { if err := argb.build.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }
defer rows.Close() defer rows.Close()
return sql.ScanSlice(rows, v) return sql.ScanSlice(rows, v)
} }
func (argb *AuthRolesGroupBy) sqlQuery() *sql.Selector {
selector := argb.sql.Select()
aggregation := make([]string, 0, len(argb.fns))
for _, fn := range argb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(argb.fields)+len(argb.fns))
for _, f := range argb.fields {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
return selector.GroupBy(selector.Columns(argb.fields...)...)
}
// AuthRolesSelect is the builder for selecting fields of AuthRoles entities. // AuthRolesSelect is the builder for selecting fields of AuthRoles entities.
type AuthRolesSelect struct { type AuthRolesSelect struct {
*AuthRolesQuery *AuthRolesQuery
selector selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
@ -605,26 +593,27 @@ func (ars *AuthRolesSelect) Aggregate(fns ...AggregateFunc) *AuthRolesSelect {
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (ars *AuthRolesSelect) Scan(ctx context.Context, v any) error { func (ars *AuthRolesSelect) Scan(ctx context.Context, v any) error {
ctx = newQueryContext(ctx, TypeAuthRoles, "Select")
if err := ars.prepareQuery(ctx); err != nil { if err := ars.prepareQuery(ctx); err != nil {
return err return err
} }
ars.sql = ars.AuthRolesQuery.sqlQuery(ctx) return scanWithInterceptors[*AuthRolesQuery, *AuthRolesSelect](ctx, ars.AuthRolesQuery, ars, ars.inters, v)
return ars.sqlScan(ctx, v)
} }
func (ars *AuthRolesSelect) sqlScan(ctx context.Context, v any) error { func (ars *AuthRolesSelect) sqlScan(ctx context.Context, root *AuthRolesQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(ars.fns)) aggregation := make([]string, 0, len(ars.fns))
for _, fn := range ars.fns { for _, fn := range ars.fns {
aggregation = append(aggregation, fn(ars.sql)) aggregation = append(aggregation, fn(selector))
} }
switch n := len(*ars.selector.flds); { switch n := len(*ars.selector.flds); {
case n == 0 && len(aggregation) > 0: case n == 0 && len(aggregation) > 0:
ars.sql.Select(aggregation...) selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0: case n != 0 && len(aggregation) > 0:
ars.sql.AppendSelect(aggregation...) selector.AppendSelect(aggregation...)
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := ars.sql.Query() query, args := selector.Query()
if err := ars.driver.Query(ctx, query, args, rows); err != nil { if err := ars.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }

View file

@ -75,40 +75,7 @@ func (aru *AuthRolesUpdate) ClearToken() *AuthRolesUpdate {
// Save executes the query and returns the number of nodes affected by the update operation. // Save executes the query and returns the number of nodes affected by the update operation.
func (aru *AuthRolesUpdate) Save(ctx context.Context) (int, error) { func (aru *AuthRolesUpdate) Save(ctx context.Context) (int, error) {
var ( return withHooks[int, AuthRolesMutation](ctx, aru.sqlSave, aru.mutation, aru.hooks)
err error
affected int
)
if len(aru.hooks) == 0 {
if err = aru.check(); err != nil {
return 0, err
}
affected, err = aru.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AuthRolesMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = aru.check(); err != nil {
return 0, err
}
aru.mutation = mutation
affected, err = aru.sqlSave(ctx)
mutation.done = true
return affected, err
})
for i := len(aru.hooks) - 1; i >= 0; i-- {
if aru.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = aru.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, aru.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -144,6 +111,9 @@ func (aru *AuthRolesUpdate) check() error {
} }
func (aru *AuthRolesUpdate) sqlSave(ctx context.Context) (n int, err error) { func (aru *AuthRolesUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := aru.check(); err != nil {
return n, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: authroles.Table, Table: authroles.Table,
@ -207,6 +177,7 @@ func (aru *AuthRolesUpdate) sqlSave(ctx context.Context) (n int, err error) {
} }
return 0, err return 0, err
} }
aru.mutation.done = true
return n, nil return n, nil
} }
@ -271,46 +242,7 @@ func (aruo *AuthRolesUpdateOne) Select(field string, fields ...string) *AuthRole
// Save executes the query and returns the updated AuthRoles entity. // Save executes the query and returns the updated AuthRoles entity.
func (aruo *AuthRolesUpdateOne) Save(ctx context.Context) (*AuthRoles, error) { func (aruo *AuthRolesUpdateOne) Save(ctx context.Context) (*AuthRoles, error) {
var ( return withHooks[*AuthRoles, AuthRolesMutation](ctx, aruo.sqlSave, aruo.mutation, aruo.hooks)
err error
node *AuthRoles
)
if len(aruo.hooks) == 0 {
if err = aruo.check(); err != nil {
return nil, err
}
node, err = aruo.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AuthRolesMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = aruo.check(); err != nil {
return nil, err
}
aruo.mutation = mutation
node, err = aruo.sqlSave(ctx)
mutation.done = true
return node, err
})
for i := len(aruo.hooks) - 1; i >= 0; i-- {
if aruo.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = aruo.hooks[i](mut)
}
v, err := mut.Mutate(ctx, aruo.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*AuthRoles)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from AuthRolesMutation", v)
}
node = nv
}
return node, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -346,6 +278,9 @@ func (aruo *AuthRolesUpdateOne) check() error {
} }
func (aruo *AuthRolesUpdateOne) sqlSave(ctx context.Context) (_node *AuthRoles, err error) { func (aruo *AuthRolesUpdateOne) sqlSave(ctx context.Context) (_node *AuthRoles, err error) {
if err := aruo.check(); err != nil {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: authroles.Table, Table: authroles.Table,
@ -429,5 +364,6 @@ func (aruo *AuthRolesUpdateOne) sqlSave(ctx context.Context) (_node *AuthRoles,
} }
return nil, err return nil, err
} }
aruo.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -13,357 +13,227 @@ import (
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.
func ID(id uuid.UUID) predicate.AuthTokens { func ID(id uuid.UUID) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDEQ applies the EQ predicate on the ID field. // IDEQ applies the EQ predicate on the ID field.
func IDEQ(id uuid.UUID) predicate.AuthTokens { func IDEQ(id uuid.UUID) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDNEQ applies the NEQ predicate on the ID field. // IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id uuid.UUID) predicate.AuthTokens { func IDNEQ(id uuid.UUID) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldNEQ(FieldID, id))
s.Where(sql.NEQ(s.C(FieldID), id))
})
} }
// IDIn applies the In predicate on the ID field. // IDIn applies the In predicate on the ID field.
func IDIn(ids ...uuid.UUID) predicate.AuthTokens { func IDIn(ids ...uuid.UUID) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.In(s.C(FieldID), v...))
})
} }
// IDNotIn applies the NotIn predicate on the ID field. // IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...uuid.UUID) predicate.AuthTokens { func IDNotIn(ids ...uuid.UUID) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldNotIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.NotIn(s.C(FieldID), v...))
})
} }
// IDGT applies the GT predicate on the ID field. // IDGT applies the GT predicate on the ID field.
func IDGT(id uuid.UUID) predicate.AuthTokens { func IDGT(id uuid.UUID) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldGT(FieldID, id))
s.Where(sql.GT(s.C(FieldID), id))
})
} }
// IDGTE applies the GTE predicate on the ID field. // IDGTE applies the GTE predicate on the ID field.
func IDGTE(id uuid.UUID) predicate.AuthTokens { func IDGTE(id uuid.UUID) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldGTE(FieldID, id))
s.Where(sql.GTE(s.C(FieldID), id))
})
} }
// IDLT applies the LT predicate on the ID field. // IDLT applies the LT predicate on the ID field.
func IDLT(id uuid.UUID) predicate.AuthTokens { func IDLT(id uuid.UUID) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldLT(FieldID, id))
s.Where(sql.LT(s.C(FieldID), id))
})
} }
// IDLTE applies the LTE predicate on the ID field. // IDLTE applies the LTE predicate on the ID field.
func IDLTE(id uuid.UUID) predicate.AuthTokens { func IDLTE(id uuid.UUID) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldLTE(FieldID, id))
s.Where(sql.LTE(s.C(FieldID), id))
})
} }
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. // CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.AuthTokens { func CreatedAt(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. // UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.AuthTokens { func UpdatedAt(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// Token applies equality check predicate on the "token" field. It's identical to TokenEQ. // Token applies equality check predicate on the "token" field. It's identical to TokenEQ.
func Token(v []byte) predicate.AuthTokens { func Token(v []byte) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldEQ(FieldToken, v))
s.Where(sql.EQ(s.C(FieldToken), v))
})
} }
// ExpiresAt applies equality check predicate on the "expires_at" field. It's identical to ExpiresAtEQ. // ExpiresAt applies equality check predicate on the "expires_at" field. It's identical to ExpiresAtEQ.
func ExpiresAt(v time.Time) predicate.AuthTokens { func ExpiresAt(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldEQ(FieldExpiresAt, v))
s.Where(sql.EQ(s.C(FieldExpiresAt), v))
})
} }
// CreatedAtEQ applies the EQ predicate on the "created_at" field. // CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.AuthTokens { func CreatedAtEQ(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. // CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.AuthTokens { func CreatedAtNEQ(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldNEQ(FieldCreatedAt, v))
s.Where(sql.NEQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtIn applies the In predicate on the "created_at" field. // CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.AuthTokens { func CreatedAtIn(vs ...time.Time) predicate.AuthTokens {
v := make([]any, len(vs)) return predicate.AuthTokens(sql.FieldIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.AuthTokens(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. // CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.AuthTokens { func CreatedAtNotIn(vs ...time.Time) predicate.AuthTokens {
v := make([]any, len(vs)) return predicate.AuthTokens(sql.FieldNotIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.AuthTokens(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtGT applies the GT predicate on the "created_at" field. // CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.AuthTokens { func CreatedAtGT(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldGT(FieldCreatedAt, v))
s.Where(sql.GT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtGTE applies the GTE predicate on the "created_at" field. // CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.AuthTokens { func CreatedAtGTE(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldGTE(FieldCreatedAt, v))
s.Where(sql.GTE(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLT applies the LT predicate on the "created_at" field. // CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.AuthTokens { func CreatedAtLT(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldLT(FieldCreatedAt, v))
s.Where(sql.LT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLTE applies the LTE predicate on the "created_at" field. // CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.AuthTokens { func CreatedAtLTE(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldLTE(FieldCreatedAt, v))
s.Where(sql.LTE(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. // UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.AuthTokens { func UpdatedAtEQ(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. // UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.AuthTokens { func UpdatedAtNEQ(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldNEQ(FieldUpdatedAt, v))
s.Where(sql.NEQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtIn applies the In predicate on the "updated_at" field. // UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.AuthTokens { func UpdatedAtIn(vs ...time.Time) predicate.AuthTokens {
v := make([]any, len(vs)) return predicate.AuthTokens(sql.FieldIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.AuthTokens(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. // UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.AuthTokens { func UpdatedAtNotIn(vs ...time.Time) predicate.AuthTokens {
v := make([]any, len(vs)) return predicate.AuthTokens(sql.FieldNotIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.AuthTokens(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtGT applies the GT predicate on the "updated_at" field. // UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.AuthTokens { func UpdatedAtGT(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldGT(FieldUpdatedAt, v))
s.Where(sql.GT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. // UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.AuthTokens { func UpdatedAtGTE(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldGTE(FieldUpdatedAt, v))
s.Where(sql.GTE(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLT applies the LT predicate on the "updated_at" field. // UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.AuthTokens { func UpdatedAtLT(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldLT(FieldUpdatedAt, v))
s.Where(sql.LT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. // UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.AuthTokens { func UpdatedAtLTE(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldLTE(FieldUpdatedAt, v))
s.Where(sql.LTE(s.C(FieldUpdatedAt), v))
})
} }
// TokenEQ applies the EQ predicate on the "token" field. // TokenEQ applies the EQ predicate on the "token" field.
func TokenEQ(v []byte) predicate.AuthTokens { func TokenEQ(v []byte) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldEQ(FieldToken, v))
s.Where(sql.EQ(s.C(FieldToken), v))
})
} }
// TokenNEQ applies the NEQ predicate on the "token" field. // TokenNEQ applies the NEQ predicate on the "token" field.
func TokenNEQ(v []byte) predicate.AuthTokens { func TokenNEQ(v []byte) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldNEQ(FieldToken, v))
s.Where(sql.NEQ(s.C(FieldToken), v))
})
} }
// TokenIn applies the In predicate on the "token" field. // TokenIn applies the In predicate on the "token" field.
func TokenIn(vs ...[]byte) predicate.AuthTokens { func TokenIn(vs ...[]byte) predicate.AuthTokens {
v := make([]any, len(vs)) return predicate.AuthTokens(sql.FieldIn(FieldToken, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.AuthTokens(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldToken), v...))
})
} }
// TokenNotIn applies the NotIn predicate on the "token" field. // TokenNotIn applies the NotIn predicate on the "token" field.
func TokenNotIn(vs ...[]byte) predicate.AuthTokens { func TokenNotIn(vs ...[]byte) predicate.AuthTokens {
v := make([]any, len(vs)) return predicate.AuthTokens(sql.FieldNotIn(FieldToken, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.AuthTokens(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldToken), v...))
})
} }
// TokenGT applies the GT predicate on the "token" field. // TokenGT applies the GT predicate on the "token" field.
func TokenGT(v []byte) predicate.AuthTokens { func TokenGT(v []byte) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldGT(FieldToken, v))
s.Where(sql.GT(s.C(FieldToken), v))
})
} }
// TokenGTE applies the GTE predicate on the "token" field. // TokenGTE applies the GTE predicate on the "token" field.
func TokenGTE(v []byte) predicate.AuthTokens { func TokenGTE(v []byte) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldGTE(FieldToken, v))
s.Where(sql.GTE(s.C(FieldToken), v))
})
} }
// TokenLT applies the LT predicate on the "token" field. // TokenLT applies the LT predicate on the "token" field.
func TokenLT(v []byte) predicate.AuthTokens { func TokenLT(v []byte) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldLT(FieldToken, v))
s.Where(sql.LT(s.C(FieldToken), v))
})
} }
// TokenLTE applies the LTE predicate on the "token" field. // TokenLTE applies the LTE predicate on the "token" field.
func TokenLTE(v []byte) predicate.AuthTokens { func TokenLTE(v []byte) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldLTE(FieldToken, v))
s.Where(sql.LTE(s.C(FieldToken), v))
})
} }
// ExpiresAtEQ applies the EQ predicate on the "expires_at" field. // ExpiresAtEQ applies the EQ predicate on the "expires_at" field.
func ExpiresAtEQ(v time.Time) predicate.AuthTokens { func ExpiresAtEQ(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldEQ(FieldExpiresAt, v))
s.Where(sql.EQ(s.C(FieldExpiresAt), v))
})
} }
// ExpiresAtNEQ applies the NEQ predicate on the "expires_at" field. // ExpiresAtNEQ applies the NEQ predicate on the "expires_at" field.
func ExpiresAtNEQ(v time.Time) predicate.AuthTokens { func ExpiresAtNEQ(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldNEQ(FieldExpiresAt, v))
s.Where(sql.NEQ(s.C(FieldExpiresAt), v))
})
} }
// ExpiresAtIn applies the In predicate on the "expires_at" field. // ExpiresAtIn applies the In predicate on the "expires_at" field.
func ExpiresAtIn(vs ...time.Time) predicate.AuthTokens { func ExpiresAtIn(vs ...time.Time) predicate.AuthTokens {
v := make([]any, len(vs)) return predicate.AuthTokens(sql.FieldIn(FieldExpiresAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.AuthTokens(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldExpiresAt), v...))
})
} }
// ExpiresAtNotIn applies the NotIn predicate on the "expires_at" field. // ExpiresAtNotIn applies the NotIn predicate on the "expires_at" field.
func ExpiresAtNotIn(vs ...time.Time) predicate.AuthTokens { func ExpiresAtNotIn(vs ...time.Time) predicate.AuthTokens {
v := make([]any, len(vs)) return predicate.AuthTokens(sql.FieldNotIn(FieldExpiresAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.AuthTokens(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldExpiresAt), v...))
})
} }
// ExpiresAtGT applies the GT predicate on the "expires_at" field. // ExpiresAtGT applies the GT predicate on the "expires_at" field.
func ExpiresAtGT(v time.Time) predicate.AuthTokens { func ExpiresAtGT(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldGT(FieldExpiresAt, v))
s.Where(sql.GT(s.C(FieldExpiresAt), v))
})
} }
// ExpiresAtGTE applies the GTE predicate on the "expires_at" field. // ExpiresAtGTE applies the GTE predicate on the "expires_at" field.
func ExpiresAtGTE(v time.Time) predicate.AuthTokens { func ExpiresAtGTE(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldGTE(FieldExpiresAt, v))
s.Where(sql.GTE(s.C(FieldExpiresAt), v))
})
} }
// ExpiresAtLT applies the LT predicate on the "expires_at" field. // ExpiresAtLT applies the LT predicate on the "expires_at" field.
func ExpiresAtLT(v time.Time) predicate.AuthTokens { func ExpiresAtLT(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldLT(FieldExpiresAt, v))
s.Where(sql.LT(s.C(FieldExpiresAt), v))
})
} }
// ExpiresAtLTE applies the LTE predicate on the "expires_at" field. // ExpiresAtLTE applies the LTE predicate on the "expires_at" field.
func ExpiresAtLTE(v time.Time) predicate.AuthTokens { func ExpiresAtLTE(v time.Time) predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(sql.FieldLTE(FieldExpiresAt, v))
s.Where(sql.LTE(s.C(FieldExpiresAt), v))
})
} }
// HasUser applies the HasEdge predicate on the "user" edge. // HasUser applies the HasEdge predicate on the "user" edge.
@ -371,7 +241,6 @@ func HasUser() predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(UserTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn), sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)
@ -399,7 +268,6 @@ func HasRoles() predicate.AuthTokens {
return predicate.AuthTokens(func(s *sql.Selector) { return predicate.AuthTokens(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(RolesTable, FieldID),
sqlgraph.Edge(sqlgraph.O2O, false, RolesTable, RolesColumn), sqlgraph.Edge(sqlgraph.O2O, false, RolesTable, RolesColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)

View file

@ -130,50 +130,8 @@ func (atc *AuthTokensCreate) Mutation() *AuthTokensMutation {
// Save creates the AuthTokens in the database. // Save creates the AuthTokens in the database.
func (atc *AuthTokensCreate) Save(ctx context.Context) (*AuthTokens, error) { func (atc *AuthTokensCreate) Save(ctx context.Context) (*AuthTokens, error) {
var (
err error
node *AuthTokens
)
atc.defaults() atc.defaults()
if len(atc.hooks) == 0 { return withHooks[*AuthTokens, AuthTokensMutation](ctx, atc.sqlSave, atc.mutation, atc.hooks)
if err = atc.check(); err != nil {
return nil, err
}
node, err = atc.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AuthTokensMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = atc.check(); err != nil {
return nil, err
}
atc.mutation = mutation
if node, err = atc.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(atc.hooks) - 1; i >= 0; i-- {
if atc.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = atc.hooks[i](mut)
}
v, err := mut.Mutate(ctx, atc.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*AuthTokens)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from AuthTokensMutation", v)
}
node = nv
}
return node, err
} }
// SaveX calls Save and panics if Save returns an error. // SaveX calls Save and panics if Save returns an error.
@ -236,6 +194,9 @@ func (atc *AuthTokensCreate) check() error {
} }
func (atc *AuthTokensCreate) sqlSave(ctx context.Context) (*AuthTokens, error) { func (atc *AuthTokensCreate) sqlSave(ctx context.Context) (*AuthTokens, error) {
if err := atc.check(); err != nil {
return nil, err
}
_node, _spec := atc.createSpec() _node, _spec := atc.createSpec()
if err := sqlgraph.CreateNode(ctx, atc.driver, _spec); err != nil { if err := sqlgraph.CreateNode(ctx, atc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) { if sqlgraph.IsConstraintError(err) {
@ -250,6 +211,8 @@ func (atc *AuthTokensCreate) sqlSave(ctx context.Context) (*AuthTokens, error) {
return nil, err return nil, err
} }
} }
atc.mutation.id = &_node.ID
atc.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -4,7 +4,6 @@ package ent
import ( import (
"context" "context"
"fmt"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
@ -28,34 +27,7 @@ func (atd *AuthTokensDelete) Where(ps ...predicate.AuthTokens) *AuthTokensDelete
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (atd *AuthTokensDelete) Exec(ctx context.Context) (int, error) { func (atd *AuthTokensDelete) Exec(ctx context.Context) (int, error) {
var ( return withHooks[int, AuthTokensMutation](ctx, atd.sqlExec, atd.mutation, atd.hooks)
err error
affected int
)
if len(atd.hooks) == 0 {
affected, err = atd.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AuthTokensMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
atd.mutation = mutation
affected, err = atd.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(atd.hooks) - 1; i >= 0; i-- {
if atd.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = atd.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, atd.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
@ -88,6 +60,7 @@ func (atd *AuthTokensDelete) sqlExec(ctx context.Context) (int, error) {
if err != nil && sqlgraph.IsConstraintError(err) { if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
atd.mutation.done = true
return affected, err return affected, err
} }

View file

@ -26,6 +26,7 @@ type AuthTokensQuery struct {
unique *bool unique *bool
order []OrderFunc order []OrderFunc
fields []string fields []string
inters []Interceptor
predicates []predicate.AuthTokens predicates []predicate.AuthTokens
withUser *UserQuery withUser *UserQuery
withRoles *AuthRolesQuery withRoles *AuthRolesQuery
@ -41,13 +42,13 @@ func (atq *AuthTokensQuery) Where(ps ...predicate.AuthTokens) *AuthTokensQuery {
return atq return atq
} }
// Limit adds a limit step to the query. // Limit the number of records to be returned by this query.
func (atq *AuthTokensQuery) Limit(limit int) *AuthTokensQuery { func (atq *AuthTokensQuery) Limit(limit int) *AuthTokensQuery {
atq.limit = &limit atq.limit = &limit
return atq return atq
} }
// Offset adds an offset step to the query. // Offset to start from.
func (atq *AuthTokensQuery) Offset(offset int) *AuthTokensQuery { func (atq *AuthTokensQuery) Offset(offset int) *AuthTokensQuery {
atq.offset = &offset atq.offset = &offset
return atq return atq
@ -60,7 +61,7 @@ func (atq *AuthTokensQuery) Unique(unique bool) *AuthTokensQuery {
return atq return atq
} }
// Order adds an order step to the query. // Order specifies how the records should be ordered.
func (atq *AuthTokensQuery) Order(o ...OrderFunc) *AuthTokensQuery { func (atq *AuthTokensQuery) Order(o ...OrderFunc) *AuthTokensQuery {
atq.order = append(atq.order, o...) atq.order = append(atq.order, o...)
return atq return atq
@ -68,7 +69,7 @@ func (atq *AuthTokensQuery) Order(o ...OrderFunc) *AuthTokensQuery {
// QueryUser chains the current query on the "user" edge. // QueryUser chains the current query on the "user" edge.
func (atq *AuthTokensQuery) QueryUser() *UserQuery { func (atq *AuthTokensQuery) QueryUser() *UserQuery {
query := &UserQuery{config: atq.config} query := (&UserClient{config: atq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := atq.prepareQuery(ctx); err != nil { if err := atq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -90,7 +91,7 @@ func (atq *AuthTokensQuery) QueryUser() *UserQuery {
// QueryRoles chains the current query on the "roles" edge. // QueryRoles chains the current query on the "roles" edge.
func (atq *AuthTokensQuery) QueryRoles() *AuthRolesQuery { func (atq *AuthTokensQuery) QueryRoles() *AuthRolesQuery {
query := &AuthRolesQuery{config: atq.config} query := (&AuthRolesClient{config: atq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := atq.prepareQuery(ctx); err != nil { if err := atq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -113,7 +114,7 @@ func (atq *AuthTokensQuery) QueryRoles() *AuthRolesQuery {
// First returns the first AuthTokens entity from the query. // First returns the first AuthTokens entity from the query.
// Returns a *NotFoundError when no AuthTokens was found. // Returns a *NotFoundError when no AuthTokens was found.
func (atq *AuthTokensQuery) First(ctx context.Context) (*AuthTokens, error) { func (atq *AuthTokensQuery) First(ctx context.Context) (*AuthTokens, error) {
nodes, err := atq.Limit(1).All(ctx) nodes, err := atq.Limit(1).All(newQueryContext(ctx, TypeAuthTokens, "First"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -136,7 +137,7 @@ func (atq *AuthTokensQuery) FirstX(ctx context.Context) *AuthTokens {
// Returns a *NotFoundError when no AuthTokens ID was found. // Returns a *NotFoundError when no AuthTokens ID was found.
func (atq *AuthTokensQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { func (atq *AuthTokensQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = atq.Limit(1).IDs(ctx); err != nil { if ids, err = atq.Limit(1).IDs(newQueryContext(ctx, TypeAuthTokens, "FirstID")); err != nil {
return return
} }
if len(ids) == 0 { if len(ids) == 0 {
@ -159,7 +160,7 @@ func (atq *AuthTokensQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one AuthTokens entity is found. // Returns a *NotSingularError when more than one AuthTokens entity is found.
// Returns a *NotFoundError when no AuthTokens entities are found. // Returns a *NotFoundError when no AuthTokens entities are found.
func (atq *AuthTokensQuery) Only(ctx context.Context) (*AuthTokens, error) { func (atq *AuthTokensQuery) Only(ctx context.Context) (*AuthTokens, error) {
nodes, err := atq.Limit(2).All(ctx) nodes, err := atq.Limit(2).All(newQueryContext(ctx, TypeAuthTokens, "Only"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -187,7 +188,7 @@ func (atq *AuthTokensQuery) OnlyX(ctx context.Context) *AuthTokens {
// Returns a *NotFoundError when no entities are found. // Returns a *NotFoundError when no entities are found.
func (atq *AuthTokensQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { func (atq *AuthTokensQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = atq.Limit(2).IDs(ctx); err != nil { if ids, err = atq.Limit(2).IDs(newQueryContext(ctx, TypeAuthTokens, "OnlyID")); err != nil {
return return
} }
switch len(ids) { switch len(ids) {
@ -212,10 +213,12 @@ func (atq *AuthTokensQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of AuthTokensSlice. // All executes the query and returns a list of AuthTokensSlice.
func (atq *AuthTokensQuery) All(ctx context.Context) ([]*AuthTokens, error) { func (atq *AuthTokensQuery) All(ctx context.Context) ([]*AuthTokens, error) {
ctx = newQueryContext(ctx, TypeAuthTokens, "All")
if err := atq.prepareQuery(ctx); err != nil { if err := atq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return atq.sqlAll(ctx) qr := querierAll[[]*AuthTokens, *AuthTokensQuery]()
return withInterceptors[[]*AuthTokens](ctx, atq, qr, atq.inters)
} }
// AllX is like All, but panics if an error occurs. // AllX is like All, but panics if an error occurs.
@ -230,6 +233,7 @@ func (atq *AuthTokensQuery) AllX(ctx context.Context) []*AuthTokens {
// IDs executes the query and returns a list of AuthTokens IDs. // IDs executes the query and returns a list of AuthTokens IDs.
func (atq *AuthTokensQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (atq *AuthTokensQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID var ids []uuid.UUID
ctx = newQueryContext(ctx, TypeAuthTokens, "IDs")
if err := atq.Select(authtokens.FieldID).Scan(ctx, &ids); err != nil { if err := atq.Select(authtokens.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
@ -247,10 +251,11 @@ func (atq *AuthTokensQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query. // Count returns the count of the given query.
func (atq *AuthTokensQuery) Count(ctx context.Context) (int, error) { func (atq *AuthTokensQuery) Count(ctx context.Context) (int, error) {
ctx = newQueryContext(ctx, TypeAuthTokens, "Count")
if err := atq.prepareQuery(ctx); err != nil { if err := atq.prepareQuery(ctx); err != nil {
return 0, err return 0, err
} }
return atq.sqlCount(ctx) return withInterceptors[int](ctx, atq, querierCount[*AuthTokensQuery](), atq.inters)
} }
// CountX is like Count, but panics if an error occurs. // CountX is like Count, but panics if an error occurs.
@ -264,10 +269,15 @@ func (atq *AuthTokensQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph. // Exist returns true if the query has elements in the graph.
func (atq *AuthTokensQuery) Exist(ctx context.Context) (bool, error) { func (atq *AuthTokensQuery) Exist(ctx context.Context) (bool, error) {
if err := atq.prepareQuery(ctx); err != nil { ctx = newQueryContext(ctx, TypeAuthTokens, "Exist")
return false, err switch _, err := atq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
} }
return atq.sqlExist(ctx)
} }
// ExistX is like Exist, but panics if an error occurs. // ExistX is like Exist, but panics if an error occurs.
@ -290,6 +300,7 @@ func (atq *AuthTokensQuery) Clone() *AuthTokensQuery {
limit: atq.limit, limit: atq.limit,
offset: atq.offset, offset: atq.offset,
order: append([]OrderFunc{}, atq.order...), order: append([]OrderFunc{}, atq.order...),
inters: append([]Interceptor{}, atq.inters...),
predicates: append([]predicate.AuthTokens{}, atq.predicates...), predicates: append([]predicate.AuthTokens{}, atq.predicates...),
withUser: atq.withUser.Clone(), withUser: atq.withUser.Clone(),
withRoles: atq.withRoles.Clone(), withRoles: atq.withRoles.Clone(),
@ -303,7 +314,7 @@ func (atq *AuthTokensQuery) Clone() *AuthTokensQuery {
// WithUser tells the query-builder to eager-load the nodes that are connected to // WithUser tells the query-builder to eager-load the nodes that are connected to
// the "user" edge. The optional arguments are used to configure the query builder of the edge. // the "user" edge. The optional arguments are used to configure the query builder of the edge.
func (atq *AuthTokensQuery) WithUser(opts ...func(*UserQuery)) *AuthTokensQuery { func (atq *AuthTokensQuery) WithUser(opts ...func(*UserQuery)) *AuthTokensQuery {
query := &UserQuery{config: atq.config} query := (&UserClient{config: atq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -314,7 +325,7 @@ func (atq *AuthTokensQuery) WithUser(opts ...func(*UserQuery)) *AuthTokensQuery
// WithRoles tells the query-builder to eager-load the nodes that are connected to // WithRoles tells the query-builder to eager-load the nodes that are connected to
// the "roles" edge. The optional arguments are used to configure the query builder of the edge. // the "roles" edge. The optional arguments are used to configure the query builder of the edge.
func (atq *AuthTokensQuery) WithRoles(opts ...func(*AuthRolesQuery)) *AuthTokensQuery { func (atq *AuthTokensQuery) WithRoles(opts ...func(*AuthRolesQuery)) *AuthTokensQuery {
query := &AuthRolesQuery{config: atq.config} query := (&AuthRolesClient{config: atq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -337,16 +348,11 @@ func (atq *AuthTokensQuery) WithRoles(opts ...func(*AuthRolesQuery)) *AuthTokens
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (atq *AuthTokensQuery) GroupBy(field string, fields ...string) *AuthTokensGroupBy { func (atq *AuthTokensQuery) GroupBy(field string, fields ...string) *AuthTokensGroupBy {
grbuild := &AuthTokensGroupBy{config: atq.config} atq.fields = append([]string{field}, fields...)
grbuild.fields = append([]string{field}, fields...) grbuild := &AuthTokensGroupBy{build: atq}
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { grbuild.flds = &atq.fields
if err := atq.prepareQuery(ctx); err != nil {
return nil, err
}
return atq.sqlQuery(ctx), nil
}
grbuild.label = authtokens.Label grbuild.label = authtokens.Label
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan grbuild.scan = grbuild.Scan
return grbuild return grbuild
} }
@ -364,10 +370,10 @@ func (atq *AuthTokensQuery) GroupBy(field string, fields ...string) *AuthTokensG
// Scan(ctx, &v) // Scan(ctx, &v)
func (atq *AuthTokensQuery) Select(fields ...string) *AuthTokensSelect { func (atq *AuthTokensQuery) Select(fields ...string) *AuthTokensSelect {
atq.fields = append(atq.fields, fields...) atq.fields = append(atq.fields, fields...)
selbuild := &AuthTokensSelect{AuthTokensQuery: atq} sbuild := &AuthTokensSelect{AuthTokensQuery: atq}
selbuild.label = authtokens.Label sbuild.label = authtokens.Label
selbuild.flds, selbuild.scan = &atq.fields, selbuild.Scan sbuild.flds, sbuild.scan = &atq.fields, sbuild.Scan
return selbuild return sbuild
} }
// Aggregate returns a AuthTokensSelect configured with the given aggregations. // Aggregate returns a AuthTokensSelect configured with the given aggregations.
@ -376,6 +382,16 @@ func (atq *AuthTokensQuery) Aggregate(fns ...AggregateFunc) *AuthTokensSelect {
} }
func (atq *AuthTokensQuery) prepareQuery(ctx context.Context) error { func (atq *AuthTokensQuery) prepareQuery(ctx context.Context) error {
for _, inter := range atq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, atq); err != nil {
return err
}
}
}
for _, f := range atq.fields { for _, f := range atq.fields {
if !authtokens.ValidColumn(f) { if !authtokens.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
@ -507,17 +523,6 @@ func (atq *AuthTokensQuery) sqlCount(ctx context.Context) (int, error) {
return sqlgraph.CountNodes(ctx, atq.driver, _spec) return sqlgraph.CountNodes(ctx, atq.driver, _spec)
} }
func (atq *AuthTokensQuery) sqlExist(ctx context.Context) (bool, error) {
switch _, err := atq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
func (atq *AuthTokensQuery) querySpec() *sqlgraph.QuerySpec { func (atq *AuthTokensQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
@ -600,13 +605,8 @@ func (atq *AuthTokensQuery) sqlQuery(ctx context.Context) *sql.Selector {
// AuthTokensGroupBy is the group-by builder for AuthTokens entities. // AuthTokensGroupBy is the group-by builder for AuthTokens entities.
type AuthTokensGroupBy struct { type AuthTokensGroupBy struct {
config
selector selector
fields []string build *AuthTokensQuery
fns []AggregateFunc
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
} }
// Aggregate adds the given aggregation functions to the group-by query. // Aggregate adds the given aggregation functions to the group-by query.
@ -615,58 +615,46 @@ func (atgb *AuthTokensGroupBy) Aggregate(fns ...AggregateFunc) *AuthTokensGroupB
return atgb return atgb
} }
// Scan applies the group-by query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (atgb *AuthTokensGroupBy) Scan(ctx context.Context, v any) error { func (atgb *AuthTokensGroupBy) Scan(ctx context.Context, v any) error {
query, err := atgb.path(ctx) ctx = newQueryContext(ctx, TypeAuthTokens, "GroupBy")
if err != nil { if err := atgb.build.prepareQuery(ctx); err != nil {
return err return err
} }
atgb.sql = query return scanWithInterceptors[*AuthTokensQuery, *AuthTokensGroupBy](ctx, atgb.build, atgb, atgb.build.inters, v)
return atgb.sqlScan(ctx, v)
} }
func (atgb *AuthTokensGroupBy) sqlScan(ctx context.Context, v any) error { func (atgb *AuthTokensGroupBy) sqlScan(ctx context.Context, root *AuthTokensQuery, v any) error {
for _, f := range atgb.fields { selector := root.sqlQuery(ctx).Select()
if !authtokens.ValidColumn(f) { aggregation := make([]string, 0, len(atgb.fns))
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} for _, fn := range atgb.fns {
} aggregation = append(aggregation, fn(selector))
} }
selector := atgb.sqlQuery() if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*atgb.flds)+len(atgb.fns))
for _, f := range *atgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*atgb.flds...)...)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return err return err
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() query, args := selector.Query()
if err := atgb.driver.Query(ctx, query, args, rows); err != nil { if err := atgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }
defer rows.Close() defer rows.Close()
return sql.ScanSlice(rows, v) return sql.ScanSlice(rows, v)
} }
func (atgb *AuthTokensGroupBy) sqlQuery() *sql.Selector {
selector := atgb.sql.Select()
aggregation := make([]string, 0, len(atgb.fns))
for _, fn := range atgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(atgb.fields)+len(atgb.fns))
for _, f := range atgb.fields {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
return selector.GroupBy(selector.Columns(atgb.fields...)...)
}
// AuthTokensSelect is the builder for selecting fields of AuthTokens entities. // AuthTokensSelect is the builder for selecting fields of AuthTokens entities.
type AuthTokensSelect struct { type AuthTokensSelect struct {
*AuthTokensQuery *AuthTokensQuery
selector selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
@ -677,26 +665,27 @@ func (ats *AuthTokensSelect) Aggregate(fns ...AggregateFunc) *AuthTokensSelect {
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (ats *AuthTokensSelect) Scan(ctx context.Context, v any) error { func (ats *AuthTokensSelect) Scan(ctx context.Context, v any) error {
ctx = newQueryContext(ctx, TypeAuthTokens, "Select")
if err := ats.prepareQuery(ctx); err != nil { if err := ats.prepareQuery(ctx); err != nil {
return err return err
} }
ats.sql = ats.AuthTokensQuery.sqlQuery(ctx) return scanWithInterceptors[*AuthTokensQuery, *AuthTokensSelect](ctx, ats.AuthTokensQuery, ats, ats.inters, v)
return ats.sqlScan(ctx, v)
} }
func (ats *AuthTokensSelect) sqlScan(ctx context.Context, v any) error { func (ats *AuthTokensSelect) sqlScan(ctx context.Context, root *AuthTokensQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(ats.fns)) aggregation := make([]string, 0, len(ats.fns))
for _, fn := range ats.fns { for _, fn := range ats.fns {
aggregation = append(aggregation, fn(ats.sql)) aggregation = append(aggregation, fn(selector))
} }
switch n := len(*ats.selector.flds); { switch n := len(*ats.selector.flds); {
case n == 0 && len(aggregation) > 0: case n == 0 && len(aggregation) > 0:
ats.sql.Select(aggregation...) selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0: case n != 0 && len(aggregation) > 0:
ats.sql.AppendSelect(aggregation...) selector.AppendSelect(aggregation...)
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := ats.sql.Query() query, args := selector.Query()
if err := ats.driver.Query(ctx, query, args, rows); err != nil { if err := ats.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }

View file

@ -114,35 +114,8 @@ func (atu *AuthTokensUpdate) ClearRoles() *AuthTokensUpdate {
// Save executes the query and returns the number of nodes affected by the update operation. // Save executes the query and returns the number of nodes affected by the update operation.
func (atu *AuthTokensUpdate) Save(ctx context.Context) (int, error) { func (atu *AuthTokensUpdate) Save(ctx context.Context) (int, error) {
var (
err error
affected int
)
atu.defaults() atu.defaults()
if len(atu.hooks) == 0 { return withHooks[int, AuthTokensMutation](ctx, atu.sqlSave, atu.mutation, atu.hooks)
affected, err = atu.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AuthTokensMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
atu.mutation = mutation
affected, err = atu.sqlSave(ctx)
mutation.done = true
return affected, err
})
for i := len(atu.hooks) - 1; i >= 0; i-- {
if atu.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = atu.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, atu.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -280,6 +253,7 @@ func (atu *AuthTokensUpdate) sqlSave(ctx context.Context) (n int, err error) {
} }
return 0, err return 0, err
} }
atu.mutation.done = true
return n, nil return n, nil
} }
@ -381,41 +355,8 @@ func (atuo *AuthTokensUpdateOne) Select(field string, fields ...string) *AuthTok
// Save executes the query and returns the updated AuthTokens entity. // Save executes the query and returns the updated AuthTokens entity.
func (atuo *AuthTokensUpdateOne) Save(ctx context.Context) (*AuthTokens, error) { func (atuo *AuthTokensUpdateOne) Save(ctx context.Context) (*AuthTokens, error) {
var (
err error
node *AuthTokens
)
atuo.defaults() atuo.defaults()
if len(atuo.hooks) == 0 { return withHooks[*AuthTokens, AuthTokensMutation](ctx, atuo.sqlSave, atuo.mutation, atuo.hooks)
node, err = atuo.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AuthTokensMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
atuo.mutation = mutation
node, err = atuo.sqlSave(ctx)
mutation.done = true
return node, err
})
for i := len(atuo.hooks) - 1; i >= 0; i-- {
if atuo.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = atuo.hooks[i](mut)
}
v, err := mut.Mutate(ctx, atuo.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*AuthTokens)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from AuthTokensMutation", v)
}
node = nv
}
return node, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -573,5 +514,6 @@ func (atuo *AuthTokensUpdateOne) sqlSave(ctx context.Context) (_node *AuthTokens
} }
return nil, err return nil, err
} }
atuo.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -62,7 +62,7 @@ type Client struct {
// NewClient creates a new client configured with the given options. // NewClient creates a new client configured with the given options.
func NewClient(opts ...Option) *Client { func NewClient(opts ...Option) *Client {
cfg := config{log: log.Println, hooks: &hooks{}} cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
cfg.options(opts...) cfg.options(opts...)
client := &Client{config: cfg} client := &Client{config: cfg}
client.init() client.init()
@ -201,6 +201,55 @@ func (c *Client) Use(hooks ...Hook) {
c.User.Use(hooks...) c.User.Use(hooks...)
} }
// Intercept adds the query interceptors to all the entity clients.
// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
func (c *Client) Intercept(interceptors ...Interceptor) {
c.Attachment.Intercept(interceptors...)
c.AuthRoles.Intercept(interceptors...)
c.AuthTokens.Intercept(interceptors...)
c.Document.Intercept(interceptors...)
c.Group.Intercept(interceptors...)
c.GroupInvitationToken.Intercept(interceptors...)
c.Item.Intercept(interceptors...)
c.ItemField.Intercept(interceptors...)
c.Label.Intercept(interceptors...)
c.Location.Intercept(interceptors...)
c.MaintenanceEntry.Intercept(interceptors...)
c.User.Intercept(interceptors...)
}
// Mutate implements the ent.Mutator interface.
func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
switch m := m.(type) {
case *AttachmentMutation:
return c.Attachment.mutate(ctx, m)
case *AuthRolesMutation:
return c.AuthRoles.mutate(ctx, m)
case *AuthTokensMutation:
return c.AuthTokens.mutate(ctx, m)
case *DocumentMutation:
return c.Document.mutate(ctx, m)
case *GroupMutation:
return c.Group.mutate(ctx, m)
case *GroupInvitationTokenMutation:
return c.GroupInvitationToken.mutate(ctx, m)
case *ItemMutation:
return c.Item.mutate(ctx, m)
case *ItemFieldMutation:
return c.ItemField.mutate(ctx, m)
case *LabelMutation:
return c.Label.mutate(ctx, m)
case *LocationMutation:
return c.Location.mutate(ctx, m)
case *MaintenanceEntryMutation:
return c.MaintenanceEntry.mutate(ctx, m)
case *UserMutation:
return c.User.mutate(ctx, m)
default:
return nil, fmt.Errorf("ent: unknown mutation type %T", m)
}
}
// AttachmentClient is a client for the Attachment schema. // AttachmentClient is a client for the Attachment schema.
type AttachmentClient struct { type AttachmentClient struct {
config config
@ -217,6 +266,12 @@ func (c *AttachmentClient) Use(hooks ...Hook) {
c.hooks.Attachment = append(c.hooks.Attachment, hooks...) c.hooks.Attachment = append(c.hooks.Attachment, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `attachment.Intercept(f(g(h())))`.
func (c *AttachmentClient) Intercept(interceptors ...Interceptor) {
c.inters.Attachment = append(c.inters.Attachment, interceptors...)
}
// Create returns a builder for creating a Attachment entity. // Create returns a builder for creating a Attachment entity.
func (c *AttachmentClient) Create() *AttachmentCreate { func (c *AttachmentClient) Create() *AttachmentCreate {
mutation := newAttachmentMutation(c.config, OpCreate) mutation := newAttachmentMutation(c.config, OpCreate)
@ -269,6 +324,7 @@ func (c *AttachmentClient) DeleteOneID(id uuid.UUID) *AttachmentDeleteOne {
func (c *AttachmentClient) Query() *AttachmentQuery { func (c *AttachmentClient) Query() *AttachmentQuery {
return &AttachmentQuery{ return &AttachmentQuery{
config: c.config, config: c.config,
inters: c.Interceptors(),
} }
} }
@ -288,7 +344,7 @@ func (c *AttachmentClient) GetX(ctx context.Context, id uuid.UUID) *Attachment {
// QueryItem queries the item edge of a Attachment. // QueryItem queries the item edge of a Attachment.
func (c *AttachmentClient) QueryItem(a *Attachment) *ItemQuery { func (c *AttachmentClient) QueryItem(a *Attachment) *ItemQuery {
query := &ItemQuery{config: c.config} query := (&ItemClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := a.ID id := a.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -304,7 +360,7 @@ func (c *AttachmentClient) QueryItem(a *Attachment) *ItemQuery {
// QueryDocument queries the document edge of a Attachment. // QueryDocument queries the document edge of a Attachment.
func (c *AttachmentClient) QueryDocument(a *Attachment) *DocumentQuery { func (c *AttachmentClient) QueryDocument(a *Attachment) *DocumentQuery {
query := &DocumentQuery{config: c.config} query := (&DocumentClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := a.ID id := a.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -323,6 +379,26 @@ func (c *AttachmentClient) Hooks() []Hook {
return c.hooks.Attachment return c.hooks.Attachment
} }
// Interceptors returns the client interceptors.
func (c *AttachmentClient) Interceptors() []Interceptor {
return c.inters.Attachment
}
func (c *AttachmentClient) mutate(ctx context.Context, m *AttachmentMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&AttachmentCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&AttachmentUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&AttachmentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&AttachmentDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown Attachment mutation op: %q", m.Op())
}
}
// AuthRolesClient is a client for the AuthRoles schema. // AuthRolesClient is a client for the AuthRoles schema.
type AuthRolesClient struct { type AuthRolesClient struct {
config config
@ -339,6 +415,12 @@ func (c *AuthRolesClient) Use(hooks ...Hook) {
c.hooks.AuthRoles = append(c.hooks.AuthRoles, hooks...) c.hooks.AuthRoles = append(c.hooks.AuthRoles, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `authroles.Intercept(f(g(h())))`.
func (c *AuthRolesClient) Intercept(interceptors ...Interceptor) {
c.inters.AuthRoles = append(c.inters.AuthRoles, interceptors...)
}
// Create returns a builder for creating a AuthRoles entity. // Create returns a builder for creating a AuthRoles entity.
func (c *AuthRolesClient) Create() *AuthRolesCreate { func (c *AuthRolesClient) Create() *AuthRolesCreate {
mutation := newAuthRolesMutation(c.config, OpCreate) mutation := newAuthRolesMutation(c.config, OpCreate)
@ -391,6 +473,7 @@ func (c *AuthRolesClient) DeleteOneID(id int) *AuthRolesDeleteOne {
func (c *AuthRolesClient) Query() *AuthRolesQuery { func (c *AuthRolesClient) Query() *AuthRolesQuery {
return &AuthRolesQuery{ return &AuthRolesQuery{
config: c.config, config: c.config,
inters: c.Interceptors(),
} }
} }
@ -410,7 +493,7 @@ func (c *AuthRolesClient) GetX(ctx context.Context, id int) *AuthRoles {
// QueryToken queries the token edge of a AuthRoles. // QueryToken queries the token edge of a AuthRoles.
func (c *AuthRolesClient) QueryToken(ar *AuthRoles) *AuthTokensQuery { func (c *AuthRolesClient) QueryToken(ar *AuthRoles) *AuthTokensQuery {
query := &AuthTokensQuery{config: c.config} query := (&AuthTokensClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := ar.ID id := ar.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -429,6 +512,26 @@ func (c *AuthRolesClient) Hooks() []Hook {
return c.hooks.AuthRoles return c.hooks.AuthRoles
} }
// Interceptors returns the client interceptors.
func (c *AuthRolesClient) Interceptors() []Interceptor {
return c.inters.AuthRoles
}
func (c *AuthRolesClient) mutate(ctx context.Context, m *AuthRolesMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&AuthRolesCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&AuthRolesUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&AuthRolesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&AuthRolesDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown AuthRoles mutation op: %q", m.Op())
}
}
// AuthTokensClient is a client for the AuthTokens schema. // AuthTokensClient is a client for the AuthTokens schema.
type AuthTokensClient struct { type AuthTokensClient struct {
config config
@ -445,6 +548,12 @@ func (c *AuthTokensClient) Use(hooks ...Hook) {
c.hooks.AuthTokens = append(c.hooks.AuthTokens, hooks...) c.hooks.AuthTokens = append(c.hooks.AuthTokens, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `authtokens.Intercept(f(g(h())))`.
func (c *AuthTokensClient) Intercept(interceptors ...Interceptor) {
c.inters.AuthTokens = append(c.inters.AuthTokens, interceptors...)
}
// Create returns a builder for creating a AuthTokens entity. // Create returns a builder for creating a AuthTokens entity.
func (c *AuthTokensClient) Create() *AuthTokensCreate { func (c *AuthTokensClient) Create() *AuthTokensCreate {
mutation := newAuthTokensMutation(c.config, OpCreate) mutation := newAuthTokensMutation(c.config, OpCreate)
@ -497,6 +606,7 @@ func (c *AuthTokensClient) DeleteOneID(id uuid.UUID) *AuthTokensDeleteOne {
func (c *AuthTokensClient) Query() *AuthTokensQuery { func (c *AuthTokensClient) Query() *AuthTokensQuery {
return &AuthTokensQuery{ return &AuthTokensQuery{
config: c.config, config: c.config,
inters: c.Interceptors(),
} }
} }
@ -516,7 +626,7 @@ func (c *AuthTokensClient) GetX(ctx context.Context, id uuid.UUID) *AuthTokens {
// QueryUser queries the user edge of a AuthTokens. // QueryUser queries the user edge of a AuthTokens.
func (c *AuthTokensClient) QueryUser(at *AuthTokens) *UserQuery { func (c *AuthTokensClient) QueryUser(at *AuthTokens) *UserQuery {
query := &UserQuery{config: c.config} query := (&UserClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := at.ID id := at.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -532,7 +642,7 @@ func (c *AuthTokensClient) QueryUser(at *AuthTokens) *UserQuery {
// QueryRoles queries the roles edge of a AuthTokens. // QueryRoles queries the roles edge of a AuthTokens.
func (c *AuthTokensClient) QueryRoles(at *AuthTokens) *AuthRolesQuery { func (c *AuthTokensClient) QueryRoles(at *AuthTokens) *AuthRolesQuery {
query := &AuthRolesQuery{config: c.config} query := (&AuthRolesClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := at.ID id := at.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -551,6 +661,26 @@ func (c *AuthTokensClient) Hooks() []Hook {
return c.hooks.AuthTokens return c.hooks.AuthTokens
} }
// Interceptors returns the client interceptors.
func (c *AuthTokensClient) Interceptors() []Interceptor {
return c.inters.AuthTokens
}
func (c *AuthTokensClient) mutate(ctx context.Context, m *AuthTokensMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&AuthTokensCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&AuthTokensUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&AuthTokensUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&AuthTokensDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown AuthTokens mutation op: %q", m.Op())
}
}
// DocumentClient is a client for the Document schema. // DocumentClient is a client for the Document schema.
type DocumentClient struct { type DocumentClient struct {
config config
@ -567,6 +697,12 @@ func (c *DocumentClient) Use(hooks ...Hook) {
c.hooks.Document = append(c.hooks.Document, hooks...) c.hooks.Document = append(c.hooks.Document, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `document.Intercept(f(g(h())))`.
func (c *DocumentClient) Intercept(interceptors ...Interceptor) {
c.inters.Document = append(c.inters.Document, interceptors...)
}
// Create returns a builder for creating a Document entity. // Create returns a builder for creating a Document entity.
func (c *DocumentClient) Create() *DocumentCreate { func (c *DocumentClient) Create() *DocumentCreate {
mutation := newDocumentMutation(c.config, OpCreate) mutation := newDocumentMutation(c.config, OpCreate)
@ -619,6 +755,7 @@ func (c *DocumentClient) DeleteOneID(id uuid.UUID) *DocumentDeleteOne {
func (c *DocumentClient) Query() *DocumentQuery { func (c *DocumentClient) Query() *DocumentQuery {
return &DocumentQuery{ return &DocumentQuery{
config: c.config, config: c.config,
inters: c.Interceptors(),
} }
} }
@ -638,7 +775,7 @@ func (c *DocumentClient) GetX(ctx context.Context, id uuid.UUID) *Document {
// QueryGroup queries the group edge of a Document. // QueryGroup queries the group edge of a Document.
func (c *DocumentClient) QueryGroup(d *Document) *GroupQuery { func (c *DocumentClient) QueryGroup(d *Document) *GroupQuery {
query := &GroupQuery{config: c.config} query := (&GroupClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := d.ID id := d.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -654,7 +791,7 @@ func (c *DocumentClient) QueryGroup(d *Document) *GroupQuery {
// QueryAttachments queries the attachments edge of a Document. // QueryAttachments queries the attachments edge of a Document.
func (c *DocumentClient) QueryAttachments(d *Document) *AttachmentQuery { func (c *DocumentClient) QueryAttachments(d *Document) *AttachmentQuery {
query := &AttachmentQuery{config: c.config} query := (&AttachmentClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := d.ID id := d.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -673,6 +810,26 @@ func (c *DocumentClient) Hooks() []Hook {
return c.hooks.Document return c.hooks.Document
} }
// Interceptors returns the client interceptors.
func (c *DocumentClient) Interceptors() []Interceptor {
return c.inters.Document
}
func (c *DocumentClient) mutate(ctx context.Context, m *DocumentMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&DocumentCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&DocumentUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&DocumentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&DocumentDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown Document mutation op: %q", m.Op())
}
}
// GroupClient is a client for the Group schema. // GroupClient is a client for the Group schema.
type GroupClient struct { type GroupClient struct {
config config
@ -689,6 +846,12 @@ func (c *GroupClient) Use(hooks ...Hook) {
c.hooks.Group = append(c.hooks.Group, hooks...) c.hooks.Group = append(c.hooks.Group, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `group.Intercept(f(g(h())))`.
func (c *GroupClient) Intercept(interceptors ...Interceptor) {
c.inters.Group = append(c.inters.Group, interceptors...)
}
// Create returns a builder for creating a Group entity. // Create returns a builder for creating a Group entity.
func (c *GroupClient) Create() *GroupCreate { func (c *GroupClient) Create() *GroupCreate {
mutation := newGroupMutation(c.config, OpCreate) mutation := newGroupMutation(c.config, OpCreate)
@ -741,6 +904,7 @@ func (c *GroupClient) DeleteOneID(id uuid.UUID) *GroupDeleteOne {
func (c *GroupClient) Query() *GroupQuery { func (c *GroupClient) Query() *GroupQuery {
return &GroupQuery{ return &GroupQuery{
config: c.config, config: c.config,
inters: c.Interceptors(),
} }
} }
@ -760,7 +924,7 @@ func (c *GroupClient) GetX(ctx context.Context, id uuid.UUID) *Group {
// QueryUsers queries the users edge of a Group. // QueryUsers queries the users edge of a Group.
func (c *GroupClient) QueryUsers(gr *Group) *UserQuery { func (c *GroupClient) QueryUsers(gr *Group) *UserQuery {
query := &UserQuery{config: c.config} query := (&UserClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := gr.ID id := gr.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -776,7 +940,7 @@ func (c *GroupClient) QueryUsers(gr *Group) *UserQuery {
// QueryLocations queries the locations edge of a Group. // QueryLocations queries the locations edge of a Group.
func (c *GroupClient) QueryLocations(gr *Group) *LocationQuery { func (c *GroupClient) QueryLocations(gr *Group) *LocationQuery {
query := &LocationQuery{config: c.config} query := (&LocationClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := gr.ID id := gr.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -792,7 +956,7 @@ func (c *GroupClient) QueryLocations(gr *Group) *LocationQuery {
// QueryItems queries the items edge of a Group. // QueryItems queries the items edge of a Group.
func (c *GroupClient) QueryItems(gr *Group) *ItemQuery { func (c *GroupClient) QueryItems(gr *Group) *ItemQuery {
query := &ItemQuery{config: c.config} query := (&ItemClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := gr.ID id := gr.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -808,7 +972,7 @@ func (c *GroupClient) QueryItems(gr *Group) *ItemQuery {
// QueryLabels queries the labels edge of a Group. // QueryLabels queries the labels edge of a Group.
func (c *GroupClient) QueryLabels(gr *Group) *LabelQuery { func (c *GroupClient) QueryLabels(gr *Group) *LabelQuery {
query := &LabelQuery{config: c.config} query := (&LabelClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := gr.ID id := gr.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -824,7 +988,7 @@ func (c *GroupClient) QueryLabels(gr *Group) *LabelQuery {
// QueryDocuments queries the documents edge of a Group. // QueryDocuments queries the documents edge of a Group.
func (c *GroupClient) QueryDocuments(gr *Group) *DocumentQuery { func (c *GroupClient) QueryDocuments(gr *Group) *DocumentQuery {
query := &DocumentQuery{config: c.config} query := (&DocumentClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := gr.ID id := gr.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -840,7 +1004,7 @@ func (c *GroupClient) QueryDocuments(gr *Group) *DocumentQuery {
// QueryInvitationTokens queries the invitation_tokens edge of a Group. // QueryInvitationTokens queries the invitation_tokens edge of a Group.
func (c *GroupClient) QueryInvitationTokens(gr *Group) *GroupInvitationTokenQuery { func (c *GroupClient) QueryInvitationTokens(gr *Group) *GroupInvitationTokenQuery {
query := &GroupInvitationTokenQuery{config: c.config} query := (&GroupInvitationTokenClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := gr.ID id := gr.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -859,6 +1023,26 @@ func (c *GroupClient) Hooks() []Hook {
return c.hooks.Group return c.hooks.Group
} }
// Interceptors returns the client interceptors.
func (c *GroupClient) Interceptors() []Interceptor {
return c.inters.Group
}
func (c *GroupClient) mutate(ctx context.Context, m *GroupMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&GroupCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&GroupUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&GroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&GroupDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown Group mutation op: %q", m.Op())
}
}
// GroupInvitationTokenClient is a client for the GroupInvitationToken schema. // GroupInvitationTokenClient is a client for the GroupInvitationToken schema.
type GroupInvitationTokenClient struct { type GroupInvitationTokenClient struct {
config config
@ -875,6 +1059,12 @@ func (c *GroupInvitationTokenClient) Use(hooks ...Hook) {
c.hooks.GroupInvitationToken = append(c.hooks.GroupInvitationToken, hooks...) c.hooks.GroupInvitationToken = append(c.hooks.GroupInvitationToken, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `groupinvitationtoken.Intercept(f(g(h())))`.
func (c *GroupInvitationTokenClient) Intercept(interceptors ...Interceptor) {
c.inters.GroupInvitationToken = append(c.inters.GroupInvitationToken, interceptors...)
}
// Create returns a builder for creating a GroupInvitationToken entity. // Create returns a builder for creating a GroupInvitationToken entity.
func (c *GroupInvitationTokenClient) Create() *GroupInvitationTokenCreate { func (c *GroupInvitationTokenClient) Create() *GroupInvitationTokenCreate {
mutation := newGroupInvitationTokenMutation(c.config, OpCreate) mutation := newGroupInvitationTokenMutation(c.config, OpCreate)
@ -927,6 +1117,7 @@ func (c *GroupInvitationTokenClient) DeleteOneID(id uuid.UUID) *GroupInvitationT
func (c *GroupInvitationTokenClient) Query() *GroupInvitationTokenQuery { func (c *GroupInvitationTokenClient) Query() *GroupInvitationTokenQuery {
return &GroupInvitationTokenQuery{ return &GroupInvitationTokenQuery{
config: c.config, config: c.config,
inters: c.Interceptors(),
} }
} }
@ -946,7 +1137,7 @@ func (c *GroupInvitationTokenClient) GetX(ctx context.Context, id uuid.UUID) *Gr
// QueryGroup queries the group edge of a GroupInvitationToken. // QueryGroup queries the group edge of a GroupInvitationToken.
func (c *GroupInvitationTokenClient) QueryGroup(git *GroupInvitationToken) *GroupQuery { func (c *GroupInvitationTokenClient) QueryGroup(git *GroupInvitationToken) *GroupQuery {
query := &GroupQuery{config: c.config} query := (&GroupClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := git.ID id := git.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -965,6 +1156,26 @@ func (c *GroupInvitationTokenClient) Hooks() []Hook {
return c.hooks.GroupInvitationToken return c.hooks.GroupInvitationToken
} }
// Interceptors returns the client interceptors.
func (c *GroupInvitationTokenClient) Interceptors() []Interceptor {
return c.inters.GroupInvitationToken
}
func (c *GroupInvitationTokenClient) mutate(ctx context.Context, m *GroupInvitationTokenMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&GroupInvitationTokenCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&GroupInvitationTokenUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&GroupInvitationTokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&GroupInvitationTokenDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown GroupInvitationToken mutation op: %q", m.Op())
}
}
// ItemClient is a client for the Item schema. // ItemClient is a client for the Item schema.
type ItemClient struct { type ItemClient struct {
config config
@ -981,6 +1192,12 @@ func (c *ItemClient) Use(hooks ...Hook) {
c.hooks.Item = append(c.hooks.Item, hooks...) c.hooks.Item = append(c.hooks.Item, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `item.Intercept(f(g(h())))`.
func (c *ItemClient) Intercept(interceptors ...Interceptor) {
c.inters.Item = append(c.inters.Item, interceptors...)
}
// Create returns a builder for creating a Item entity. // Create returns a builder for creating a Item entity.
func (c *ItemClient) Create() *ItemCreate { func (c *ItemClient) Create() *ItemCreate {
mutation := newItemMutation(c.config, OpCreate) mutation := newItemMutation(c.config, OpCreate)
@ -1033,6 +1250,7 @@ func (c *ItemClient) DeleteOneID(id uuid.UUID) *ItemDeleteOne {
func (c *ItemClient) Query() *ItemQuery { func (c *ItemClient) Query() *ItemQuery {
return &ItemQuery{ return &ItemQuery{
config: c.config, config: c.config,
inters: c.Interceptors(),
} }
} }
@ -1052,7 +1270,7 @@ func (c *ItemClient) GetX(ctx context.Context, id uuid.UUID) *Item {
// QueryParent queries the parent edge of a Item. // QueryParent queries the parent edge of a Item.
func (c *ItemClient) QueryParent(i *Item) *ItemQuery { func (c *ItemClient) QueryParent(i *Item) *ItemQuery {
query := &ItemQuery{config: c.config} query := (&ItemClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := i.ID id := i.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -1068,7 +1286,7 @@ func (c *ItemClient) QueryParent(i *Item) *ItemQuery {
// QueryChildren queries the children edge of a Item. // QueryChildren queries the children edge of a Item.
func (c *ItemClient) QueryChildren(i *Item) *ItemQuery { func (c *ItemClient) QueryChildren(i *Item) *ItemQuery {
query := &ItemQuery{config: c.config} query := (&ItemClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := i.ID id := i.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -1084,7 +1302,7 @@ func (c *ItemClient) QueryChildren(i *Item) *ItemQuery {
// QueryGroup queries the group edge of a Item. // QueryGroup queries the group edge of a Item.
func (c *ItemClient) QueryGroup(i *Item) *GroupQuery { func (c *ItemClient) QueryGroup(i *Item) *GroupQuery {
query := &GroupQuery{config: c.config} query := (&GroupClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := i.ID id := i.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -1100,7 +1318,7 @@ func (c *ItemClient) QueryGroup(i *Item) *GroupQuery {
// QueryLabel queries the label edge of a Item. // QueryLabel queries the label edge of a Item.
func (c *ItemClient) QueryLabel(i *Item) *LabelQuery { func (c *ItemClient) QueryLabel(i *Item) *LabelQuery {
query := &LabelQuery{config: c.config} query := (&LabelClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := i.ID id := i.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -1116,7 +1334,7 @@ func (c *ItemClient) QueryLabel(i *Item) *LabelQuery {
// QueryLocation queries the location edge of a Item. // QueryLocation queries the location edge of a Item.
func (c *ItemClient) QueryLocation(i *Item) *LocationQuery { func (c *ItemClient) QueryLocation(i *Item) *LocationQuery {
query := &LocationQuery{config: c.config} query := (&LocationClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := i.ID id := i.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -1132,7 +1350,7 @@ func (c *ItemClient) QueryLocation(i *Item) *LocationQuery {
// QueryFields queries the fields edge of a Item. // QueryFields queries the fields edge of a Item.
func (c *ItemClient) QueryFields(i *Item) *ItemFieldQuery { func (c *ItemClient) QueryFields(i *Item) *ItemFieldQuery {
query := &ItemFieldQuery{config: c.config} query := (&ItemFieldClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := i.ID id := i.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -1148,7 +1366,7 @@ func (c *ItemClient) QueryFields(i *Item) *ItemFieldQuery {
// QueryMaintenanceEntries queries the maintenance_entries edge of a Item. // QueryMaintenanceEntries queries the maintenance_entries edge of a Item.
func (c *ItemClient) QueryMaintenanceEntries(i *Item) *MaintenanceEntryQuery { func (c *ItemClient) QueryMaintenanceEntries(i *Item) *MaintenanceEntryQuery {
query := &MaintenanceEntryQuery{config: c.config} query := (&MaintenanceEntryClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := i.ID id := i.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -1164,7 +1382,7 @@ func (c *ItemClient) QueryMaintenanceEntries(i *Item) *MaintenanceEntryQuery {
// QueryAttachments queries the attachments edge of a Item. // QueryAttachments queries the attachments edge of a Item.
func (c *ItemClient) QueryAttachments(i *Item) *AttachmentQuery { func (c *ItemClient) QueryAttachments(i *Item) *AttachmentQuery {
query := &AttachmentQuery{config: c.config} query := (&AttachmentClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := i.ID id := i.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -1183,6 +1401,26 @@ func (c *ItemClient) Hooks() []Hook {
return c.hooks.Item return c.hooks.Item
} }
// Interceptors returns the client interceptors.
func (c *ItemClient) Interceptors() []Interceptor {
return c.inters.Item
}
func (c *ItemClient) mutate(ctx context.Context, m *ItemMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&ItemCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&ItemUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&ItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&ItemDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown Item mutation op: %q", m.Op())
}
}
// ItemFieldClient is a client for the ItemField schema. // ItemFieldClient is a client for the ItemField schema.
type ItemFieldClient struct { type ItemFieldClient struct {
config config
@ -1199,6 +1437,12 @@ func (c *ItemFieldClient) Use(hooks ...Hook) {
c.hooks.ItemField = append(c.hooks.ItemField, hooks...) c.hooks.ItemField = append(c.hooks.ItemField, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `itemfield.Intercept(f(g(h())))`.
func (c *ItemFieldClient) Intercept(interceptors ...Interceptor) {
c.inters.ItemField = append(c.inters.ItemField, interceptors...)
}
// Create returns a builder for creating a ItemField entity. // Create returns a builder for creating a ItemField entity.
func (c *ItemFieldClient) Create() *ItemFieldCreate { func (c *ItemFieldClient) Create() *ItemFieldCreate {
mutation := newItemFieldMutation(c.config, OpCreate) mutation := newItemFieldMutation(c.config, OpCreate)
@ -1251,6 +1495,7 @@ func (c *ItemFieldClient) DeleteOneID(id uuid.UUID) *ItemFieldDeleteOne {
func (c *ItemFieldClient) Query() *ItemFieldQuery { func (c *ItemFieldClient) Query() *ItemFieldQuery {
return &ItemFieldQuery{ return &ItemFieldQuery{
config: c.config, config: c.config,
inters: c.Interceptors(),
} }
} }
@ -1270,7 +1515,7 @@ func (c *ItemFieldClient) GetX(ctx context.Context, id uuid.UUID) *ItemField {
// QueryItem queries the item edge of a ItemField. // QueryItem queries the item edge of a ItemField.
func (c *ItemFieldClient) QueryItem(_if *ItemField) *ItemQuery { func (c *ItemFieldClient) QueryItem(_if *ItemField) *ItemQuery {
query := &ItemQuery{config: c.config} query := (&ItemClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _if.ID id := _if.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -1289,6 +1534,26 @@ func (c *ItemFieldClient) Hooks() []Hook {
return c.hooks.ItemField return c.hooks.ItemField
} }
// Interceptors returns the client interceptors.
func (c *ItemFieldClient) Interceptors() []Interceptor {
return c.inters.ItemField
}
func (c *ItemFieldClient) mutate(ctx context.Context, m *ItemFieldMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&ItemFieldCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&ItemFieldUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&ItemFieldUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&ItemFieldDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown ItemField mutation op: %q", m.Op())
}
}
// LabelClient is a client for the Label schema. // LabelClient is a client for the Label schema.
type LabelClient struct { type LabelClient struct {
config config
@ -1305,6 +1570,12 @@ func (c *LabelClient) Use(hooks ...Hook) {
c.hooks.Label = append(c.hooks.Label, hooks...) c.hooks.Label = append(c.hooks.Label, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `label.Intercept(f(g(h())))`.
func (c *LabelClient) Intercept(interceptors ...Interceptor) {
c.inters.Label = append(c.inters.Label, interceptors...)
}
// Create returns a builder for creating a Label entity. // Create returns a builder for creating a Label entity.
func (c *LabelClient) Create() *LabelCreate { func (c *LabelClient) Create() *LabelCreate {
mutation := newLabelMutation(c.config, OpCreate) mutation := newLabelMutation(c.config, OpCreate)
@ -1357,6 +1628,7 @@ func (c *LabelClient) DeleteOneID(id uuid.UUID) *LabelDeleteOne {
func (c *LabelClient) Query() *LabelQuery { func (c *LabelClient) Query() *LabelQuery {
return &LabelQuery{ return &LabelQuery{
config: c.config, config: c.config,
inters: c.Interceptors(),
} }
} }
@ -1376,7 +1648,7 @@ func (c *LabelClient) GetX(ctx context.Context, id uuid.UUID) *Label {
// QueryGroup queries the group edge of a Label. // QueryGroup queries the group edge of a Label.
func (c *LabelClient) QueryGroup(l *Label) *GroupQuery { func (c *LabelClient) QueryGroup(l *Label) *GroupQuery {
query := &GroupQuery{config: c.config} query := (&GroupClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := l.ID id := l.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -1392,7 +1664,7 @@ func (c *LabelClient) QueryGroup(l *Label) *GroupQuery {
// QueryItems queries the items edge of a Label. // QueryItems queries the items edge of a Label.
func (c *LabelClient) QueryItems(l *Label) *ItemQuery { func (c *LabelClient) QueryItems(l *Label) *ItemQuery {
query := &ItemQuery{config: c.config} query := (&ItemClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := l.ID id := l.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -1411,6 +1683,26 @@ func (c *LabelClient) Hooks() []Hook {
return c.hooks.Label return c.hooks.Label
} }
// Interceptors returns the client interceptors.
func (c *LabelClient) Interceptors() []Interceptor {
return c.inters.Label
}
func (c *LabelClient) mutate(ctx context.Context, m *LabelMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&LabelCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&LabelUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&LabelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&LabelDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown Label mutation op: %q", m.Op())
}
}
// LocationClient is a client for the Location schema. // LocationClient is a client for the Location schema.
type LocationClient struct { type LocationClient struct {
config config
@ -1427,6 +1719,12 @@ func (c *LocationClient) Use(hooks ...Hook) {
c.hooks.Location = append(c.hooks.Location, hooks...) c.hooks.Location = append(c.hooks.Location, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `location.Intercept(f(g(h())))`.
func (c *LocationClient) Intercept(interceptors ...Interceptor) {
c.inters.Location = append(c.inters.Location, interceptors...)
}
// Create returns a builder for creating a Location entity. // Create returns a builder for creating a Location entity.
func (c *LocationClient) Create() *LocationCreate { func (c *LocationClient) Create() *LocationCreate {
mutation := newLocationMutation(c.config, OpCreate) mutation := newLocationMutation(c.config, OpCreate)
@ -1479,6 +1777,7 @@ func (c *LocationClient) DeleteOneID(id uuid.UUID) *LocationDeleteOne {
func (c *LocationClient) Query() *LocationQuery { func (c *LocationClient) Query() *LocationQuery {
return &LocationQuery{ return &LocationQuery{
config: c.config, config: c.config,
inters: c.Interceptors(),
} }
} }
@ -1498,7 +1797,7 @@ func (c *LocationClient) GetX(ctx context.Context, id uuid.UUID) *Location {
// QueryParent queries the parent edge of a Location. // QueryParent queries the parent edge of a Location.
func (c *LocationClient) QueryParent(l *Location) *LocationQuery { func (c *LocationClient) QueryParent(l *Location) *LocationQuery {
query := &LocationQuery{config: c.config} query := (&LocationClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := l.ID id := l.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -1514,7 +1813,7 @@ func (c *LocationClient) QueryParent(l *Location) *LocationQuery {
// QueryChildren queries the children edge of a Location. // QueryChildren queries the children edge of a Location.
func (c *LocationClient) QueryChildren(l *Location) *LocationQuery { func (c *LocationClient) QueryChildren(l *Location) *LocationQuery {
query := &LocationQuery{config: c.config} query := (&LocationClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := l.ID id := l.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -1530,7 +1829,7 @@ func (c *LocationClient) QueryChildren(l *Location) *LocationQuery {
// QueryGroup queries the group edge of a Location. // QueryGroup queries the group edge of a Location.
func (c *LocationClient) QueryGroup(l *Location) *GroupQuery { func (c *LocationClient) QueryGroup(l *Location) *GroupQuery {
query := &GroupQuery{config: c.config} query := (&GroupClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := l.ID id := l.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -1546,7 +1845,7 @@ func (c *LocationClient) QueryGroup(l *Location) *GroupQuery {
// QueryItems queries the items edge of a Location. // QueryItems queries the items edge of a Location.
func (c *LocationClient) QueryItems(l *Location) *ItemQuery { func (c *LocationClient) QueryItems(l *Location) *ItemQuery {
query := &ItemQuery{config: c.config} query := (&ItemClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := l.ID id := l.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -1565,6 +1864,26 @@ func (c *LocationClient) Hooks() []Hook {
return c.hooks.Location return c.hooks.Location
} }
// Interceptors returns the client interceptors.
func (c *LocationClient) Interceptors() []Interceptor {
return c.inters.Location
}
func (c *LocationClient) mutate(ctx context.Context, m *LocationMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&LocationCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&LocationUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&LocationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&LocationDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown Location mutation op: %q", m.Op())
}
}
// MaintenanceEntryClient is a client for the MaintenanceEntry schema. // MaintenanceEntryClient is a client for the MaintenanceEntry schema.
type MaintenanceEntryClient struct { type MaintenanceEntryClient struct {
config config
@ -1581,6 +1900,12 @@ func (c *MaintenanceEntryClient) Use(hooks ...Hook) {
c.hooks.MaintenanceEntry = append(c.hooks.MaintenanceEntry, hooks...) c.hooks.MaintenanceEntry = append(c.hooks.MaintenanceEntry, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `maintenanceentry.Intercept(f(g(h())))`.
func (c *MaintenanceEntryClient) Intercept(interceptors ...Interceptor) {
c.inters.MaintenanceEntry = append(c.inters.MaintenanceEntry, interceptors...)
}
// Create returns a builder for creating a MaintenanceEntry entity. // Create returns a builder for creating a MaintenanceEntry entity.
func (c *MaintenanceEntryClient) Create() *MaintenanceEntryCreate { func (c *MaintenanceEntryClient) Create() *MaintenanceEntryCreate {
mutation := newMaintenanceEntryMutation(c.config, OpCreate) mutation := newMaintenanceEntryMutation(c.config, OpCreate)
@ -1633,6 +1958,7 @@ func (c *MaintenanceEntryClient) DeleteOneID(id uuid.UUID) *MaintenanceEntryDele
func (c *MaintenanceEntryClient) Query() *MaintenanceEntryQuery { func (c *MaintenanceEntryClient) Query() *MaintenanceEntryQuery {
return &MaintenanceEntryQuery{ return &MaintenanceEntryQuery{
config: c.config, config: c.config,
inters: c.Interceptors(),
} }
} }
@ -1652,7 +1978,7 @@ func (c *MaintenanceEntryClient) GetX(ctx context.Context, id uuid.UUID) *Mainte
// QueryItem queries the item edge of a MaintenanceEntry. // QueryItem queries the item edge of a MaintenanceEntry.
func (c *MaintenanceEntryClient) QueryItem(me *MaintenanceEntry) *ItemQuery { func (c *MaintenanceEntryClient) QueryItem(me *MaintenanceEntry) *ItemQuery {
query := &ItemQuery{config: c.config} query := (&ItemClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := me.ID id := me.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -1671,6 +1997,26 @@ func (c *MaintenanceEntryClient) Hooks() []Hook {
return c.hooks.MaintenanceEntry return c.hooks.MaintenanceEntry
} }
// Interceptors returns the client interceptors.
func (c *MaintenanceEntryClient) Interceptors() []Interceptor {
return c.inters.MaintenanceEntry
}
func (c *MaintenanceEntryClient) mutate(ctx context.Context, m *MaintenanceEntryMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&MaintenanceEntryCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&MaintenanceEntryUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&MaintenanceEntryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&MaintenanceEntryDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown MaintenanceEntry mutation op: %q", m.Op())
}
}
// UserClient is a client for the User schema. // UserClient is a client for the User schema.
type UserClient struct { type UserClient struct {
config config
@ -1687,6 +2033,12 @@ func (c *UserClient) Use(hooks ...Hook) {
c.hooks.User = append(c.hooks.User, hooks...) c.hooks.User = append(c.hooks.User, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `user.Intercept(f(g(h())))`.
func (c *UserClient) Intercept(interceptors ...Interceptor) {
c.inters.User = append(c.inters.User, interceptors...)
}
// Create returns a builder for creating a User entity. // Create returns a builder for creating a User entity.
func (c *UserClient) Create() *UserCreate { func (c *UserClient) Create() *UserCreate {
mutation := newUserMutation(c.config, OpCreate) mutation := newUserMutation(c.config, OpCreate)
@ -1739,6 +2091,7 @@ func (c *UserClient) DeleteOneID(id uuid.UUID) *UserDeleteOne {
func (c *UserClient) Query() *UserQuery { func (c *UserClient) Query() *UserQuery {
return &UserQuery{ return &UserQuery{
config: c.config, config: c.config,
inters: c.Interceptors(),
} }
} }
@ -1758,7 +2111,7 @@ func (c *UserClient) GetX(ctx context.Context, id uuid.UUID) *User {
// QueryGroup queries the group edge of a User. // QueryGroup queries the group edge of a User.
func (c *UserClient) QueryGroup(u *User) *GroupQuery { func (c *UserClient) QueryGroup(u *User) *GroupQuery {
query := &GroupQuery{config: c.config} query := (&GroupClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := u.ID id := u.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -1774,7 +2127,7 @@ func (c *UserClient) QueryGroup(u *User) *GroupQuery {
// QueryAuthTokens queries the auth_tokens edge of a User. // QueryAuthTokens queries the auth_tokens edge of a User.
func (c *UserClient) QueryAuthTokens(u *User) *AuthTokensQuery { func (c *UserClient) QueryAuthTokens(u *User) *AuthTokensQuery {
query := &AuthTokensQuery{config: c.config} query := (&AuthTokensClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := u.ID id := u.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
@ -1792,3 +2145,23 @@ func (c *UserClient) QueryAuthTokens(u *User) *AuthTokensQuery {
func (c *UserClient) Hooks() []Hook { func (c *UserClient) Hooks() []Hook {
return c.hooks.User return c.hooks.User
} }
// Interceptors returns the client interceptors.
func (c *UserClient) Interceptors() []Interceptor {
return c.inters.User
}
func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&UserCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&UserUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&UserDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown User mutation op: %q", m.Op())
}
}

View file

@ -20,23 +20,41 @@ type config struct {
log func(...any) log func(...any)
// hooks to execute on mutations. // hooks to execute on mutations.
hooks *hooks hooks *hooks
// interceptors to execute on queries.
inters *inters
} }
// hooks per client, for fast access. // hooks and interceptors per client, for fast access.
type hooks struct { type (
Attachment []ent.Hook hooks struct {
AuthRoles []ent.Hook Attachment []ent.Hook
AuthTokens []ent.Hook AuthRoles []ent.Hook
Document []ent.Hook AuthTokens []ent.Hook
Group []ent.Hook Document []ent.Hook
GroupInvitationToken []ent.Hook Group []ent.Hook
Item []ent.Hook GroupInvitationToken []ent.Hook
ItemField []ent.Hook Item []ent.Hook
Label []ent.Hook ItemField []ent.Hook
Location []ent.Hook Label []ent.Hook
MaintenanceEntry []ent.Hook Location []ent.Hook
User []ent.Hook MaintenanceEntry []ent.Hook
} User []ent.Hook
}
inters struct {
Attachment []ent.Interceptor
AuthRoles []ent.Interceptor
AuthTokens []ent.Interceptor
Document []ent.Interceptor
Group []ent.Interceptor
GroupInvitationToken []ent.Interceptor
Item []ent.Interceptor
ItemField []ent.Interceptor
Label []ent.Interceptor
Location []ent.Interceptor
MaintenanceEntry []ent.Interceptor
User []ent.Interceptor
}
)
// Options applies the options on the config object. // Options applies the options on the config object.
func (c *config) options(opts ...Option) { func (c *config) options(opts ...Option) {

View file

@ -13,427 +13,277 @@ import (
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.
func ID(id uuid.UUID) predicate.Document { func ID(id uuid.UUID) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDEQ applies the EQ predicate on the ID field. // IDEQ applies the EQ predicate on the ID field.
func IDEQ(id uuid.UUID) predicate.Document { func IDEQ(id uuid.UUID) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDNEQ applies the NEQ predicate on the ID field. // IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id uuid.UUID) predicate.Document { func IDNEQ(id uuid.UUID) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldNEQ(FieldID, id))
s.Where(sql.NEQ(s.C(FieldID), id))
})
} }
// IDIn applies the In predicate on the ID field. // IDIn applies the In predicate on the ID field.
func IDIn(ids ...uuid.UUID) predicate.Document { func IDIn(ids ...uuid.UUID) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.In(s.C(FieldID), v...))
})
} }
// IDNotIn applies the NotIn predicate on the ID field. // IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...uuid.UUID) predicate.Document { func IDNotIn(ids ...uuid.UUID) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldNotIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.NotIn(s.C(FieldID), v...))
})
} }
// IDGT applies the GT predicate on the ID field. // IDGT applies the GT predicate on the ID field.
func IDGT(id uuid.UUID) predicate.Document { func IDGT(id uuid.UUID) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldGT(FieldID, id))
s.Where(sql.GT(s.C(FieldID), id))
})
} }
// IDGTE applies the GTE predicate on the ID field. // IDGTE applies the GTE predicate on the ID field.
func IDGTE(id uuid.UUID) predicate.Document { func IDGTE(id uuid.UUID) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldGTE(FieldID, id))
s.Where(sql.GTE(s.C(FieldID), id))
})
} }
// IDLT applies the LT predicate on the ID field. // IDLT applies the LT predicate on the ID field.
func IDLT(id uuid.UUID) predicate.Document { func IDLT(id uuid.UUID) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldLT(FieldID, id))
s.Where(sql.LT(s.C(FieldID), id))
})
} }
// IDLTE applies the LTE predicate on the ID field. // IDLTE applies the LTE predicate on the ID field.
func IDLTE(id uuid.UUID) predicate.Document { func IDLTE(id uuid.UUID) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldLTE(FieldID, id))
s.Where(sql.LTE(s.C(FieldID), id))
})
} }
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. // CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.Document { func CreatedAt(v time.Time) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. // UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.Document { func UpdatedAt(v time.Time) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// Title applies equality check predicate on the "title" field. It's identical to TitleEQ. // Title applies equality check predicate on the "title" field. It's identical to TitleEQ.
func Title(v string) predicate.Document { func Title(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldEQ(FieldTitle, v))
s.Where(sql.EQ(s.C(FieldTitle), v))
})
} }
// Path applies equality check predicate on the "path" field. It's identical to PathEQ. // Path applies equality check predicate on the "path" field. It's identical to PathEQ.
func Path(v string) predicate.Document { func Path(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldEQ(FieldPath, v))
s.Where(sql.EQ(s.C(FieldPath), v))
})
} }
// CreatedAtEQ applies the EQ predicate on the "created_at" field. // CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.Document { func CreatedAtEQ(v time.Time) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. // CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.Document { func CreatedAtNEQ(v time.Time) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldNEQ(FieldCreatedAt, v))
s.Where(sql.NEQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtIn applies the In predicate on the "created_at" field. // CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.Document { func CreatedAtIn(vs ...time.Time) predicate.Document {
v := make([]any, len(vs)) return predicate.Document(sql.FieldIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Document(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. // CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.Document { func CreatedAtNotIn(vs ...time.Time) predicate.Document {
v := make([]any, len(vs)) return predicate.Document(sql.FieldNotIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Document(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtGT applies the GT predicate on the "created_at" field. // CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.Document { func CreatedAtGT(v time.Time) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldGT(FieldCreatedAt, v))
s.Where(sql.GT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtGTE applies the GTE predicate on the "created_at" field. // CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.Document { func CreatedAtGTE(v time.Time) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldGTE(FieldCreatedAt, v))
s.Where(sql.GTE(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLT applies the LT predicate on the "created_at" field. // CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.Document { func CreatedAtLT(v time.Time) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldLT(FieldCreatedAt, v))
s.Where(sql.LT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLTE applies the LTE predicate on the "created_at" field. // CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.Document { func CreatedAtLTE(v time.Time) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldLTE(FieldCreatedAt, v))
s.Where(sql.LTE(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. // UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.Document { func UpdatedAtEQ(v time.Time) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. // UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.Document { func UpdatedAtNEQ(v time.Time) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldNEQ(FieldUpdatedAt, v))
s.Where(sql.NEQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtIn applies the In predicate on the "updated_at" field. // UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.Document { func UpdatedAtIn(vs ...time.Time) predicate.Document {
v := make([]any, len(vs)) return predicate.Document(sql.FieldIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Document(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. // UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.Document { func UpdatedAtNotIn(vs ...time.Time) predicate.Document {
v := make([]any, len(vs)) return predicate.Document(sql.FieldNotIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Document(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtGT applies the GT predicate on the "updated_at" field. // UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.Document { func UpdatedAtGT(v time.Time) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldGT(FieldUpdatedAt, v))
s.Where(sql.GT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. // UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.Document { func UpdatedAtGTE(v time.Time) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldGTE(FieldUpdatedAt, v))
s.Where(sql.GTE(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLT applies the LT predicate on the "updated_at" field. // UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.Document { func UpdatedAtLT(v time.Time) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldLT(FieldUpdatedAt, v))
s.Where(sql.LT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. // UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.Document { func UpdatedAtLTE(v time.Time) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldLTE(FieldUpdatedAt, v))
s.Where(sql.LTE(s.C(FieldUpdatedAt), v))
})
} }
// TitleEQ applies the EQ predicate on the "title" field. // TitleEQ applies the EQ predicate on the "title" field.
func TitleEQ(v string) predicate.Document { func TitleEQ(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldEQ(FieldTitle, v))
s.Where(sql.EQ(s.C(FieldTitle), v))
})
} }
// TitleNEQ applies the NEQ predicate on the "title" field. // TitleNEQ applies the NEQ predicate on the "title" field.
func TitleNEQ(v string) predicate.Document { func TitleNEQ(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldNEQ(FieldTitle, v))
s.Where(sql.NEQ(s.C(FieldTitle), v))
})
} }
// TitleIn applies the In predicate on the "title" field. // TitleIn applies the In predicate on the "title" field.
func TitleIn(vs ...string) predicate.Document { func TitleIn(vs ...string) predicate.Document {
v := make([]any, len(vs)) return predicate.Document(sql.FieldIn(FieldTitle, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Document(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldTitle), v...))
})
} }
// TitleNotIn applies the NotIn predicate on the "title" field. // TitleNotIn applies the NotIn predicate on the "title" field.
func TitleNotIn(vs ...string) predicate.Document { func TitleNotIn(vs ...string) predicate.Document {
v := make([]any, len(vs)) return predicate.Document(sql.FieldNotIn(FieldTitle, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Document(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldTitle), v...))
})
} }
// TitleGT applies the GT predicate on the "title" field. // TitleGT applies the GT predicate on the "title" field.
func TitleGT(v string) predicate.Document { func TitleGT(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldGT(FieldTitle, v))
s.Where(sql.GT(s.C(FieldTitle), v))
})
} }
// TitleGTE applies the GTE predicate on the "title" field. // TitleGTE applies the GTE predicate on the "title" field.
func TitleGTE(v string) predicate.Document { func TitleGTE(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldGTE(FieldTitle, v))
s.Where(sql.GTE(s.C(FieldTitle), v))
})
} }
// TitleLT applies the LT predicate on the "title" field. // TitleLT applies the LT predicate on the "title" field.
func TitleLT(v string) predicate.Document { func TitleLT(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldLT(FieldTitle, v))
s.Where(sql.LT(s.C(FieldTitle), v))
})
} }
// TitleLTE applies the LTE predicate on the "title" field. // TitleLTE applies the LTE predicate on the "title" field.
func TitleLTE(v string) predicate.Document { func TitleLTE(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldLTE(FieldTitle, v))
s.Where(sql.LTE(s.C(FieldTitle), v))
})
} }
// TitleContains applies the Contains predicate on the "title" field. // TitleContains applies the Contains predicate on the "title" field.
func TitleContains(v string) predicate.Document { func TitleContains(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldContains(FieldTitle, v))
s.Where(sql.Contains(s.C(FieldTitle), v))
})
} }
// TitleHasPrefix applies the HasPrefix predicate on the "title" field. // TitleHasPrefix applies the HasPrefix predicate on the "title" field.
func TitleHasPrefix(v string) predicate.Document { func TitleHasPrefix(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldHasPrefix(FieldTitle, v))
s.Where(sql.HasPrefix(s.C(FieldTitle), v))
})
} }
// TitleHasSuffix applies the HasSuffix predicate on the "title" field. // TitleHasSuffix applies the HasSuffix predicate on the "title" field.
func TitleHasSuffix(v string) predicate.Document { func TitleHasSuffix(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldHasSuffix(FieldTitle, v))
s.Where(sql.HasSuffix(s.C(FieldTitle), v))
})
} }
// TitleEqualFold applies the EqualFold predicate on the "title" field. // TitleEqualFold applies the EqualFold predicate on the "title" field.
func TitleEqualFold(v string) predicate.Document { func TitleEqualFold(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldEqualFold(FieldTitle, v))
s.Where(sql.EqualFold(s.C(FieldTitle), v))
})
} }
// TitleContainsFold applies the ContainsFold predicate on the "title" field. // TitleContainsFold applies the ContainsFold predicate on the "title" field.
func TitleContainsFold(v string) predicate.Document { func TitleContainsFold(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldContainsFold(FieldTitle, v))
s.Where(sql.ContainsFold(s.C(FieldTitle), v))
})
} }
// PathEQ applies the EQ predicate on the "path" field. // PathEQ applies the EQ predicate on the "path" field.
func PathEQ(v string) predicate.Document { func PathEQ(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldEQ(FieldPath, v))
s.Where(sql.EQ(s.C(FieldPath), v))
})
} }
// PathNEQ applies the NEQ predicate on the "path" field. // PathNEQ applies the NEQ predicate on the "path" field.
func PathNEQ(v string) predicate.Document { func PathNEQ(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldNEQ(FieldPath, v))
s.Where(sql.NEQ(s.C(FieldPath), v))
})
} }
// PathIn applies the In predicate on the "path" field. // PathIn applies the In predicate on the "path" field.
func PathIn(vs ...string) predicate.Document { func PathIn(vs ...string) predicate.Document {
v := make([]any, len(vs)) return predicate.Document(sql.FieldIn(FieldPath, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Document(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldPath), v...))
})
} }
// PathNotIn applies the NotIn predicate on the "path" field. // PathNotIn applies the NotIn predicate on the "path" field.
func PathNotIn(vs ...string) predicate.Document { func PathNotIn(vs ...string) predicate.Document {
v := make([]any, len(vs)) return predicate.Document(sql.FieldNotIn(FieldPath, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Document(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldPath), v...))
})
} }
// PathGT applies the GT predicate on the "path" field. // PathGT applies the GT predicate on the "path" field.
func PathGT(v string) predicate.Document { func PathGT(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldGT(FieldPath, v))
s.Where(sql.GT(s.C(FieldPath), v))
})
} }
// PathGTE applies the GTE predicate on the "path" field. // PathGTE applies the GTE predicate on the "path" field.
func PathGTE(v string) predicate.Document { func PathGTE(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldGTE(FieldPath, v))
s.Where(sql.GTE(s.C(FieldPath), v))
})
} }
// PathLT applies the LT predicate on the "path" field. // PathLT applies the LT predicate on the "path" field.
func PathLT(v string) predicate.Document { func PathLT(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldLT(FieldPath, v))
s.Where(sql.LT(s.C(FieldPath), v))
})
} }
// PathLTE applies the LTE predicate on the "path" field. // PathLTE applies the LTE predicate on the "path" field.
func PathLTE(v string) predicate.Document { func PathLTE(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldLTE(FieldPath, v))
s.Where(sql.LTE(s.C(FieldPath), v))
})
} }
// PathContains applies the Contains predicate on the "path" field. // PathContains applies the Contains predicate on the "path" field.
func PathContains(v string) predicate.Document { func PathContains(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldContains(FieldPath, v))
s.Where(sql.Contains(s.C(FieldPath), v))
})
} }
// PathHasPrefix applies the HasPrefix predicate on the "path" field. // PathHasPrefix applies the HasPrefix predicate on the "path" field.
func PathHasPrefix(v string) predicate.Document { func PathHasPrefix(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldHasPrefix(FieldPath, v))
s.Where(sql.HasPrefix(s.C(FieldPath), v))
})
} }
// PathHasSuffix applies the HasSuffix predicate on the "path" field. // PathHasSuffix applies the HasSuffix predicate on the "path" field.
func PathHasSuffix(v string) predicate.Document { func PathHasSuffix(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldHasSuffix(FieldPath, v))
s.Where(sql.HasSuffix(s.C(FieldPath), v))
})
} }
// PathEqualFold applies the EqualFold predicate on the "path" field. // PathEqualFold applies the EqualFold predicate on the "path" field.
func PathEqualFold(v string) predicate.Document { func PathEqualFold(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldEqualFold(FieldPath, v))
s.Where(sql.EqualFold(s.C(FieldPath), v))
})
} }
// PathContainsFold applies the ContainsFold predicate on the "path" field. // PathContainsFold applies the ContainsFold predicate on the "path" field.
func PathContainsFold(v string) predicate.Document { func PathContainsFold(v string) predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(sql.FieldContainsFold(FieldPath, v))
s.Where(sql.ContainsFold(s.C(FieldPath), v))
})
} }
// HasGroup applies the HasEdge predicate on the "group" edge. // HasGroup applies the HasEdge predicate on the "group" edge.
@ -441,7 +291,6 @@ func HasGroup() predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(GroupTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn), sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)
@ -469,7 +318,6 @@ func HasAttachments() predicate.Document {
return predicate.Document(func(s *sql.Selector) { return predicate.Document(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(AttachmentsTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, AttachmentsTable, AttachmentsColumn), sqlgraph.Edge(sqlgraph.O2M, false, AttachmentsTable, AttachmentsColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)

View file

@ -110,50 +110,8 @@ func (dc *DocumentCreate) Mutation() *DocumentMutation {
// Save creates the Document in the database. // Save creates the Document in the database.
func (dc *DocumentCreate) Save(ctx context.Context) (*Document, error) { func (dc *DocumentCreate) Save(ctx context.Context) (*Document, error) {
var (
err error
node *Document
)
dc.defaults() dc.defaults()
if len(dc.hooks) == 0 { return withHooks[*Document, DocumentMutation](ctx, dc.sqlSave, dc.mutation, dc.hooks)
if err = dc.check(); err != nil {
return nil, err
}
node, err = dc.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*DocumentMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = dc.check(); err != nil {
return nil, err
}
dc.mutation = mutation
if node, err = dc.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(dc.hooks) - 1; i >= 0; i-- {
if dc.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = dc.hooks[i](mut)
}
v, err := mut.Mutate(ctx, dc.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Document)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from DocumentMutation", v)
}
node = nv
}
return node, err
} }
// SaveX calls Save and panics if Save returns an error. // SaveX calls Save and panics if Save returns an error.
@ -225,6 +183,9 @@ func (dc *DocumentCreate) check() error {
} }
func (dc *DocumentCreate) sqlSave(ctx context.Context) (*Document, error) { func (dc *DocumentCreate) sqlSave(ctx context.Context) (*Document, error) {
if err := dc.check(); err != nil {
return nil, err
}
_node, _spec := dc.createSpec() _node, _spec := dc.createSpec()
if err := sqlgraph.CreateNode(ctx, dc.driver, _spec); err != nil { if err := sqlgraph.CreateNode(ctx, dc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) { if sqlgraph.IsConstraintError(err) {
@ -239,6 +200,8 @@ func (dc *DocumentCreate) sqlSave(ctx context.Context) (*Document, error) {
return nil, err return nil, err
} }
} }
dc.mutation.id = &_node.ID
dc.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -4,7 +4,6 @@ package ent
import ( import (
"context" "context"
"fmt"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
@ -28,34 +27,7 @@ func (dd *DocumentDelete) Where(ps ...predicate.Document) *DocumentDelete {
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (dd *DocumentDelete) Exec(ctx context.Context) (int, error) { func (dd *DocumentDelete) Exec(ctx context.Context) (int, error) {
var ( return withHooks[int, DocumentMutation](ctx, dd.sqlExec, dd.mutation, dd.hooks)
err error
affected int
)
if len(dd.hooks) == 0 {
affected, err = dd.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*DocumentMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
dd.mutation = mutation
affected, err = dd.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(dd.hooks) - 1; i >= 0; i-- {
if dd.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = dd.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, dd.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
@ -88,6 +60,7 @@ func (dd *DocumentDelete) sqlExec(ctx context.Context) (int, error) {
if err != nil && sqlgraph.IsConstraintError(err) { if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
dd.mutation.done = true
return affected, err return affected, err
} }

View file

@ -26,6 +26,7 @@ type DocumentQuery struct {
unique *bool unique *bool
order []OrderFunc order []OrderFunc
fields []string fields []string
inters []Interceptor
predicates []predicate.Document predicates []predicate.Document
withGroup *GroupQuery withGroup *GroupQuery
withAttachments *AttachmentQuery withAttachments *AttachmentQuery
@ -41,13 +42,13 @@ func (dq *DocumentQuery) Where(ps ...predicate.Document) *DocumentQuery {
return dq return dq
} }
// Limit adds a limit step to the query. // Limit the number of records to be returned by this query.
func (dq *DocumentQuery) Limit(limit int) *DocumentQuery { func (dq *DocumentQuery) Limit(limit int) *DocumentQuery {
dq.limit = &limit dq.limit = &limit
return dq return dq
} }
// Offset adds an offset step to the query. // Offset to start from.
func (dq *DocumentQuery) Offset(offset int) *DocumentQuery { func (dq *DocumentQuery) Offset(offset int) *DocumentQuery {
dq.offset = &offset dq.offset = &offset
return dq return dq
@ -60,7 +61,7 @@ func (dq *DocumentQuery) Unique(unique bool) *DocumentQuery {
return dq return dq
} }
// Order adds an order step to the query. // Order specifies how the records should be ordered.
func (dq *DocumentQuery) Order(o ...OrderFunc) *DocumentQuery { func (dq *DocumentQuery) Order(o ...OrderFunc) *DocumentQuery {
dq.order = append(dq.order, o...) dq.order = append(dq.order, o...)
return dq return dq
@ -68,7 +69,7 @@ func (dq *DocumentQuery) Order(o ...OrderFunc) *DocumentQuery {
// QueryGroup chains the current query on the "group" edge. // QueryGroup chains the current query on the "group" edge.
func (dq *DocumentQuery) QueryGroup() *GroupQuery { func (dq *DocumentQuery) QueryGroup() *GroupQuery {
query := &GroupQuery{config: dq.config} query := (&GroupClient{config: dq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := dq.prepareQuery(ctx); err != nil { if err := dq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -90,7 +91,7 @@ func (dq *DocumentQuery) QueryGroup() *GroupQuery {
// QueryAttachments chains the current query on the "attachments" edge. // QueryAttachments chains the current query on the "attachments" edge.
func (dq *DocumentQuery) QueryAttachments() *AttachmentQuery { func (dq *DocumentQuery) QueryAttachments() *AttachmentQuery {
query := &AttachmentQuery{config: dq.config} query := (&AttachmentClient{config: dq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := dq.prepareQuery(ctx); err != nil { if err := dq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -113,7 +114,7 @@ func (dq *DocumentQuery) QueryAttachments() *AttachmentQuery {
// First returns the first Document entity from the query. // First returns the first Document entity from the query.
// Returns a *NotFoundError when no Document was found. // Returns a *NotFoundError when no Document was found.
func (dq *DocumentQuery) First(ctx context.Context) (*Document, error) { func (dq *DocumentQuery) First(ctx context.Context) (*Document, error) {
nodes, err := dq.Limit(1).All(ctx) nodes, err := dq.Limit(1).All(newQueryContext(ctx, TypeDocument, "First"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -136,7 +137,7 @@ func (dq *DocumentQuery) FirstX(ctx context.Context) *Document {
// Returns a *NotFoundError when no Document ID was found. // Returns a *NotFoundError when no Document ID was found.
func (dq *DocumentQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { func (dq *DocumentQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = dq.Limit(1).IDs(ctx); err != nil { if ids, err = dq.Limit(1).IDs(newQueryContext(ctx, TypeDocument, "FirstID")); err != nil {
return return
} }
if len(ids) == 0 { if len(ids) == 0 {
@ -159,7 +160,7 @@ func (dq *DocumentQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one Document entity is found. // Returns a *NotSingularError when more than one Document entity is found.
// Returns a *NotFoundError when no Document entities are found. // Returns a *NotFoundError when no Document entities are found.
func (dq *DocumentQuery) Only(ctx context.Context) (*Document, error) { func (dq *DocumentQuery) Only(ctx context.Context) (*Document, error) {
nodes, err := dq.Limit(2).All(ctx) nodes, err := dq.Limit(2).All(newQueryContext(ctx, TypeDocument, "Only"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -187,7 +188,7 @@ func (dq *DocumentQuery) OnlyX(ctx context.Context) *Document {
// Returns a *NotFoundError when no entities are found. // Returns a *NotFoundError when no entities are found.
func (dq *DocumentQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { func (dq *DocumentQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = dq.Limit(2).IDs(ctx); err != nil { if ids, err = dq.Limit(2).IDs(newQueryContext(ctx, TypeDocument, "OnlyID")); err != nil {
return return
} }
switch len(ids) { switch len(ids) {
@ -212,10 +213,12 @@ func (dq *DocumentQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of Documents. // All executes the query and returns a list of Documents.
func (dq *DocumentQuery) All(ctx context.Context) ([]*Document, error) { func (dq *DocumentQuery) All(ctx context.Context) ([]*Document, error) {
ctx = newQueryContext(ctx, TypeDocument, "All")
if err := dq.prepareQuery(ctx); err != nil { if err := dq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return dq.sqlAll(ctx) qr := querierAll[[]*Document, *DocumentQuery]()
return withInterceptors[[]*Document](ctx, dq, qr, dq.inters)
} }
// AllX is like All, but panics if an error occurs. // AllX is like All, but panics if an error occurs.
@ -230,6 +233,7 @@ func (dq *DocumentQuery) AllX(ctx context.Context) []*Document {
// IDs executes the query and returns a list of Document IDs. // IDs executes the query and returns a list of Document IDs.
func (dq *DocumentQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (dq *DocumentQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID var ids []uuid.UUID
ctx = newQueryContext(ctx, TypeDocument, "IDs")
if err := dq.Select(document.FieldID).Scan(ctx, &ids); err != nil { if err := dq.Select(document.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
@ -247,10 +251,11 @@ func (dq *DocumentQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query. // Count returns the count of the given query.
func (dq *DocumentQuery) Count(ctx context.Context) (int, error) { func (dq *DocumentQuery) Count(ctx context.Context) (int, error) {
ctx = newQueryContext(ctx, TypeDocument, "Count")
if err := dq.prepareQuery(ctx); err != nil { if err := dq.prepareQuery(ctx); err != nil {
return 0, err return 0, err
} }
return dq.sqlCount(ctx) return withInterceptors[int](ctx, dq, querierCount[*DocumentQuery](), dq.inters)
} }
// CountX is like Count, but panics if an error occurs. // CountX is like Count, but panics if an error occurs.
@ -264,10 +269,15 @@ func (dq *DocumentQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph. // Exist returns true if the query has elements in the graph.
func (dq *DocumentQuery) Exist(ctx context.Context) (bool, error) { func (dq *DocumentQuery) Exist(ctx context.Context) (bool, error) {
if err := dq.prepareQuery(ctx); err != nil { ctx = newQueryContext(ctx, TypeDocument, "Exist")
return false, err switch _, err := dq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
} }
return dq.sqlExist(ctx)
} }
// ExistX is like Exist, but panics if an error occurs. // ExistX is like Exist, but panics if an error occurs.
@ -290,6 +300,7 @@ func (dq *DocumentQuery) Clone() *DocumentQuery {
limit: dq.limit, limit: dq.limit,
offset: dq.offset, offset: dq.offset,
order: append([]OrderFunc{}, dq.order...), order: append([]OrderFunc{}, dq.order...),
inters: append([]Interceptor{}, dq.inters...),
predicates: append([]predicate.Document{}, dq.predicates...), predicates: append([]predicate.Document{}, dq.predicates...),
withGroup: dq.withGroup.Clone(), withGroup: dq.withGroup.Clone(),
withAttachments: dq.withAttachments.Clone(), withAttachments: dq.withAttachments.Clone(),
@ -303,7 +314,7 @@ func (dq *DocumentQuery) Clone() *DocumentQuery {
// WithGroup tells the query-builder to eager-load the nodes that are connected to // WithGroup tells the query-builder to eager-load the nodes that are connected to
// the "group" edge. The optional arguments are used to configure the query builder of the edge. // the "group" edge. The optional arguments are used to configure the query builder of the edge.
func (dq *DocumentQuery) WithGroup(opts ...func(*GroupQuery)) *DocumentQuery { func (dq *DocumentQuery) WithGroup(opts ...func(*GroupQuery)) *DocumentQuery {
query := &GroupQuery{config: dq.config} query := (&GroupClient{config: dq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -314,7 +325,7 @@ func (dq *DocumentQuery) WithGroup(opts ...func(*GroupQuery)) *DocumentQuery {
// WithAttachments tells the query-builder to eager-load the nodes that are connected to // WithAttachments tells the query-builder to eager-load the nodes that are connected to
// the "attachments" edge. The optional arguments are used to configure the query builder of the edge. // the "attachments" edge. The optional arguments are used to configure the query builder of the edge.
func (dq *DocumentQuery) WithAttachments(opts ...func(*AttachmentQuery)) *DocumentQuery { func (dq *DocumentQuery) WithAttachments(opts ...func(*AttachmentQuery)) *DocumentQuery {
query := &AttachmentQuery{config: dq.config} query := (&AttachmentClient{config: dq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -337,16 +348,11 @@ func (dq *DocumentQuery) WithAttachments(opts ...func(*AttachmentQuery)) *Docume
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (dq *DocumentQuery) GroupBy(field string, fields ...string) *DocumentGroupBy { func (dq *DocumentQuery) GroupBy(field string, fields ...string) *DocumentGroupBy {
grbuild := &DocumentGroupBy{config: dq.config} dq.fields = append([]string{field}, fields...)
grbuild.fields = append([]string{field}, fields...) grbuild := &DocumentGroupBy{build: dq}
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { grbuild.flds = &dq.fields
if err := dq.prepareQuery(ctx); err != nil {
return nil, err
}
return dq.sqlQuery(ctx), nil
}
grbuild.label = document.Label grbuild.label = document.Label
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan grbuild.scan = grbuild.Scan
return grbuild return grbuild
} }
@ -364,10 +370,10 @@ func (dq *DocumentQuery) GroupBy(field string, fields ...string) *DocumentGroupB
// Scan(ctx, &v) // Scan(ctx, &v)
func (dq *DocumentQuery) Select(fields ...string) *DocumentSelect { func (dq *DocumentQuery) Select(fields ...string) *DocumentSelect {
dq.fields = append(dq.fields, fields...) dq.fields = append(dq.fields, fields...)
selbuild := &DocumentSelect{DocumentQuery: dq} sbuild := &DocumentSelect{DocumentQuery: dq}
selbuild.label = document.Label sbuild.label = document.Label
selbuild.flds, selbuild.scan = &dq.fields, selbuild.Scan sbuild.flds, sbuild.scan = &dq.fields, sbuild.Scan
return selbuild return sbuild
} }
// Aggregate returns a DocumentSelect configured with the given aggregations. // Aggregate returns a DocumentSelect configured with the given aggregations.
@ -376,6 +382,16 @@ func (dq *DocumentQuery) Aggregate(fns ...AggregateFunc) *DocumentSelect {
} }
func (dq *DocumentQuery) prepareQuery(ctx context.Context) error { func (dq *DocumentQuery) prepareQuery(ctx context.Context) error {
for _, inter := range dq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, dq); err != nil {
return err
}
}
}
for _, f := range dq.fields { for _, f := range dq.fields {
if !document.ValidColumn(f) { if !document.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
@ -511,17 +527,6 @@ func (dq *DocumentQuery) sqlCount(ctx context.Context) (int, error) {
return sqlgraph.CountNodes(ctx, dq.driver, _spec) return sqlgraph.CountNodes(ctx, dq.driver, _spec)
} }
func (dq *DocumentQuery) sqlExist(ctx context.Context) (bool, error) {
switch _, err := dq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
func (dq *DocumentQuery) querySpec() *sqlgraph.QuerySpec { func (dq *DocumentQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
@ -604,13 +609,8 @@ func (dq *DocumentQuery) sqlQuery(ctx context.Context) *sql.Selector {
// DocumentGroupBy is the group-by builder for Document entities. // DocumentGroupBy is the group-by builder for Document entities.
type DocumentGroupBy struct { type DocumentGroupBy struct {
config
selector selector
fields []string build *DocumentQuery
fns []AggregateFunc
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
} }
// Aggregate adds the given aggregation functions to the group-by query. // Aggregate adds the given aggregation functions to the group-by query.
@ -619,58 +619,46 @@ func (dgb *DocumentGroupBy) Aggregate(fns ...AggregateFunc) *DocumentGroupBy {
return dgb return dgb
} }
// Scan applies the group-by query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (dgb *DocumentGroupBy) Scan(ctx context.Context, v any) error { func (dgb *DocumentGroupBy) Scan(ctx context.Context, v any) error {
query, err := dgb.path(ctx) ctx = newQueryContext(ctx, TypeDocument, "GroupBy")
if err != nil { if err := dgb.build.prepareQuery(ctx); err != nil {
return err return err
} }
dgb.sql = query return scanWithInterceptors[*DocumentQuery, *DocumentGroupBy](ctx, dgb.build, dgb, dgb.build.inters, v)
return dgb.sqlScan(ctx, v)
} }
func (dgb *DocumentGroupBy) sqlScan(ctx context.Context, v any) error { func (dgb *DocumentGroupBy) sqlScan(ctx context.Context, root *DocumentQuery, v any) error {
for _, f := range dgb.fields { selector := root.sqlQuery(ctx).Select()
if !document.ValidColumn(f) { aggregation := make([]string, 0, len(dgb.fns))
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} for _, fn := range dgb.fns {
} aggregation = append(aggregation, fn(selector))
} }
selector := dgb.sqlQuery() if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*dgb.flds)+len(dgb.fns))
for _, f := range *dgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*dgb.flds...)...)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return err return err
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() query, args := selector.Query()
if err := dgb.driver.Query(ctx, query, args, rows); err != nil { if err := dgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }
defer rows.Close() defer rows.Close()
return sql.ScanSlice(rows, v) return sql.ScanSlice(rows, v)
} }
func (dgb *DocumentGroupBy) sqlQuery() *sql.Selector {
selector := dgb.sql.Select()
aggregation := make([]string, 0, len(dgb.fns))
for _, fn := range dgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(dgb.fields)+len(dgb.fns))
for _, f := range dgb.fields {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
return selector.GroupBy(selector.Columns(dgb.fields...)...)
}
// DocumentSelect is the builder for selecting fields of Document entities. // DocumentSelect is the builder for selecting fields of Document entities.
type DocumentSelect struct { type DocumentSelect struct {
*DocumentQuery *DocumentQuery
selector selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
@ -681,26 +669,27 @@ func (ds *DocumentSelect) Aggregate(fns ...AggregateFunc) *DocumentSelect {
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (ds *DocumentSelect) Scan(ctx context.Context, v any) error { func (ds *DocumentSelect) Scan(ctx context.Context, v any) error {
ctx = newQueryContext(ctx, TypeDocument, "Select")
if err := ds.prepareQuery(ctx); err != nil { if err := ds.prepareQuery(ctx); err != nil {
return err return err
} }
ds.sql = ds.DocumentQuery.sqlQuery(ctx) return scanWithInterceptors[*DocumentQuery, *DocumentSelect](ctx, ds.DocumentQuery, ds, ds.inters, v)
return ds.sqlScan(ctx, v)
} }
func (ds *DocumentSelect) sqlScan(ctx context.Context, v any) error { func (ds *DocumentSelect) sqlScan(ctx context.Context, root *DocumentQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(ds.fns)) aggregation := make([]string, 0, len(ds.fns))
for _, fn := range ds.fns { for _, fn := range ds.fns {
aggregation = append(aggregation, fn(ds.sql)) aggregation = append(aggregation, fn(selector))
} }
switch n := len(*ds.selector.flds); { switch n := len(*ds.selector.flds); {
case n == 0 && len(aggregation) > 0: case n == 0 && len(aggregation) > 0:
ds.sql.Select(aggregation...) selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0: case n != 0 && len(aggregation) > 0:
ds.sql.AppendSelect(aggregation...) selector.AppendSelect(aggregation...)
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := ds.sql.Query() query, args := selector.Query()
if err := ds.driver.Query(ctx, query, args, rows); err != nil { if err := ds.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }

View file

@ -109,41 +109,8 @@ func (du *DocumentUpdate) RemoveAttachments(a ...*Attachment) *DocumentUpdate {
// Save executes the query and returns the number of nodes affected by the update operation. // Save executes the query and returns the number of nodes affected by the update operation.
func (du *DocumentUpdate) Save(ctx context.Context) (int, error) { func (du *DocumentUpdate) Save(ctx context.Context) (int, error) {
var (
err error
affected int
)
du.defaults() du.defaults()
if len(du.hooks) == 0 { return withHooks[int, DocumentMutation](ctx, du.sqlSave, du.mutation, du.hooks)
if err = du.check(); err != nil {
return 0, err
}
affected, err = du.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*DocumentMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = du.check(); err != nil {
return 0, err
}
du.mutation = mutation
affected, err = du.sqlSave(ctx)
mutation.done = true
return affected, err
})
for i := len(du.hooks) - 1; i >= 0; i-- {
if du.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = du.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, du.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -195,6 +162,9 @@ func (du *DocumentUpdate) check() error {
} }
func (du *DocumentUpdate) sqlSave(ctx context.Context) (n int, err error) { func (du *DocumentUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := du.check(); err != nil {
return n, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: document.Table, Table: document.Table,
@ -318,6 +288,7 @@ func (du *DocumentUpdate) sqlSave(ctx context.Context) (n int, err error) {
} }
return 0, err return 0, err
} }
du.mutation.done = true
return n, nil return n, nil
} }
@ -414,47 +385,8 @@ func (duo *DocumentUpdateOne) Select(field string, fields ...string) *DocumentUp
// Save executes the query and returns the updated Document entity. // Save executes the query and returns the updated Document entity.
func (duo *DocumentUpdateOne) Save(ctx context.Context) (*Document, error) { func (duo *DocumentUpdateOne) Save(ctx context.Context) (*Document, error) {
var (
err error
node *Document
)
duo.defaults() duo.defaults()
if len(duo.hooks) == 0 { return withHooks[*Document, DocumentMutation](ctx, duo.sqlSave, duo.mutation, duo.hooks)
if err = duo.check(); err != nil {
return nil, err
}
node, err = duo.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*DocumentMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = duo.check(); err != nil {
return nil, err
}
duo.mutation = mutation
node, err = duo.sqlSave(ctx)
mutation.done = true
return node, err
})
for i := len(duo.hooks) - 1; i >= 0; i-- {
if duo.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = duo.hooks[i](mut)
}
v, err := mut.Mutate(ctx, duo.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Document)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from DocumentMutation", v)
}
node = nv
}
return node, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -506,6 +438,9 @@ func (duo *DocumentUpdateOne) check() error {
} }
func (duo *DocumentUpdateOne) sqlSave(ctx context.Context) (_node *Document, err error) { func (duo *DocumentUpdateOne) sqlSave(ctx context.Context) (_node *Document, err error) {
if err := duo.check(); err != nil {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: document.Table, Table: document.Table,
@ -649,5 +584,6 @@ func (duo *DocumentUpdateOne) sqlSave(ctx context.Context) (_node *Document, err
} }
return nil, err return nil, err
} }
duo.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -6,6 +6,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"reflect"
"entgo.io/ent" "entgo.io/ent"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
@ -26,14 +27,20 @@ import (
// ent aliases to avoid import conflicts in user's code. // ent aliases to avoid import conflicts in user's code.
type ( type (
Op = ent.Op Op = ent.Op
Hook = ent.Hook Hook = ent.Hook
Value = ent.Value Value = ent.Value
Query = ent.Query Query = ent.Query
Policy = ent.Policy Querier = ent.Querier
Mutator = ent.Mutator QuerierFunc = ent.QuerierFunc
Mutation = ent.Mutation Interceptor = ent.Interceptor
MutateFunc = ent.MutateFunc InterceptFunc = ent.InterceptFunc
Traverser = ent.Traverser
TraverseFunc = ent.TraverseFunc
Policy = ent.Policy
Mutator = ent.Mutator
Mutation = ent.Mutation
MutateFunc = ent.MutateFunc
) )
// OrderFunc applies an ordering on the sql selector. // OrderFunc applies an ordering on the sql selector.
@ -484,5 +491,120 @@ func (s *selector) BoolX(ctx context.Context) bool {
return v return v
} }
// withHooks invokes the builder operation with the given hooks, if any.
func withHooks[V Value, M any, PM interface {
*M
Mutation
}](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) {
if len(hooks) == 0 {
return exec(ctx)
}
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutationT, ok := m.(PM)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
// Set the mutation to the builder.
*mutation = *mutationT
return exec(ctx)
})
for i := len(hooks) - 1; i >= 0; i-- {
if hooks[i] == nil {
return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = hooks[i](mut)
}
v, err := mut.Mutate(ctx, mutation)
if err != nil {
return value, err
}
nv, ok := v.(V)
if !ok {
return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation)
}
return nv, nil
}
// newQueryContext returns a new context with the given QueryContext attached in case it does not exist.
func newQueryContext(ctx context.Context, typ, op string) context.Context {
if ent.QueryFromContext(ctx) == nil {
ctx = ent.NewQueryContext(ctx, &ent.QueryContext{Type: typ, Op: op})
}
return ctx
}
func querierAll[V Value, Q interface {
sqlAll(context.Context, ...queryHook) (V, error)
}]() Querier {
return QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
query, ok := q.(Q)
if !ok {
return nil, fmt.Errorf("unexpected query type %T", q)
}
return query.sqlAll(ctx)
})
}
func querierCount[Q interface {
sqlCount(context.Context) (int, error)
}]() Querier {
return QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
query, ok := q.(Q)
if !ok {
return nil, fmt.Errorf("unexpected query type %T", q)
}
return query.sqlCount(ctx)
})
}
func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) {
for i := len(inters) - 1; i >= 0; i-- {
qr = inters[i].Intercept(qr)
}
rv, err := qr.Query(ctx, q)
if err != nil {
return v, err
}
vt, ok := rv.(V)
if !ok {
return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v)
}
return vt, nil
}
func scanWithInterceptors[Q1 ent.Query, Q2 interface {
sqlScan(context.Context, Q1, any) error
}](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error {
rv := reflect.ValueOf(v)
var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
query, ok := q.(Q1)
if !ok {
return nil, fmt.Errorf("unexpected query type %T", q)
}
if err := selectOrGroup.sqlScan(ctx, query, v); err != nil {
return nil, err
}
if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() {
return rv.Elem().Interface(), nil
}
return v, nil
})
for i := len(inters) - 1; i >= 0; i-- {
qr = inters[i].Intercept(qr)
}
vv, err := qr.Query(ctx, rootQuery)
if err != nil {
return err
}
switch rv2 := reflect.ValueOf(vv); {
case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer:
case rv.Type() == rv2.Type():
rv.Elem().Set(rv2.Elem())
case rv.Elem().Type() == rv2.Type():
rv.Elem().Set(rv2)
}
return nil
}
// queryHook describes an internal hook for the different sqlAll methods. // queryHook describes an internal hook for the different sqlAll methods.
type queryHook func(context.Context, *sqlgraph.QuerySpec) type queryHook func(context.Context, *sqlgraph.QuerySpec)

View file

@ -13,357 +13,227 @@ import (
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.
func ID(id uuid.UUID) predicate.Group { func ID(id uuid.UUID) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDEQ applies the EQ predicate on the ID field. // IDEQ applies the EQ predicate on the ID field.
func IDEQ(id uuid.UUID) predicate.Group { func IDEQ(id uuid.UUID) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDNEQ applies the NEQ predicate on the ID field. // IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id uuid.UUID) predicate.Group { func IDNEQ(id uuid.UUID) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldNEQ(FieldID, id))
s.Where(sql.NEQ(s.C(FieldID), id))
})
} }
// IDIn applies the In predicate on the ID field. // IDIn applies the In predicate on the ID field.
func IDIn(ids ...uuid.UUID) predicate.Group { func IDIn(ids ...uuid.UUID) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.In(s.C(FieldID), v...))
})
} }
// IDNotIn applies the NotIn predicate on the ID field. // IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...uuid.UUID) predicate.Group { func IDNotIn(ids ...uuid.UUID) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldNotIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.NotIn(s.C(FieldID), v...))
})
} }
// IDGT applies the GT predicate on the ID field. // IDGT applies the GT predicate on the ID field.
func IDGT(id uuid.UUID) predicate.Group { func IDGT(id uuid.UUID) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldGT(FieldID, id))
s.Where(sql.GT(s.C(FieldID), id))
})
} }
// IDGTE applies the GTE predicate on the ID field. // IDGTE applies the GTE predicate on the ID field.
func IDGTE(id uuid.UUID) predicate.Group { func IDGTE(id uuid.UUID) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldGTE(FieldID, id))
s.Where(sql.GTE(s.C(FieldID), id))
})
} }
// IDLT applies the LT predicate on the ID field. // IDLT applies the LT predicate on the ID field.
func IDLT(id uuid.UUID) predicate.Group { func IDLT(id uuid.UUID) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldLT(FieldID, id))
s.Where(sql.LT(s.C(FieldID), id))
})
} }
// IDLTE applies the LTE predicate on the ID field. // IDLTE applies the LTE predicate on the ID field.
func IDLTE(id uuid.UUID) predicate.Group { func IDLTE(id uuid.UUID) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldLTE(FieldID, id))
s.Where(sql.LTE(s.C(FieldID), id))
})
} }
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. // CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.Group { func CreatedAt(v time.Time) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. // UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.Group { func UpdatedAt(v time.Time) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// Name applies equality check predicate on the "name" field. It's identical to NameEQ. // Name applies equality check predicate on the "name" field. It's identical to NameEQ.
func Name(v string) predicate.Group { func Name(v string) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldEQ(FieldName, v))
s.Where(sql.EQ(s.C(FieldName), v))
})
} }
// CreatedAtEQ applies the EQ predicate on the "created_at" field. // CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.Group { func CreatedAtEQ(v time.Time) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. // CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.Group { func CreatedAtNEQ(v time.Time) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldNEQ(FieldCreatedAt, v))
s.Where(sql.NEQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtIn applies the In predicate on the "created_at" field. // CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.Group { func CreatedAtIn(vs ...time.Time) predicate.Group {
v := make([]any, len(vs)) return predicate.Group(sql.FieldIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Group(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. // CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.Group { func CreatedAtNotIn(vs ...time.Time) predicate.Group {
v := make([]any, len(vs)) return predicate.Group(sql.FieldNotIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Group(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtGT applies the GT predicate on the "created_at" field. // CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.Group { func CreatedAtGT(v time.Time) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldGT(FieldCreatedAt, v))
s.Where(sql.GT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtGTE applies the GTE predicate on the "created_at" field. // CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.Group { func CreatedAtGTE(v time.Time) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldGTE(FieldCreatedAt, v))
s.Where(sql.GTE(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLT applies the LT predicate on the "created_at" field. // CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.Group { func CreatedAtLT(v time.Time) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldLT(FieldCreatedAt, v))
s.Where(sql.LT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLTE applies the LTE predicate on the "created_at" field. // CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.Group { func CreatedAtLTE(v time.Time) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldLTE(FieldCreatedAt, v))
s.Where(sql.LTE(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. // UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.Group { func UpdatedAtEQ(v time.Time) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. // UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.Group { func UpdatedAtNEQ(v time.Time) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldNEQ(FieldUpdatedAt, v))
s.Where(sql.NEQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtIn applies the In predicate on the "updated_at" field. // UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.Group { func UpdatedAtIn(vs ...time.Time) predicate.Group {
v := make([]any, len(vs)) return predicate.Group(sql.FieldIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Group(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. // UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.Group { func UpdatedAtNotIn(vs ...time.Time) predicate.Group {
v := make([]any, len(vs)) return predicate.Group(sql.FieldNotIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Group(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtGT applies the GT predicate on the "updated_at" field. // UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.Group { func UpdatedAtGT(v time.Time) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldGT(FieldUpdatedAt, v))
s.Where(sql.GT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. // UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.Group { func UpdatedAtGTE(v time.Time) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldGTE(FieldUpdatedAt, v))
s.Where(sql.GTE(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLT applies the LT predicate on the "updated_at" field. // UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.Group { func UpdatedAtLT(v time.Time) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldLT(FieldUpdatedAt, v))
s.Where(sql.LT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. // UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.Group { func UpdatedAtLTE(v time.Time) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldLTE(FieldUpdatedAt, v))
s.Where(sql.LTE(s.C(FieldUpdatedAt), v))
})
} }
// NameEQ applies the EQ predicate on the "name" field. // NameEQ applies the EQ predicate on the "name" field.
func NameEQ(v string) predicate.Group { func NameEQ(v string) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldEQ(FieldName, v))
s.Where(sql.EQ(s.C(FieldName), v))
})
} }
// NameNEQ applies the NEQ predicate on the "name" field. // NameNEQ applies the NEQ predicate on the "name" field.
func NameNEQ(v string) predicate.Group { func NameNEQ(v string) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldNEQ(FieldName, v))
s.Where(sql.NEQ(s.C(FieldName), v))
})
} }
// NameIn applies the In predicate on the "name" field. // NameIn applies the In predicate on the "name" field.
func NameIn(vs ...string) predicate.Group { func NameIn(vs ...string) predicate.Group {
v := make([]any, len(vs)) return predicate.Group(sql.FieldIn(FieldName, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Group(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldName), v...))
})
} }
// NameNotIn applies the NotIn predicate on the "name" field. // NameNotIn applies the NotIn predicate on the "name" field.
func NameNotIn(vs ...string) predicate.Group { func NameNotIn(vs ...string) predicate.Group {
v := make([]any, len(vs)) return predicate.Group(sql.FieldNotIn(FieldName, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Group(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldName), v...))
})
} }
// NameGT applies the GT predicate on the "name" field. // NameGT applies the GT predicate on the "name" field.
func NameGT(v string) predicate.Group { func NameGT(v string) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldGT(FieldName, v))
s.Where(sql.GT(s.C(FieldName), v))
})
} }
// NameGTE applies the GTE predicate on the "name" field. // NameGTE applies the GTE predicate on the "name" field.
func NameGTE(v string) predicate.Group { func NameGTE(v string) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldGTE(FieldName, v))
s.Where(sql.GTE(s.C(FieldName), v))
})
} }
// NameLT applies the LT predicate on the "name" field. // NameLT applies the LT predicate on the "name" field.
func NameLT(v string) predicate.Group { func NameLT(v string) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldLT(FieldName, v))
s.Where(sql.LT(s.C(FieldName), v))
})
} }
// NameLTE applies the LTE predicate on the "name" field. // NameLTE applies the LTE predicate on the "name" field.
func NameLTE(v string) predicate.Group { func NameLTE(v string) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldLTE(FieldName, v))
s.Where(sql.LTE(s.C(FieldName), v))
})
} }
// NameContains applies the Contains predicate on the "name" field. // NameContains applies the Contains predicate on the "name" field.
func NameContains(v string) predicate.Group { func NameContains(v string) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldContains(FieldName, v))
s.Where(sql.Contains(s.C(FieldName), v))
})
} }
// NameHasPrefix applies the HasPrefix predicate on the "name" field. // NameHasPrefix applies the HasPrefix predicate on the "name" field.
func NameHasPrefix(v string) predicate.Group { func NameHasPrefix(v string) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldHasPrefix(FieldName, v))
s.Where(sql.HasPrefix(s.C(FieldName), v))
})
} }
// NameHasSuffix applies the HasSuffix predicate on the "name" field. // NameHasSuffix applies the HasSuffix predicate on the "name" field.
func NameHasSuffix(v string) predicate.Group { func NameHasSuffix(v string) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldHasSuffix(FieldName, v))
s.Where(sql.HasSuffix(s.C(FieldName), v))
})
} }
// NameEqualFold applies the EqualFold predicate on the "name" field. // NameEqualFold applies the EqualFold predicate on the "name" field.
func NameEqualFold(v string) predicate.Group { func NameEqualFold(v string) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldEqualFold(FieldName, v))
s.Where(sql.EqualFold(s.C(FieldName), v))
})
} }
// NameContainsFold applies the ContainsFold predicate on the "name" field. // NameContainsFold applies the ContainsFold predicate on the "name" field.
func NameContainsFold(v string) predicate.Group { func NameContainsFold(v string) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldContainsFold(FieldName, v))
s.Where(sql.ContainsFold(s.C(FieldName), v))
})
} }
// CurrencyEQ applies the EQ predicate on the "currency" field. // CurrencyEQ applies the EQ predicate on the "currency" field.
func CurrencyEQ(v Currency) predicate.Group { func CurrencyEQ(v Currency) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldEQ(FieldCurrency, v))
s.Where(sql.EQ(s.C(FieldCurrency), v))
})
} }
// CurrencyNEQ applies the NEQ predicate on the "currency" field. // CurrencyNEQ applies the NEQ predicate on the "currency" field.
func CurrencyNEQ(v Currency) predicate.Group { func CurrencyNEQ(v Currency) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(sql.FieldNEQ(FieldCurrency, v))
s.Where(sql.NEQ(s.C(FieldCurrency), v))
})
} }
// CurrencyIn applies the In predicate on the "currency" field. // CurrencyIn applies the In predicate on the "currency" field.
func CurrencyIn(vs ...Currency) predicate.Group { func CurrencyIn(vs ...Currency) predicate.Group {
v := make([]any, len(vs)) return predicate.Group(sql.FieldIn(FieldCurrency, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Group(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldCurrency), v...))
})
} }
// CurrencyNotIn applies the NotIn predicate on the "currency" field. // CurrencyNotIn applies the NotIn predicate on the "currency" field.
func CurrencyNotIn(vs ...Currency) predicate.Group { func CurrencyNotIn(vs ...Currency) predicate.Group {
v := make([]any, len(vs)) return predicate.Group(sql.FieldNotIn(FieldCurrency, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Group(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldCurrency), v...))
})
} }
// HasUsers applies the HasEdge predicate on the "users" edge. // HasUsers applies the HasEdge predicate on the "users" edge.
@ -371,7 +241,6 @@ func HasUsers() predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(UsersTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, UsersTable, UsersColumn), sqlgraph.Edge(sqlgraph.O2M, false, UsersTable, UsersColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)
@ -399,7 +268,6 @@ func HasLocations() predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(LocationsTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, LocationsTable, LocationsColumn), sqlgraph.Edge(sqlgraph.O2M, false, LocationsTable, LocationsColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)
@ -427,7 +295,6 @@ func HasItems() predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(ItemsTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, ItemsTable, ItemsColumn), sqlgraph.Edge(sqlgraph.O2M, false, ItemsTable, ItemsColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)
@ -455,7 +322,6 @@ func HasLabels() predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(LabelsTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, LabelsTable, LabelsColumn), sqlgraph.Edge(sqlgraph.O2M, false, LabelsTable, LabelsColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)
@ -483,7 +349,6 @@ func HasDocuments() predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(DocumentsTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, DocumentsTable, DocumentsColumn), sqlgraph.Edge(sqlgraph.O2M, false, DocumentsTable, DocumentsColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)
@ -511,7 +376,6 @@ func HasInvitationTokens() predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(InvitationTokensTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, InvitationTokensTable, InvitationTokensColumn), sqlgraph.Edge(sqlgraph.O2M, false, InvitationTokensTable, InvitationTokensColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)

View file

@ -186,50 +186,8 @@ func (gc *GroupCreate) Mutation() *GroupMutation {
// Save creates the Group in the database. // Save creates the Group in the database.
func (gc *GroupCreate) Save(ctx context.Context) (*Group, error) { func (gc *GroupCreate) Save(ctx context.Context) (*Group, error) {
var (
err error
node *Group
)
gc.defaults() gc.defaults()
if len(gc.hooks) == 0 { return withHooks[*Group, GroupMutation](ctx, gc.sqlSave, gc.mutation, gc.hooks)
if err = gc.check(); err != nil {
return nil, err
}
node, err = gc.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*GroupMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = gc.check(); err != nil {
return nil, err
}
gc.mutation = mutation
if node, err = gc.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(gc.hooks) - 1; i >= 0; i-- {
if gc.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = gc.hooks[i](mut)
}
v, err := mut.Mutate(ctx, gc.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Group)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from GroupMutation", v)
}
node = nv
}
return node, err
} }
// SaveX calls Save and panics if Save returns an error. // SaveX calls Save and panics if Save returns an error.
@ -302,6 +260,9 @@ func (gc *GroupCreate) check() error {
} }
func (gc *GroupCreate) sqlSave(ctx context.Context) (*Group, error) { func (gc *GroupCreate) sqlSave(ctx context.Context) (*Group, error) {
if err := gc.check(); err != nil {
return nil, err
}
_node, _spec := gc.createSpec() _node, _spec := gc.createSpec()
if err := sqlgraph.CreateNode(ctx, gc.driver, _spec); err != nil { if err := sqlgraph.CreateNode(ctx, gc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) { if sqlgraph.IsConstraintError(err) {
@ -316,6 +277,8 @@ func (gc *GroupCreate) sqlSave(ctx context.Context) (*Group, error) {
return nil, err return nil, err
} }
} }
gc.mutation.id = &_node.ID
gc.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -4,7 +4,6 @@ package ent
import ( import (
"context" "context"
"fmt"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
@ -28,34 +27,7 @@ func (gd *GroupDelete) Where(ps ...predicate.Group) *GroupDelete {
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (gd *GroupDelete) Exec(ctx context.Context) (int, error) { func (gd *GroupDelete) Exec(ctx context.Context) (int, error) {
var ( return withHooks[int, GroupMutation](ctx, gd.sqlExec, gd.mutation, gd.hooks)
err error
affected int
)
if len(gd.hooks) == 0 {
affected, err = gd.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*GroupMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
gd.mutation = mutation
affected, err = gd.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(gd.hooks) - 1; i >= 0; i-- {
if gd.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = gd.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, gd.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
@ -88,6 +60,7 @@ func (gd *GroupDelete) sqlExec(ctx context.Context) (int, error) {
if err != nil && sqlgraph.IsConstraintError(err) { if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
gd.mutation.done = true
return affected, err return affected, err
} }

View file

@ -30,6 +30,7 @@ type GroupQuery struct {
unique *bool unique *bool
order []OrderFunc order []OrderFunc
fields []string fields []string
inters []Interceptor
predicates []predicate.Group predicates []predicate.Group
withUsers *UserQuery withUsers *UserQuery
withLocations *LocationQuery withLocations *LocationQuery
@ -48,13 +49,13 @@ func (gq *GroupQuery) Where(ps ...predicate.Group) *GroupQuery {
return gq return gq
} }
// Limit adds a limit step to the query. // Limit the number of records to be returned by this query.
func (gq *GroupQuery) Limit(limit int) *GroupQuery { func (gq *GroupQuery) Limit(limit int) *GroupQuery {
gq.limit = &limit gq.limit = &limit
return gq return gq
} }
// Offset adds an offset step to the query. // Offset to start from.
func (gq *GroupQuery) Offset(offset int) *GroupQuery { func (gq *GroupQuery) Offset(offset int) *GroupQuery {
gq.offset = &offset gq.offset = &offset
return gq return gq
@ -67,7 +68,7 @@ func (gq *GroupQuery) Unique(unique bool) *GroupQuery {
return gq return gq
} }
// Order adds an order step to the query. // Order specifies how the records should be ordered.
func (gq *GroupQuery) Order(o ...OrderFunc) *GroupQuery { func (gq *GroupQuery) Order(o ...OrderFunc) *GroupQuery {
gq.order = append(gq.order, o...) gq.order = append(gq.order, o...)
return gq return gq
@ -75,7 +76,7 @@ func (gq *GroupQuery) Order(o ...OrderFunc) *GroupQuery {
// QueryUsers chains the current query on the "users" edge. // QueryUsers chains the current query on the "users" edge.
func (gq *GroupQuery) QueryUsers() *UserQuery { func (gq *GroupQuery) QueryUsers() *UserQuery {
query := &UserQuery{config: gq.config} query := (&UserClient{config: gq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := gq.prepareQuery(ctx); err != nil { if err := gq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -97,7 +98,7 @@ func (gq *GroupQuery) QueryUsers() *UserQuery {
// QueryLocations chains the current query on the "locations" edge. // QueryLocations chains the current query on the "locations" edge.
func (gq *GroupQuery) QueryLocations() *LocationQuery { func (gq *GroupQuery) QueryLocations() *LocationQuery {
query := &LocationQuery{config: gq.config} query := (&LocationClient{config: gq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := gq.prepareQuery(ctx); err != nil { if err := gq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -119,7 +120,7 @@ func (gq *GroupQuery) QueryLocations() *LocationQuery {
// QueryItems chains the current query on the "items" edge. // QueryItems chains the current query on the "items" edge.
func (gq *GroupQuery) QueryItems() *ItemQuery { func (gq *GroupQuery) QueryItems() *ItemQuery {
query := &ItemQuery{config: gq.config} query := (&ItemClient{config: gq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := gq.prepareQuery(ctx); err != nil { if err := gq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -141,7 +142,7 @@ func (gq *GroupQuery) QueryItems() *ItemQuery {
// QueryLabels chains the current query on the "labels" edge. // QueryLabels chains the current query on the "labels" edge.
func (gq *GroupQuery) QueryLabels() *LabelQuery { func (gq *GroupQuery) QueryLabels() *LabelQuery {
query := &LabelQuery{config: gq.config} query := (&LabelClient{config: gq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := gq.prepareQuery(ctx); err != nil { if err := gq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -163,7 +164,7 @@ func (gq *GroupQuery) QueryLabels() *LabelQuery {
// QueryDocuments chains the current query on the "documents" edge. // QueryDocuments chains the current query on the "documents" edge.
func (gq *GroupQuery) QueryDocuments() *DocumentQuery { func (gq *GroupQuery) QueryDocuments() *DocumentQuery {
query := &DocumentQuery{config: gq.config} query := (&DocumentClient{config: gq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := gq.prepareQuery(ctx); err != nil { if err := gq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -185,7 +186,7 @@ func (gq *GroupQuery) QueryDocuments() *DocumentQuery {
// QueryInvitationTokens chains the current query on the "invitation_tokens" edge. // QueryInvitationTokens chains the current query on the "invitation_tokens" edge.
func (gq *GroupQuery) QueryInvitationTokens() *GroupInvitationTokenQuery { func (gq *GroupQuery) QueryInvitationTokens() *GroupInvitationTokenQuery {
query := &GroupInvitationTokenQuery{config: gq.config} query := (&GroupInvitationTokenClient{config: gq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := gq.prepareQuery(ctx); err != nil { if err := gq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -208,7 +209,7 @@ func (gq *GroupQuery) QueryInvitationTokens() *GroupInvitationTokenQuery {
// First returns the first Group entity from the query. // First returns the first Group entity from the query.
// Returns a *NotFoundError when no Group was found. // Returns a *NotFoundError when no Group was found.
func (gq *GroupQuery) First(ctx context.Context) (*Group, error) { func (gq *GroupQuery) First(ctx context.Context) (*Group, error) {
nodes, err := gq.Limit(1).All(ctx) nodes, err := gq.Limit(1).All(newQueryContext(ctx, TypeGroup, "First"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -231,7 +232,7 @@ func (gq *GroupQuery) FirstX(ctx context.Context) *Group {
// Returns a *NotFoundError when no Group ID was found. // Returns a *NotFoundError when no Group ID was found.
func (gq *GroupQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { func (gq *GroupQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = gq.Limit(1).IDs(ctx); err != nil { if ids, err = gq.Limit(1).IDs(newQueryContext(ctx, TypeGroup, "FirstID")); err != nil {
return return
} }
if len(ids) == 0 { if len(ids) == 0 {
@ -254,7 +255,7 @@ func (gq *GroupQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one Group entity is found. // Returns a *NotSingularError when more than one Group entity is found.
// Returns a *NotFoundError when no Group entities are found. // Returns a *NotFoundError when no Group entities are found.
func (gq *GroupQuery) Only(ctx context.Context) (*Group, error) { func (gq *GroupQuery) Only(ctx context.Context) (*Group, error) {
nodes, err := gq.Limit(2).All(ctx) nodes, err := gq.Limit(2).All(newQueryContext(ctx, TypeGroup, "Only"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -282,7 +283,7 @@ func (gq *GroupQuery) OnlyX(ctx context.Context) *Group {
// Returns a *NotFoundError when no entities are found. // Returns a *NotFoundError when no entities are found.
func (gq *GroupQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { func (gq *GroupQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = gq.Limit(2).IDs(ctx); err != nil { if ids, err = gq.Limit(2).IDs(newQueryContext(ctx, TypeGroup, "OnlyID")); err != nil {
return return
} }
switch len(ids) { switch len(ids) {
@ -307,10 +308,12 @@ func (gq *GroupQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of Groups. // All executes the query and returns a list of Groups.
func (gq *GroupQuery) All(ctx context.Context) ([]*Group, error) { func (gq *GroupQuery) All(ctx context.Context) ([]*Group, error) {
ctx = newQueryContext(ctx, TypeGroup, "All")
if err := gq.prepareQuery(ctx); err != nil { if err := gq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return gq.sqlAll(ctx) qr := querierAll[[]*Group, *GroupQuery]()
return withInterceptors[[]*Group](ctx, gq, qr, gq.inters)
} }
// AllX is like All, but panics if an error occurs. // AllX is like All, but panics if an error occurs.
@ -325,6 +328,7 @@ func (gq *GroupQuery) AllX(ctx context.Context) []*Group {
// IDs executes the query and returns a list of Group IDs. // IDs executes the query and returns a list of Group IDs.
func (gq *GroupQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (gq *GroupQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID var ids []uuid.UUID
ctx = newQueryContext(ctx, TypeGroup, "IDs")
if err := gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { if err := gq.Select(group.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
@ -342,10 +346,11 @@ func (gq *GroupQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query. // Count returns the count of the given query.
func (gq *GroupQuery) Count(ctx context.Context) (int, error) { func (gq *GroupQuery) Count(ctx context.Context) (int, error) {
ctx = newQueryContext(ctx, TypeGroup, "Count")
if err := gq.prepareQuery(ctx); err != nil { if err := gq.prepareQuery(ctx); err != nil {
return 0, err return 0, err
} }
return gq.sqlCount(ctx) return withInterceptors[int](ctx, gq, querierCount[*GroupQuery](), gq.inters)
} }
// CountX is like Count, but panics if an error occurs. // CountX is like Count, but panics if an error occurs.
@ -359,10 +364,15 @@ func (gq *GroupQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph. // Exist returns true if the query has elements in the graph.
func (gq *GroupQuery) Exist(ctx context.Context) (bool, error) { func (gq *GroupQuery) Exist(ctx context.Context) (bool, error) {
if err := gq.prepareQuery(ctx); err != nil { ctx = newQueryContext(ctx, TypeGroup, "Exist")
return false, err switch _, err := gq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
} }
return gq.sqlExist(ctx)
} }
// ExistX is like Exist, but panics if an error occurs. // ExistX is like Exist, but panics if an error occurs.
@ -385,6 +395,7 @@ func (gq *GroupQuery) Clone() *GroupQuery {
limit: gq.limit, limit: gq.limit,
offset: gq.offset, offset: gq.offset,
order: append([]OrderFunc{}, gq.order...), order: append([]OrderFunc{}, gq.order...),
inters: append([]Interceptor{}, gq.inters...),
predicates: append([]predicate.Group{}, gq.predicates...), predicates: append([]predicate.Group{}, gq.predicates...),
withUsers: gq.withUsers.Clone(), withUsers: gq.withUsers.Clone(),
withLocations: gq.withLocations.Clone(), withLocations: gq.withLocations.Clone(),
@ -402,7 +413,7 @@ func (gq *GroupQuery) Clone() *GroupQuery {
// WithUsers tells the query-builder to eager-load the nodes that are connected to // WithUsers tells the query-builder to eager-load the nodes that are connected to
// the "users" edge. The optional arguments are used to configure the query builder of the edge. // the "users" edge. The optional arguments are used to configure the query builder of the edge.
func (gq *GroupQuery) WithUsers(opts ...func(*UserQuery)) *GroupQuery { func (gq *GroupQuery) WithUsers(opts ...func(*UserQuery)) *GroupQuery {
query := &UserQuery{config: gq.config} query := (&UserClient{config: gq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -413,7 +424,7 @@ func (gq *GroupQuery) WithUsers(opts ...func(*UserQuery)) *GroupQuery {
// WithLocations tells the query-builder to eager-load the nodes that are connected to // WithLocations tells the query-builder to eager-load the nodes that are connected to
// the "locations" edge. The optional arguments are used to configure the query builder of the edge. // the "locations" edge. The optional arguments are used to configure the query builder of the edge.
func (gq *GroupQuery) WithLocations(opts ...func(*LocationQuery)) *GroupQuery { func (gq *GroupQuery) WithLocations(opts ...func(*LocationQuery)) *GroupQuery {
query := &LocationQuery{config: gq.config} query := (&LocationClient{config: gq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -424,7 +435,7 @@ func (gq *GroupQuery) WithLocations(opts ...func(*LocationQuery)) *GroupQuery {
// WithItems tells the query-builder to eager-load the nodes that are connected to // WithItems tells the query-builder to eager-load the nodes that are connected to
// the "items" edge. The optional arguments are used to configure the query builder of the edge. // the "items" edge. The optional arguments are used to configure the query builder of the edge.
func (gq *GroupQuery) WithItems(opts ...func(*ItemQuery)) *GroupQuery { func (gq *GroupQuery) WithItems(opts ...func(*ItemQuery)) *GroupQuery {
query := &ItemQuery{config: gq.config} query := (&ItemClient{config: gq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -435,7 +446,7 @@ func (gq *GroupQuery) WithItems(opts ...func(*ItemQuery)) *GroupQuery {
// WithLabels tells the query-builder to eager-load the nodes that are connected to // WithLabels tells the query-builder to eager-load the nodes that are connected to
// the "labels" edge. The optional arguments are used to configure the query builder of the edge. // the "labels" edge. The optional arguments are used to configure the query builder of the edge.
func (gq *GroupQuery) WithLabels(opts ...func(*LabelQuery)) *GroupQuery { func (gq *GroupQuery) WithLabels(opts ...func(*LabelQuery)) *GroupQuery {
query := &LabelQuery{config: gq.config} query := (&LabelClient{config: gq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -446,7 +457,7 @@ func (gq *GroupQuery) WithLabels(opts ...func(*LabelQuery)) *GroupQuery {
// WithDocuments tells the query-builder to eager-load the nodes that are connected to // WithDocuments tells the query-builder to eager-load the nodes that are connected to
// the "documents" edge. The optional arguments are used to configure the query builder of the edge. // the "documents" edge. The optional arguments are used to configure the query builder of the edge.
func (gq *GroupQuery) WithDocuments(opts ...func(*DocumentQuery)) *GroupQuery { func (gq *GroupQuery) WithDocuments(opts ...func(*DocumentQuery)) *GroupQuery {
query := &DocumentQuery{config: gq.config} query := (&DocumentClient{config: gq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -457,7 +468,7 @@ func (gq *GroupQuery) WithDocuments(opts ...func(*DocumentQuery)) *GroupQuery {
// WithInvitationTokens tells the query-builder to eager-load the nodes that are connected to // WithInvitationTokens tells the query-builder to eager-load the nodes that are connected to
// the "invitation_tokens" edge. The optional arguments are used to configure the query builder of the edge. // the "invitation_tokens" edge. The optional arguments are used to configure the query builder of the edge.
func (gq *GroupQuery) WithInvitationTokens(opts ...func(*GroupInvitationTokenQuery)) *GroupQuery { func (gq *GroupQuery) WithInvitationTokens(opts ...func(*GroupInvitationTokenQuery)) *GroupQuery {
query := &GroupInvitationTokenQuery{config: gq.config} query := (&GroupInvitationTokenClient{config: gq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -480,16 +491,11 @@ func (gq *GroupQuery) WithInvitationTokens(opts ...func(*GroupInvitationTokenQue
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (gq *GroupQuery) GroupBy(field string, fields ...string) *GroupGroupBy { func (gq *GroupQuery) GroupBy(field string, fields ...string) *GroupGroupBy {
grbuild := &GroupGroupBy{config: gq.config} gq.fields = append([]string{field}, fields...)
grbuild.fields = append([]string{field}, fields...) grbuild := &GroupGroupBy{build: gq}
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { grbuild.flds = &gq.fields
if err := gq.prepareQuery(ctx); err != nil {
return nil, err
}
return gq.sqlQuery(ctx), nil
}
grbuild.label = group.Label grbuild.label = group.Label
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan grbuild.scan = grbuild.Scan
return grbuild return grbuild
} }
@ -507,10 +513,10 @@ func (gq *GroupQuery) GroupBy(field string, fields ...string) *GroupGroupBy {
// Scan(ctx, &v) // Scan(ctx, &v)
func (gq *GroupQuery) Select(fields ...string) *GroupSelect { func (gq *GroupQuery) Select(fields ...string) *GroupSelect {
gq.fields = append(gq.fields, fields...) gq.fields = append(gq.fields, fields...)
selbuild := &GroupSelect{GroupQuery: gq} sbuild := &GroupSelect{GroupQuery: gq}
selbuild.label = group.Label sbuild.label = group.Label
selbuild.flds, selbuild.scan = &gq.fields, selbuild.Scan sbuild.flds, sbuild.scan = &gq.fields, sbuild.Scan
return selbuild return sbuild
} }
// Aggregate returns a GroupSelect configured with the given aggregations. // Aggregate returns a GroupSelect configured with the given aggregations.
@ -519,6 +525,16 @@ func (gq *GroupQuery) Aggregate(fns ...AggregateFunc) *GroupSelect {
} }
func (gq *GroupQuery) prepareQuery(ctx context.Context) error { func (gq *GroupQuery) prepareQuery(ctx context.Context) error {
for _, inter := range gq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, gq); err != nil {
return err
}
}
}
for _, f := range gq.fields { for _, f := range gq.fields {
if !group.ValidColumn(f) { if !group.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
@ -808,17 +824,6 @@ func (gq *GroupQuery) sqlCount(ctx context.Context) (int, error) {
return sqlgraph.CountNodes(ctx, gq.driver, _spec) return sqlgraph.CountNodes(ctx, gq.driver, _spec)
} }
func (gq *GroupQuery) sqlExist(ctx context.Context) (bool, error) {
switch _, err := gq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
func (gq *GroupQuery) querySpec() *sqlgraph.QuerySpec { func (gq *GroupQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
@ -901,13 +906,8 @@ func (gq *GroupQuery) sqlQuery(ctx context.Context) *sql.Selector {
// GroupGroupBy is the group-by builder for Group entities. // GroupGroupBy is the group-by builder for Group entities.
type GroupGroupBy struct { type GroupGroupBy struct {
config
selector selector
fields []string build *GroupQuery
fns []AggregateFunc
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
} }
// Aggregate adds the given aggregation functions to the group-by query. // Aggregate adds the given aggregation functions to the group-by query.
@ -916,58 +916,46 @@ func (ggb *GroupGroupBy) Aggregate(fns ...AggregateFunc) *GroupGroupBy {
return ggb return ggb
} }
// Scan applies the group-by query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (ggb *GroupGroupBy) Scan(ctx context.Context, v any) error { func (ggb *GroupGroupBy) Scan(ctx context.Context, v any) error {
query, err := ggb.path(ctx) ctx = newQueryContext(ctx, TypeGroup, "GroupBy")
if err != nil { if err := ggb.build.prepareQuery(ctx); err != nil {
return err return err
} }
ggb.sql = query return scanWithInterceptors[*GroupQuery, *GroupGroupBy](ctx, ggb.build, ggb, ggb.build.inters, v)
return ggb.sqlScan(ctx, v)
} }
func (ggb *GroupGroupBy) sqlScan(ctx context.Context, v any) error { func (ggb *GroupGroupBy) sqlScan(ctx context.Context, root *GroupQuery, v any) error {
for _, f := range ggb.fields { selector := root.sqlQuery(ctx).Select()
if !group.ValidColumn(f) { aggregation := make([]string, 0, len(ggb.fns))
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} for _, fn := range ggb.fns {
} aggregation = append(aggregation, fn(selector))
} }
selector := ggb.sqlQuery() if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*ggb.flds)+len(ggb.fns))
for _, f := range *ggb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*ggb.flds...)...)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return err return err
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() query, args := selector.Query()
if err := ggb.driver.Query(ctx, query, args, rows); err != nil { if err := ggb.build.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }
defer rows.Close() defer rows.Close()
return sql.ScanSlice(rows, v) return sql.ScanSlice(rows, v)
} }
func (ggb *GroupGroupBy) sqlQuery() *sql.Selector {
selector := ggb.sql.Select()
aggregation := make([]string, 0, len(ggb.fns))
for _, fn := range ggb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(ggb.fields)+len(ggb.fns))
for _, f := range ggb.fields {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
return selector.GroupBy(selector.Columns(ggb.fields...)...)
}
// GroupSelect is the builder for selecting fields of Group entities. // GroupSelect is the builder for selecting fields of Group entities.
type GroupSelect struct { type GroupSelect struct {
*GroupQuery *GroupQuery
selector selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
@ -978,26 +966,27 @@ func (gs *GroupSelect) Aggregate(fns ...AggregateFunc) *GroupSelect {
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (gs *GroupSelect) Scan(ctx context.Context, v any) error { func (gs *GroupSelect) Scan(ctx context.Context, v any) error {
ctx = newQueryContext(ctx, TypeGroup, "Select")
if err := gs.prepareQuery(ctx); err != nil { if err := gs.prepareQuery(ctx); err != nil {
return err return err
} }
gs.sql = gs.GroupQuery.sqlQuery(ctx) return scanWithInterceptors[*GroupQuery, *GroupSelect](ctx, gs.GroupQuery, gs, gs.inters, v)
return gs.sqlScan(ctx, v)
} }
func (gs *GroupSelect) sqlScan(ctx context.Context, v any) error { func (gs *GroupSelect) sqlScan(ctx context.Context, root *GroupQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(gs.fns)) aggregation := make([]string, 0, len(gs.fns))
for _, fn := range gs.fns { for _, fn := range gs.fns {
aggregation = append(aggregation, fn(gs.sql)) aggregation = append(aggregation, fn(selector))
} }
switch n := len(*gs.selector.flds); { switch n := len(*gs.selector.flds); {
case n == 0 && len(aggregation) > 0: case n == 0 && len(aggregation) > 0:
gs.sql.Select(aggregation...) selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0: case n != 0 && len(aggregation) > 0:
gs.sql.AppendSelect(aggregation...) selector.AppendSelect(aggregation...)
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := gs.sql.Query() query, args := selector.Query()
if err := gs.driver.Query(ctx, query, args, rows); err != nil { if err := gs.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }

View file

@ -284,41 +284,8 @@ func (gu *GroupUpdate) RemoveInvitationTokens(g ...*GroupInvitationToken) *Group
// Save executes the query and returns the number of nodes affected by the update operation. // Save executes the query and returns the number of nodes affected by the update operation.
func (gu *GroupUpdate) Save(ctx context.Context) (int, error) { func (gu *GroupUpdate) Save(ctx context.Context) (int, error) {
var (
err error
affected int
)
gu.defaults() gu.defaults()
if len(gu.hooks) == 0 { return withHooks[int, GroupMutation](ctx, gu.sqlSave, gu.mutation, gu.hooks)
if err = gu.check(); err != nil {
return 0, err
}
affected, err = gu.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*GroupMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = gu.check(); err != nil {
return 0, err
}
gu.mutation = mutation
affected, err = gu.sqlSave(ctx)
mutation.done = true
return affected, err
})
for i := len(gu.hooks) - 1; i >= 0; i-- {
if gu.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = gu.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, gu.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -367,6 +334,9 @@ func (gu *GroupUpdate) check() error {
} }
func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) { func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := gu.check(); err != nil {
return n, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: group.Table, Table: group.Table,
@ -725,6 +695,7 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) {
} }
return 0, err return 0, err
} }
gu.mutation.done = true
return n, nil return n, nil
} }
@ -992,47 +963,8 @@ func (guo *GroupUpdateOne) Select(field string, fields ...string) *GroupUpdateOn
// Save executes the query and returns the updated Group entity. // Save executes the query and returns the updated Group entity.
func (guo *GroupUpdateOne) Save(ctx context.Context) (*Group, error) { func (guo *GroupUpdateOne) Save(ctx context.Context) (*Group, error) {
var (
err error
node *Group
)
guo.defaults() guo.defaults()
if len(guo.hooks) == 0 { return withHooks[*Group, GroupMutation](ctx, guo.sqlSave, guo.mutation, guo.hooks)
if err = guo.check(); err != nil {
return nil, err
}
node, err = guo.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*GroupMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = guo.check(); err != nil {
return nil, err
}
guo.mutation = mutation
node, err = guo.sqlSave(ctx)
mutation.done = true
return node, err
})
for i := len(guo.hooks) - 1; i >= 0; i-- {
if guo.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = guo.hooks[i](mut)
}
v, err := mut.Mutate(ctx, guo.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Group)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from GroupMutation", v)
}
node = nv
}
return node, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -1081,6 +1013,9 @@ func (guo *GroupUpdateOne) check() error {
} }
func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error) { func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error) {
if err := guo.check(); err != nil {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: group.Table, Table: group.Table,
@ -1459,5 +1394,6 @@ func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error
} }
return nil, err return nil, err
} }
guo.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -13,428 +13,272 @@ import (
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.
func ID(id uuid.UUID) predicate.GroupInvitationToken { func ID(id uuid.UUID) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDEQ applies the EQ predicate on the ID field. // IDEQ applies the EQ predicate on the ID field.
func IDEQ(id uuid.UUID) predicate.GroupInvitationToken { func IDEQ(id uuid.UUID) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDNEQ applies the NEQ predicate on the ID field. // IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id uuid.UUID) predicate.GroupInvitationToken { func IDNEQ(id uuid.UUID) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldNEQ(FieldID, id))
s.Where(sql.NEQ(s.C(FieldID), id))
})
} }
// IDIn applies the In predicate on the ID field. // IDIn applies the In predicate on the ID field.
func IDIn(ids ...uuid.UUID) predicate.GroupInvitationToken { func IDIn(ids ...uuid.UUID) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.In(s.C(FieldID), v...))
})
} }
// IDNotIn applies the NotIn predicate on the ID field. // IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...uuid.UUID) predicate.GroupInvitationToken { func IDNotIn(ids ...uuid.UUID) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldNotIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.NotIn(s.C(FieldID), v...))
})
} }
// IDGT applies the GT predicate on the ID field. // IDGT applies the GT predicate on the ID field.
func IDGT(id uuid.UUID) predicate.GroupInvitationToken { func IDGT(id uuid.UUID) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldGT(FieldID, id))
s.Where(sql.GT(s.C(FieldID), id))
})
} }
// IDGTE applies the GTE predicate on the ID field. // IDGTE applies the GTE predicate on the ID field.
func IDGTE(id uuid.UUID) predicate.GroupInvitationToken { func IDGTE(id uuid.UUID) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldGTE(FieldID, id))
s.Where(sql.GTE(s.C(FieldID), id))
})
} }
// IDLT applies the LT predicate on the ID field. // IDLT applies the LT predicate on the ID field.
func IDLT(id uuid.UUID) predicate.GroupInvitationToken { func IDLT(id uuid.UUID) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldLT(FieldID, id))
s.Where(sql.LT(s.C(FieldID), id))
})
} }
// IDLTE applies the LTE predicate on the ID field. // IDLTE applies the LTE predicate on the ID field.
func IDLTE(id uuid.UUID) predicate.GroupInvitationToken { func IDLTE(id uuid.UUID) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldLTE(FieldID, id))
s.Where(sql.LTE(s.C(FieldID), id))
})
} }
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. // CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.GroupInvitationToken { func CreatedAt(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. // UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.GroupInvitationToken { func UpdatedAt(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// Token applies equality check predicate on the "token" field. It's identical to TokenEQ. // Token applies equality check predicate on the "token" field. It's identical to TokenEQ.
func Token(v []byte) predicate.GroupInvitationToken { func Token(v []byte) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldEQ(FieldToken, v))
s.Where(sql.EQ(s.C(FieldToken), v))
})
} }
// ExpiresAt applies equality check predicate on the "expires_at" field. It's identical to ExpiresAtEQ. // ExpiresAt applies equality check predicate on the "expires_at" field. It's identical to ExpiresAtEQ.
func ExpiresAt(v time.Time) predicate.GroupInvitationToken { func ExpiresAt(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldEQ(FieldExpiresAt, v))
s.Where(sql.EQ(s.C(FieldExpiresAt), v))
})
} }
// Uses applies equality check predicate on the "uses" field. It's identical to UsesEQ. // Uses applies equality check predicate on the "uses" field. It's identical to UsesEQ.
func Uses(v int) predicate.GroupInvitationToken { func Uses(v int) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldEQ(FieldUses, v))
s.Where(sql.EQ(s.C(FieldUses), v))
})
} }
// CreatedAtEQ applies the EQ predicate on the "created_at" field. // CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.GroupInvitationToken { func CreatedAtEQ(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. // CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.GroupInvitationToken { func CreatedAtNEQ(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldNEQ(FieldCreatedAt, v))
s.Where(sql.NEQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtIn applies the In predicate on the "created_at" field. // CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.GroupInvitationToken { func CreatedAtIn(vs ...time.Time) predicate.GroupInvitationToken {
v := make([]any, len(vs)) return predicate.GroupInvitationToken(sql.FieldIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.GroupInvitationToken(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. // CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.GroupInvitationToken { func CreatedAtNotIn(vs ...time.Time) predicate.GroupInvitationToken {
v := make([]any, len(vs)) return predicate.GroupInvitationToken(sql.FieldNotIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.GroupInvitationToken(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtGT applies the GT predicate on the "created_at" field. // CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.GroupInvitationToken { func CreatedAtGT(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldGT(FieldCreatedAt, v))
s.Where(sql.GT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtGTE applies the GTE predicate on the "created_at" field. // CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.GroupInvitationToken { func CreatedAtGTE(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldGTE(FieldCreatedAt, v))
s.Where(sql.GTE(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLT applies the LT predicate on the "created_at" field. // CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.GroupInvitationToken { func CreatedAtLT(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldLT(FieldCreatedAt, v))
s.Where(sql.LT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLTE applies the LTE predicate on the "created_at" field. // CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.GroupInvitationToken { func CreatedAtLTE(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldLTE(FieldCreatedAt, v))
s.Where(sql.LTE(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. // UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.GroupInvitationToken { func UpdatedAtEQ(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. // UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.GroupInvitationToken { func UpdatedAtNEQ(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldNEQ(FieldUpdatedAt, v))
s.Where(sql.NEQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtIn applies the In predicate on the "updated_at" field. // UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.GroupInvitationToken { func UpdatedAtIn(vs ...time.Time) predicate.GroupInvitationToken {
v := make([]any, len(vs)) return predicate.GroupInvitationToken(sql.FieldIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.GroupInvitationToken(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. // UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.GroupInvitationToken { func UpdatedAtNotIn(vs ...time.Time) predicate.GroupInvitationToken {
v := make([]any, len(vs)) return predicate.GroupInvitationToken(sql.FieldNotIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.GroupInvitationToken(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtGT applies the GT predicate on the "updated_at" field. // UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.GroupInvitationToken { func UpdatedAtGT(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldGT(FieldUpdatedAt, v))
s.Where(sql.GT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. // UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.GroupInvitationToken { func UpdatedAtGTE(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldGTE(FieldUpdatedAt, v))
s.Where(sql.GTE(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLT applies the LT predicate on the "updated_at" field. // UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.GroupInvitationToken { func UpdatedAtLT(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldLT(FieldUpdatedAt, v))
s.Where(sql.LT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. // UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.GroupInvitationToken { func UpdatedAtLTE(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldLTE(FieldUpdatedAt, v))
s.Where(sql.LTE(s.C(FieldUpdatedAt), v))
})
} }
// TokenEQ applies the EQ predicate on the "token" field. // TokenEQ applies the EQ predicate on the "token" field.
func TokenEQ(v []byte) predicate.GroupInvitationToken { func TokenEQ(v []byte) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldEQ(FieldToken, v))
s.Where(sql.EQ(s.C(FieldToken), v))
})
} }
// TokenNEQ applies the NEQ predicate on the "token" field. // TokenNEQ applies the NEQ predicate on the "token" field.
func TokenNEQ(v []byte) predicate.GroupInvitationToken { func TokenNEQ(v []byte) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldNEQ(FieldToken, v))
s.Where(sql.NEQ(s.C(FieldToken), v))
})
} }
// TokenIn applies the In predicate on the "token" field. // TokenIn applies the In predicate on the "token" field.
func TokenIn(vs ...[]byte) predicate.GroupInvitationToken { func TokenIn(vs ...[]byte) predicate.GroupInvitationToken {
v := make([]any, len(vs)) return predicate.GroupInvitationToken(sql.FieldIn(FieldToken, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.GroupInvitationToken(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldToken), v...))
})
} }
// TokenNotIn applies the NotIn predicate on the "token" field. // TokenNotIn applies the NotIn predicate on the "token" field.
func TokenNotIn(vs ...[]byte) predicate.GroupInvitationToken { func TokenNotIn(vs ...[]byte) predicate.GroupInvitationToken {
v := make([]any, len(vs)) return predicate.GroupInvitationToken(sql.FieldNotIn(FieldToken, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.GroupInvitationToken(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldToken), v...))
})
} }
// TokenGT applies the GT predicate on the "token" field. // TokenGT applies the GT predicate on the "token" field.
func TokenGT(v []byte) predicate.GroupInvitationToken { func TokenGT(v []byte) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldGT(FieldToken, v))
s.Where(sql.GT(s.C(FieldToken), v))
})
} }
// TokenGTE applies the GTE predicate on the "token" field. // TokenGTE applies the GTE predicate on the "token" field.
func TokenGTE(v []byte) predicate.GroupInvitationToken { func TokenGTE(v []byte) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldGTE(FieldToken, v))
s.Where(sql.GTE(s.C(FieldToken), v))
})
} }
// TokenLT applies the LT predicate on the "token" field. // TokenLT applies the LT predicate on the "token" field.
func TokenLT(v []byte) predicate.GroupInvitationToken { func TokenLT(v []byte) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldLT(FieldToken, v))
s.Where(sql.LT(s.C(FieldToken), v))
})
} }
// TokenLTE applies the LTE predicate on the "token" field. // TokenLTE applies the LTE predicate on the "token" field.
func TokenLTE(v []byte) predicate.GroupInvitationToken { func TokenLTE(v []byte) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldLTE(FieldToken, v))
s.Where(sql.LTE(s.C(FieldToken), v))
})
} }
// ExpiresAtEQ applies the EQ predicate on the "expires_at" field. // ExpiresAtEQ applies the EQ predicate on the "expires_at" field.
func ExpiresAtEQ(v time.Time) predicate.GroupInvitationToken { func ExpiresAtEQ(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldEQ(FieldExpiresAt, v))
s.Where(sql.EQ(s.C(FieldExpiresAt), v))
})
} }
// ExpiresAtNEQ applies the NEQ predicate on the "expires_at" field. // ExpiresAtNEQ applies the NEQ predicate on the "expires_at" field.
func ExpiresAtNEQ(v time.Time) predicate.GroupInvitationToken { func ExpiresAtNEQ(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldNEQ(FieldExpiresAt, v))
s.Where(sql.NEQ(s.C(FieldExpiresAt), v))
})
} }
// ExpiresAtIn applies the In predicate on the "expires_at" field. // ExpiresAtIn applies the In predicate on the "expires_at" field.
func ExpiresAtIn(vs ...time.Time) predicate.GroupInvitationToken { func ExpiresAtIn(vs ...time.Time) predicate.GroupInvitationToken {
v := make([]any, len(vs)) return predicate.GroupInvitationToken(sql.FieldIn(FieldExpiresAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.GroupInvitationToken(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldExpiresAt), v...))
})
} }
// ExpiresAtNotIn applies the NotIn predicate on the "expires_at" field. // ExpiresAtNotIn applies the NotIn predicate on the "expires_at" field.
func ExpiresAtNotIn(vs ...time.Time) predicate.GroupInvitationToken { func ExpiresAtNotIn(vs ...time.Time) predicate.GroupInvitationToken {
v := make([]any, len(vs)) return predicate.GroupInvitationToken(sql.FieldNotIn(FieldExpiresAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.GroupInvitationToken(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldExpiresAt), v...))
})
} }
// ExpiresAtGT applies the GT predicate on the "expires_at" field. // ExpiresAtGT applies the GT predicate on the "expires_at" field.
func ExpiresAtGT(v time.Time) predicate.GroupInvitationToken { func ExpiresAtGT(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldGT(FieldExpiresAt, v))
s.Where(sql.GT(s.C(FieldExpiresAt), v))
})
} }
// ExpiresAtGTE applies the GTE predicate on the "expires_at" field. // ExpiresAtGTE applies the GTE predicate on the "expires_at" field.
func ExpiresAtGTE(v time.Time) predicate.GroupInvitationToken { func ExpiresAtGTE(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldGTE(FieldExpiresAt, v))
s.Where(sql.GTE(s.C(FieldExpiresAt), v))
})
} }
// ExpiresAtLT applies the LT predicate on the "expires_at" field. // ExpiresAtLT applies the LT predicate on the "expires_at" field.
func ExpiresAtLT(v time.Time) predicate.GroupInvitationToken { func ExpiresAtLT(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldLT(FieldExpiresAt, v))
s.Where(sql.LT(s.C(FieldExpiresAt), v))
})
} }
// ExpiresAtLTE applies the LTE predicate on the "expires_at" field. // ExpiresAtLTE applies the LTE predicate on the "expires_at" field.
func ExpiresAtLTE(v time.Time) predicate.GroupInvitationToken { func ExpiresAtLTE(v time.Time) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldLTE(FieldExpiresAt, v))
s.Where(sql.LTE(s.C(FieldExpiresAt), v))
})
} }
// UsesEQ applies the EQ predicate on the "uses" field. // UsesEQ applies the EQ predicate on the "uses" field.
func UsesEQ(v int) predicate.GroupInvitationToken { func UsesEQ(v int) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldEQ(FieldUses, v))
s.Where(sql.EQ(s.C(FieldUses), v))
})
} }
// UsesNEQ applies the NEQ predicate on the "uses" field. // UsesNEQ applies the NEQ predicate on the "uses" field.
func UsesNEQ(v int) predicate.GroupInvitationToken { func UsesNEQ(v int) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldNEQ(FieldUses, v))
s.Where(sql.NEQ(s.C(FieldUses), v))
})
} }
// UsesIn applies the In predicate on the "uses" field. // UsesIn applies the In predicate on the "uses" field.
func UsesIn(vs ...int) predicate.GroupInvitationToken { func UsesIn(vs ...int) predicate.GroupInvitationToken {
v := make([]any, len(vs)) return predicate.GroupInvitationToken(sql.FieldIn(FieldUses, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.GroupInvitationToken(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldUses), v...))
})
} }
// UsesNotIn applies the NotIn predicate on the "uses" field. // UsesNotIn applies the NotIn predicate on the "uses" field.
func UsesNotIn(vs ...int) predicate.GroupInvitationToken { func UsesNotIn(vs ...int) predicate.GroupInvitationToken {
v := make([]any, len(vs)) return predicate.GroupInvitationToken(sql.FieldNotIn(FieldUses, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.GroupInvitationToken(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldUses), v...))
})
} }
// UsesGT applies the GT predicate on the "uses" field. // UsesGT applies the GT predicate on the "uses" field.
func UsesGT(v int) predicate.GroupInvitationToken { func UsesGT(v int) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldGT(FieldUses, v))
s.Where(sql.GT(s.C(FieldUses), v))
})
} }
// UsesGTE applies the GTE predicate on the "uses" field. // UsesGTE applies the GTE predicate on the "uses" field.
func UsesGTE(v int) predicate.GroupInvitationToken { func UsesGTE(v int) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldGTE(FieldUses, v))
s.Where(sql.GTE(s.C(FieldUses), v))
})
} }
// UsesLT applies the LT predicate on the "uses" field. // UsesLT applies the LT predicate on the "uses" field.
func UsesLT(v int) predicate.GroupInvitationToken { func UsesLT(v int) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldLT(FieldUses, v))
s.Where(sql.LT(s.C(FieldUses), v))
})
} }
// UsesLTE applies the LTE predicate on the "uses" field. // UsesLTE applies the LTE predicate on the "uses" field.
func UsesLTE(v int) predicate.GroupInvitationToken { func UsesLTE(v int) predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(sql.FieldLTE(FieldUses, v))
s.Where(sql.LTE(s.C(FieldUses), v))
})
} }
// HasGroup applies the HasEdge predicate on the "group" edge. // HasGroup applies the HasEdge predicate on the "group" edge.
@ -442,7 +286,6 @@ func HasGroup() predicate.GroupInvitationToken {
return predicate.GroupInvitationToken(func(s *sql.Selector) { return predicate.GroupInvitationToken(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(GroupTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn), sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)

View file

@ -124,50 +124,8 @@ func (gitc *GroupInvitationTokenCreate) Mutation() *GroupInvitationTokenMutation
// Save creates the GroupInvitationToken in the database. // Save creates the GroupInvitationToken in the database.
func (gitc *GroupInvitationTokenCreate) Save(ctx context.Context) (*GroupInvitationToken, error) { func (gitc *GroupInvitationTokenCreate) Save(ctx context.Context) (*GroupInvitationToken, error) {
var (
err error
node *GroupInvitationToken
)
gitc.defaults() gitc.defaults()
if len(gitc.hooks) == 0 { return withHooks[*GroupInvitationToken, GroupInvitationTokenMutation](ctx, gitc.sqlSave, gitc.mutation, gitc.hooks)
if err = gitc.check(); err != nil {
return nil, err
}
node, err = gitc.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*GroupInvitationTokenMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = gitc.check(); err != nil {
return nil, err
}
gitc.mutation = mutation
if node, err = gitc.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(gitc.hooks) - 1; i >= 0; i-- {
if gitc.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = gitc.hooks[i](mut)
}
v, err := mut.Mutate(ctx, gitc.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*GroupInvitationToken)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from GroupInvitationTokenMutation", v)
}
node = nv
}
return node, err
} }
// SaveX calls Save and panics if Save returns an error. // SaveX calls Save and panics if Save returns an error.
@ -237,6 +195,9 @@ func (gitc *GroupInvitationTokenCreate) check() error {
} }
func (gitc *GroupInvitationTokenCreate) sqlSave(ctx context.Context) (*GroupInvitationToken, error) { func (gitc *GroupInvitationTokenCreate) sqlSave(ctx context.Context) (*GroupInvitationToken, error) {
if err := gitc.check(); err != nil {
return nil, err
}
_node, _spec := gitc.createSpec() _node, _spec := gitc.createSpec()
if err := sqlgraph.CreateNode(ctx, gitc.driver, _spec); err != nil { if err := sqlgraph.CreateNode(ctx, gitc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) { if sqlgraph.IsConstraintError(err) {
@ -251,6 +212,8 @@ func (gitc *GroupInvitationTokenCreate) sqlSave(ctx context.Context) (*GroupInvi
return nil, err return nil, err
} }
} }
gitc.mutation.id = &_node.ID
gitc.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -4,7 +4,6 @@ package ent
import ( import (
"context" "context"
"fmt"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
@ -28,34 +27,7 @@ func (gitd *GroupInvitationTokenDelete) Where(ps ...predicate.GroupInvitationTok
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (gitd *GroupInvitationTokenDelete) Exec(ctx context.Context) (int, error) { func (gitd *GroupInvitationTokenDelete) Exec(ctx context.Context) (int, error) {
var ( return withHooks[int, GroupInvitationTokenMutation](ctx, gitd.sqlExec, gitd.mutation, gitd.hooks)
err error
affected int
)
if len(gitd.hooks) == 0 {
affected, err = gitd.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*GroupInvitationTokenMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
gitd.mutation = mutation
affected, err = gitd.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(gitd.hooks) - 1; i >= 0; i-- {
if gitd.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = gitd.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, gitd.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
@ -88,6 +60,7 @@ func (gitd *GroupInvitationTokenDelete) sqlExec(ctx context.Context) (int, error
if err != nil && sqlgraph.IsConstraintError(err) { if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
gitd.mutation.done = true
return affected, err return affected, err
} }

View file

@ -24,6 +24,7 @@ type GroupInvitationTokenQuery struct {
unique *bool unique *bool
order []OrderFunc order []OrderFunc
fields []string fields []string
inters []Interceptor
predicates []predicate.GroupInvitationToken predicates []predicate.GroupInvitationToken
withGroup *GroupQuery withGroup *GroupQuery
withFKs bool withFKs bool
@ -38,13 +39,13 @@ func (gitq *GroupInvitationTokenQuery) Where(ps ...predicate.GroupInvitationToke
return gitq return gitq
} }
// Limit adds a limit step to the query. // Limit the number of records to be returned by this query.
func (gitq *GroupInvitationTokenQuery) Limit(limit int) *GroupInvitationTokenQuery { func (gitq *GroupInvitationTokenQuery) Limit(limit int) *GroupInvitationTokenQuery {
gitq.limit = &limit gitq.limit = &limit
return gitq return gitq
} }
// Offset adds an offset step to the query. // Offset to start from.
func (gitq *GroupInvitationTokenQuery) Offset(offset int) *GroupInvitationTokenQuery { func (gitq *GroupInvitationTokenQuery) Offset(offset int) *GroupInvitationTokenQuery {
gitq.offset = &offset gitq.offset = &offset
return gitq return gitq
@ -57,7 +58,7 @@ func (gitq *GroupInvitationTokenQuery) Unique(unique bool) *GroupInvitationToken
return gitq return gitq
} }
// Order adds an order step to the query. // Order specifies how the records should be ordered.
func (gitq *GroupInvitationTokenQuery) Order(o ...OrderFunc) *GroupInvitationTokenQuery { func (gitq *GroupInvitationTokenQuery) Order(o ...OrderFunc) *GroupInvitationTokenQuery {
gitq.order = append(gitq.order, o...) gitq.order = append(gitq.order, o...)
return gitq return gitq
@ -65,7 +66,7 @@ func (gitq *GroupInvitationTokenQuery) Order(o ...OrderFunc) *GroupInvitationTok
// QueryGroup chains the current query on the "group" edge. // QueryGroup chains the current query on the "group" edge.
func (gitq *GroupInvitationTokenQuery) QueryGroup() *GroupQuery { func (gitq *GroupInvitationTokenQuery) QueryGroup() *GroupQuery {
query := &GroupQuery{config: gitq.config} query := (&GroupClient{config: gitq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := gitq.prepareQuery(ctx); err != nil { if err := gitq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -88,7 +89,7 @@ func (gitq *GroupInvitationTokenQuery) QueryGroup() *GroupQuery {
// First returns the first GroupInvitationToken entity from the query. // First returns the first GroupInvitationToken entity from the query.
// Returns a *NotFoundError when no GroupInvitationToken was found. // Returns a *NotFoundError when no GroupInvitationToken was found.
func (gitq *GroupInvitationTokenQuery) First(ctx context.Context) (*GroupInvitationToken, error) { func (gitq *GroupInvitationTokenQuery) First(ctx context.Context) (*GroupInvitationToken, error) {
nodes, err := gitq.Limit(1).All(ctx) nodes, err := gitq.Limit(1).All(newQueryContext(ctx, TypeGroupInvitationToken, "First"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -111,7 +112,7 @@ func (gitq *GroupInvitationTokenQuery) FirstX(ctx context.Context) *GroupInvitat
// Returns a *NotFoundError when no GroupInvitationToken ID was found. // Returns a *NotFoundError when no GroupInvitationToken ID was found.
func (gitq *GroupInvitationTokenQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { func (gitq *GroupInvitationTokenQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = gitq.Limit(1).IDs(ctx); err != nil { if ids, err = gitq.Limit(1).IDs(newQueryContext(ctx, TypeGroupInvitationToken, "FirstID")); err != nil {
return return
} }
if len(ids) == 0 { if len(ids) == 0 {
@ -134,7 +135,7 @@ func (gitq *GroupInvitationTokenQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one GroupInvitationToken entity is found. // Returns a *NotSingularError when more than one GroupInvitationToken entity is found.
// Returns a *NotFoundError when no GroupInvitationToken entities are found. // Returns a *NotFoundError when no GroupInvitationToken entities are found.
func (gitq *GroupInvitationTokenQuery) Only(ctx context.Context) (*GroupInvitationToken, error) { func (gitq *GroupInvitationTokenQuery) Only(ctx context.Context) (*GroupInvitationToken, error) {
nodes, err := gitq.Limit(2).All(ctx) nodes, err := gitq.Limit(2).All(newQueryContext(ctx, TypeGroupInvitationToken, "Only"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -162,7 +163,7 @@ func (gitq *GroupInvitationTokenQuery) OnlyX(ctx context.Context) *GroupInvitati
// Returns a *NotFoundError when no entities are found. // Returns a *NotFoundError when no entities are found.
func (gitq *GroupInvitationTokenQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { func (gitq *GroupInvitationTokenQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = gitq.Limit(2).IDs(ctx); err != nil { if ids, err = gitq.Limit(2).IDs(newQueryContext(ctx, TypeGroupInvitationToken, "OnlyID")); err != nil {
return return
} }
switch len(ids) { switch len(ids) {
@ -187,10 +188,12 @@ func (gitq *GroupInvitationTokenQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of GroupInvitationTokens. // All executes the query and returns a list of GroupInvitationTokens.
func (gitq *GroupInvitationTokenQuery) All(ctx context.Context) ([]*GroupInvitationToken, error) { func (gitq *GroupInvitationTokenQuery) All(ctx context.Context) ([]*GroupInvitationToken, error) {
ctx = newQueryContext(ctx, TypeGroupInvitationToken, "All")
if err := gitq.prepareQuery(ctx); err != nil { if err := gitq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return gitq.sqlAll(ctx) qr := querierAll[[]*GroupInvitationToken, *GroupInvitationTokenQuery]()
return withInterceptors[[]*GroupInvitationToken](ctx, gitq, qr, gitq.inters)
} }
// AllX is like All, but panics if an error occurs. // AllX is like All, but panics if an error occurs.
@ -205,6 +208,7 @@ func (gitq *GroupInvitationTokenQuery) AllX(ctx context.Context) []*GroupInvitat
// IDs executes the query and returns a list of GroupInvitationToken IDs. // IDs executes the query and returns a list of GroupInvitationToken IDs.
func (gitq *GroupInvitationTokenQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (gitq *GroupInvitationTokenQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID var ids []uuid.UUID
ctx = newQueryContext(ctx, TypeGroupInvitationToken, "IDs")
if err := gitq.Select(groupinvitationtoken.FieldID).Scan(ctx, &ids); err != nil { if err := gitq.Select(groupinvitationtoken.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
@ -222,10 +226,11 @@ func (gitq *GroupInvitationTokenQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query. // Count returns the count of the given query.
func (gitq *GroupInvitationTokenQuery) Count(ctx context.Context) (int, error) { func (gitq *GroupInvitationTokenQuery) Count(ctx context.Context) (int, error) {
ctx = newQueryContext(ctx, TypeGroupInvitationToken, "Count")
if err := gitq.prepareQuery(ctx); err != nil { if err := gitq.prepareQuery(ctx); err != nil {
return 0, err return 0, err
} }
return gitq.sqlCount(ctx) return withInterceptors[int](ctx, gitq, querierCount[*GroupInvitationTokenQuery](), gitq.inters)
} }
// CountX is like Count, but panics if an error occurs. // CountX is like Count, but panics if an error occurs.
@ -239,10 +244,15 @@ func (gitq *GroupInvitationTokenQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph. // Exist returns true if the query has elements in the graph.
func (gitq *GroupInvitationTokenQuery) Exist(ctx context.Context) (bool, error) { func (gitq *GroupInvitationTokenQuery) Exist(ctx context.Context) (bool, error) {
if err := gitq.prepareQuery(ctx); err != nil { ctx = newQueryContext(ctx, TypeGroupInvitationToken, "Exist")
return false, err switch _, err := gitq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
} }
return gitq.sqlExist(ctx)
} }
// ExistX is like Exist, but panics if an error occurs. // ExistX is like Exist, but panics if an error occurs.
@ -265,6 +275,7 @@ func (gitq *GroupInvitationTokenQuery) Clone() *GroupInvitationTokenQuery {
limit: gitq.limit, limit: gitq.limit,
offset: gitq.offset, offset: gitq.offset,
order: append([]OrderFunc{}, gitq.order...), order: append([]OrderFunc{}, gitq.order...),
inters: append([]Interceptor{}, gitq.inters...),
predicates: append([]predicate.GroupInvitationToken{}, gitq.predicates...), predicates: append([]predicate.GroupInvitationToken{}, gitq.predicates...),
withGroup: gitq.withGroup.Clone(), withGroup: gitq.withGroup.Clone(),
// clone intermediate query. // clone intermediate query.
@ -277,7 +288,7 @@ func (gitq *GroupInvitationTokenQuery) Clone() *GroupInvitationTokenQuery {
// WithGroup tells the query-builder to eager-load the nodes that are connected to // WithGroup tells the query-builder to eager-load the nodes that are connected to
// the "group" edge. The optional arguments are used to configure the query builder of the edge. // the "group" edge. The optional arguments are used to configure the query builder of the edge.
func (gitq *GroupInvitationTokenQuery) WithGroup(opts ...func(*GroupQuery)) *GroupInvitationTokenQuery { func (gitq *GroupInvitationTokenQuery) WithGroup(opts ...func(*GroupQuery)) *GroupInvitationTokenQuery {
query := &GroupQuery{config: gitq.config} query := (&GroupClient{config: gitq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -300,16 +311,11 @@ func (gitq *GroupInvitationTokenQuery) WithGroup(opts ...func(*GroupQuery)) *Gro
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (gitq *GroupInvitationTokenQuery) GroupBy(field string, fields ...string) *GroupInvitationTokenGroupBy { func (gitq *GroupInvitationTokenQuery) GroupBy(field string, fields ...string) *GroupInvitationTokenGroupBy {
grbuild := &GroupInvitationTokenGroupBy{config: gitq.config} gitq.fields = append([]string{field}, fields...)
grbuild.fields = append([]string{field}, fields...) grbuild := &GroupInvitationTokenGroupBy{build: gitq}
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { grbuild.flds = &gitq.fields
if err := gitq.prepareQuery(ctx); err != nil {
return nil, err
}
return gitq.sqlQuery(ctx), nil
}
grbuild.label = groupinvitationtoken.Label grbuild.label = groupinvitationtoken.Label
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan grbuild.scan = grbuild.Scan
return grbuild return grbuild
} }
@ -327,10 +333,10 @@ func (gitq *GroupInvitationTokenQuery) GroupBy(field string, fields ...string) *
// Scan(ctx, &v) // Scan(ctx, &v)
func (gitq *GroupInvitationTokenQuery) Select(fields ...string) *GroupInvitationTokenSelect { func (gitq *GroupInvitationTokenQuery) Select(fields ...string) *GroupInvitationTokenSelect {
gitq.fields = append(gitq.fields, fields...) gitq.fields = append(gitq.fields, fields...)
selbuild := &GroupInvitationTokenSelect{GroupInvitationTokenQuery: gitq} sbuild := &GroupInvitationTokenSelect{GroupInvitationTokenQuery: gitq}
selbuild.label = groupinvitationtoken.Label sbuild.label = groupinvitationtoken.Label
selbuild.flds, selbuild.scan = &gitq.fields, selbuild.Scan sbuild.flds, sbuild.scan = &gitq.fields, sbuild.Scan
return selbuild return sbuild
} }
// Aggregate returns a GroupInvitationTokenSelect configured with the given aggregations. // Aggregate returns a GroupInvitationTokenSelect configured with the given aggregations.
@ -339,6 +345,16 @@ func (gitq *GroupInvitationTokenQuery) Aggregate(fns ...AggregateFunc) *GroupInv
} }
func (gitq *GroupInvitationTokenQuery) prepareQuery(ctx context.Context) error { func (gitq *GroupInvitationTokenQuery) prepareQuery(ctx context.Context) error {
for _, inter := range gitq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, gitq); err != nil {
return err
}
}
}
for _, f := range gitq.fields { for _, f := range gitq.fields {
if !groupinvitationtoken.ValidColumn(f) { if !groupinvitationtoken.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
@ -435,17 +451,6 @@ func (gitq *GroupInvitationTokenQuery) sqlCount(ctx context.Context) (int, error
return sqlgraph.CountNodes(ctx, gitq.driver, _spec) return sqlgraph.CountNodes(ctx, gitq.driver, _spec)
} }
func (gitq *GroupInvitationTokenQuery) sqlExist(ctx context.Context) (bool, error) {
switch _, err := gitq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
func (gitq *GroupInvitationTokenQuery) querySpec() *sqlgraph.QuerySpec { func (gitq *GroupInvitationTokenQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
@ -528,13 +533,8 @@ func (gitq *GroupInvitationTokenQuery) sqlQuery(ctx context.Context) *sql.Select
// GroupInvitationTokenGroupBy is the group-by builder for GroupInvitationToken entities. // GroupInvitationTokenGroupBy is the group-by builder for GroupInvitationToken entities.
type GroupInvitationTokenGroupBy struct { type GroupInvitationTokenGroupBy struct {
config
selector selector
fields []string build *GroupInvitationTokenQuery
fns []AggregateFunc
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
} }
// Aggregate adds the given aggregation functions to the group-by query. // Aggregate adds the given aggregation functions to the group-by query.
@ -543,58 +543,46 @@ func (gitgb *GroupInvitationTokenGroupBy) Aggregate(fns ...AggregateFunc) *Group
return gitgb return gitgb
} }
// Scan applies the group-by query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (gitgb *GroupInvitationTokenGroupBy) Scan(ctx context.Context, v any) error { func (gitgb *GroupInvitationTokenGroupBy) Scan(ctx context.Context, v any) error {
query, err := gitgb.path(ctx) ctx = newQueryContext(ctx, TypeGroupInvitationToken, "GroupBy")
if err != nil { if err := gitgb.build.prepareQuery(ctx); err != nil {
return err return err
} }
gitgb.sql = query return scanWithInterceptors[*GroupInvitationTokenQuery, *GroupInvitationTokenGroupBy](ctx, gitgb.build, gitgb, gitgb.build.inters, v)
return gitgb.sqlScan(ctx, v)
} }
func (gitgb *GroupInvitationTokenGroupBy) sqlScan(ctx context.Context, v any) error { func (gitgb *GroupInvitationTokenGroupBy) sqlScan(ctx context.Context, root *GroupInvitationTokenQuery, v any) error {
for _, f := range gitgb.fields { selector := root.sqlQuery(ctx).Select()
if !groupinvitationtoken.ValidColumn(f) { aggregation := make([]string, 0, len(gitgb.fns))
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} for _, fn := range gitgb.fns {
} aggregation = append(aggregation, fn(selector))
} }
selector := gitgb.sqlQuery() if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*gitgb.flds)+len(gitgb.fns))
for _, f := range *gitgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*gitgb.flds...)...)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return err return err
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() query, args := selector.Query()
if err := gitgb.driver.Query(ctx, query, args, rows); err != nil { if err := gitgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }
defer rows.Close() defer rows.Close()
return sql.ScanSlice(rows, v) return sql.ScanSlice(rows, v)
} }
func (gitgb *GroupInvitationTokenGroupBy) sqlQuery() *sql.Selector {
selector := gitgb.sql.Select()
aggregation := make([]string, 0, len(gitgb.fns))
for _, fn := range gitgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(gitgb.fields)+len(gitgb.fns))
for _, f := range gitgb.fields {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
return selector.GroupBy(selector.Columns(gitgb.fields...)...)
}
// GroupInvitationTokenSelect is the builder for selecting fields of GroupInvitationToken entities. // GroupInvitationTokenSelect is the builder for selecting fields of GroupInvitationToken entities.
type GroupInvitationTokenSelect struct { type GroupInvitationTokenSelect struct {
*GroupInvitationTokenQuery *GroupInvitationTokenQuery
selector selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
@ -605,26 +593,27 @@ func (gits *GroupInvitationTokenSelect) Aggregate(fns ...AggregateFunc) *GroupIn
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (gits *GroupInvitationTokenSelect) Scan(ctx context.Context, v any) error { func (gits *GroupInvitationTokenSelect) Scan(ctx context.Context, v any) error {
ctx = newQueryContext(ctx, TypeGroupInvitationToken, "Select")
if err := gits.prepareQuery(ctx); err != nil { if err := gits.prepareQuery(ctx); err != nil {
return err return err
} }
gits.sql = gits.GroupInvitationTokenQuery.sqlQuery(ctx) return scanWithInterceptors[*GroupInvitationTokenQuery, *GroupInvitationTokenSelect](ctx, gits.GroupInvitationTokenQuery, gits, gits.inters, v)
return gits.sqlScan(ctx, v)
} }
func (gits *GroupInvitationTokenSelect) sqlScan(ctx context.Context, v any) error { func (gits *GroupInvitationTokenSelect) sqlScan(ctx context.Context, root *GroupInvitationTokenQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(gits.fns)) aggregation := make([]string, 0, len(gits.fns))
for _, fn := range gits.fns { for _, fn := range gits.fns {
aggregation = append(aggregation, fn(gits.sql)) aggregation = append(aggregation, fn(selector))
} }
switch n := len(*gits.selector.flds); { switch n := len(*gits.selector.flds); {
case n == 0 && len(aggregation) > 0: case n == 0 && len(aggregation) > 0:
gits.sql.Select(aggregation...) selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0: case n != 0 && len(aggregation) > 0:
gits.sql.AppendSelect(aggregation...) selector.AppendSelect(aggregation...)
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := gits.sql.Query() query, args := selector.Query()
if err := gits.driver.Query(ctx, query, args, rows); err != nil { if err := gits.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }

View file

@ -109,35 +109,8 @@ func (gitu *GroupInvitationTokenUpdate) ClearGroup() *GroupInvitationTokenUpdate
// Save executes the query and returns the number of nodes affected by the update operation. // Save executes the query and returns the number of nodes affected by the update operation.
func (gitu *GroupInvitationTokenUpdate) Save(ctx context.Context) (int, error) { func (gitu *GroupInvitationTokenUpdate) Save(ctx context.Context) (int, error) {
var (
err error
affected int
)
gitu.defaults() gitu.defaults()
if len(gitu.hooks) == 0 { return withHooks[int, GroupInvitationTokenMutation](ctx, gitu.sqlSave, gitu.mutation, gitu.hooks)
affected, err = gitu.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*GroupInvitationTokenMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
gitu.mutation = mutation
affected, err = gitu.sqlSave(ctx)
mutation.done = true
return affected, err
})
for i := len(gitu.hooks) - 1; i >= 0; i-- {
if gitu.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = gitu.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, gitu.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -246,6 +219,7 @@ func (gitu *GroupInvitationTokenUpdate) sqlSave(ctx context.Context) (n int, err
} }
return 0, err return 0, err
} }
gitu.mutation.done = true
return n, nil return n, nil
} }
@ -343,41 +317,8 @@ func (gituo *GroupInvitationTokenUpdateOne) Select(field string, fields ...strin
// Save executes the query and returns the updated GroupInvitationToken entity. // Save executes the query and returns the updated GroupInvitationToken entity.
func (gituo *GroupInvitationTokenUpdateOne) Save(ctx context.Context) (*GroupInvitationToken, error) { func (gituo *GroupInvitationTokenUpdateOne) Save(ctx context.Context) (*GroupInvitationToken, error) {
var (
err error
node *GroupInvitationToken
)
gituo.defaults() gituo.defaults()
if len(gituo.hooks) == 0 { return withHooks[*GroupInvitationToken, GroupInvitationTokenMutation](ctx, gituo.sqlSave, gituo.mutation, gituo.hooks)
node, err = gituo.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*GroupInvitationTokenMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
gituo.mutation = mutation
node, err = gituo.sqlSave(ctx)
mutation.done = true
return node, err
})
for i := len(gituo.hooks) - 1; i >= 0; i-- {
if gituo.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = gituo.hooks[i](mut)
}
v, err := mut.Mutate(ctx, gituo.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*GroupInvitationToken)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from GroupInvitationTokenMutation", v)
}
node = nv
}
return node, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -506,5 +447,6 @@ func (gituo *GroupInvitationTokenUpdateOne) sqlSave(ctx context.Context) (_node
} }
return nil, err return nil, err
} }
gituo.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -15,11 +15,10 @@ type AttachmentFunc func(context.Context, *ent.AttachmentMutation) (ent.Value, e
// Mutate calls f(ctx, m). // Mutate calls f(ctx, m).
func (f AttachmentFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { func (f AttachmentFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.AttachmentMutation) if mv, ok := m.(*ent.AttachmentMutation); ok {
if !ok { return f(ctx, mv)
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AttachmentMutation", m)
} }
return f(ctx, mv) return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AttachmentMutation", m)
} }
// The AuthRolesFunc type is an adapter to allow the use of ordinary // The AuthRolesFunc type is an adapter to allow the use of ordinary
@ -28,11 +27,10 @@ type AuthRolesFunc func(context.Context, *ent.AuthRolesMutation) (ent.Value, err
// Mutate calls f(ctx, m). // Mutate calls f(ctx, m).
func (f AuthRolesFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { func (f AuthRolesFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.AuthRolesMutation) if mv, ok := m.(*ent.AuthRolesMutation); ok {
if !ok { return f(ctx, mv)
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AuthRolesMutation", m)
} }
return f(ctx, mv) return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AuthRolesMutation", m)
} }
// The AuthTokensFunc type is an adapter to allow the use of ordinary // The AuthTokensFunc type is an adapter to allow the use of ordinary
@ -41,11 +39,10 @@ type AuthTokensFunc func(context.Context, *ent.AuthTokensMutation) (ent.Value, e
// Mutate calls f(ctx, m). // Mutate calls f(ctx, m).
func (f AuthTokensFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { func (f AuthTokensFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.AuthTokensMutation) if mv, ok := m.(*ent.AuthTokensMutation); ok {
if !ok { return f(ctx, mv)
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AuthTokensMutation", m)
} }
return f(ctx, mv) return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AuthTokensMutation", m)
} }
// The DocumentFunc type is an adapter to allow the use of ordinary // The DocumentFunc type is an adapter to allow the use of ordinary
@ -54,11 +51,10 @@ type DocumentFunc func(context.Context, *ent.DocumentMutation) (ent.Value, error
// Mutate calls f(ctx, m). // Mutate calls f(ctx, m).
func (f DocumentFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { func (f DocumentFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.DocumentMutation) if mv, ok := m.(*ent.DocumentMutation); ok {
if !ok { return f(ctx, mv)
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.DocumentMutation", m)
} }
return f(ctx, mv) return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.DocumentMutation", m)
} }
// The GroupFunc type is an adapter to allow the use of ordinary // The GroupFunc type is an adapter to allow the use of ordinary
@ -67,11 +63,10 @@ type GroupFunc func(context.Context, *ent.GroupMutation) (ent.Value, error)
// Mutate calls f(ctx, m). // Mutate calls f(ctx, m).
func (f GroupFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { func (f GroupFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.GroupMutation) if mv, ok := m.(*ent.GroupMutation); ok {
if !ok { return f(ctx, mv)
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.GroupMutation", m)
} }
return f(ctx, mv) return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.GroupMutation", m)
} }
// The GroupInvitationTokenFunc type is an adapter to allow the use of ordinary // The GroupInvitationTokenFunc type is an adapter to allow the use of ordinary
@ -80,11 +75,10 @@ type GroupInvitationTokenFunc func(context.Context, *ent.GroupInvitationTokenMut
// Mutate calls f(ctx, m). // Mutate calls f(ctx, m).
func (f GroupInvitationTokenFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { func (f GroupInvitationTokenFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.GroupInvitationTokenMutation) if mv, ok := m.(*ent.GroupInvitationTokenMutation); ok {
if !ok { return f(ctx, mv)
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.GroupInvitationTokenMutation", m)
} }
return f(ctx, mv) return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.GroupInvitationTokenMutation", m)
} }
// The ItemFunc type is an adapter to allow the use of ordinary // The ItemFunc type is an adapter to allow the use of ordinary
@ -93,11 +87,10 @@ type ItemFunc func(context.Context, *ent.ItemMutation) (ent.Value, error)
// Mutate calls f(ctx, m). // Mutate calls f(ctx, m).
func (f ItemFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { func (f ItemFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.ItemMutation) if mv, ok := m.(*ent.ItemMutation); ok {
if !ok { return f(ctx, mv)
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ItemMutation", m)
} }
return f(ctx, mv) return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ItemMutation", m)
} }
// The ItemFieldFunc type is an adapter to allow the use of ordinary // The ItemFieldFunc type is an adapter to allow the use of ordinary
@ -106,11 +99,10 @@ type ItemFieldFunc func(context.Context, *ent.ItemFieldMutation) (ent.Value, err
// Mutate calls f(ctx, m). // Mutate calls f(ctx, m).
func (f ItemFieldFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { func (f ItemFieldFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.ItemFieldMutation) if mv, ok := m.(*ent.ItemFieldMutation); ok {
if !ok { return f(ctx, mv)
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ItemFieldMutation", m)
} }
return f(ctx, mv) return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ItemFieldMutation", m)
} }
// The LabelFunc type is an adapter to allow the use of ordinary // The LabelFunc type is an adapter to allow the use of ordinary
@ -119,11 +111,10 @@ type LabelFunc func(context.Context, *ent.LabelMutation) (ent.Value, error)
// Mutate calls f(ctx, m). // Mutate calls f(ctx, m).
func (f LabelFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { func (f LabelFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.LabelMutation) if mv, ok := m.(*ent.LabelMutation); ok {
if !ok { return f(ctx, mv)
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.LabelMutation", m)
} }
return f(ctx, mv) return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.LabelMutation", m)
} }
// The LocationFunc type is an adapter to allow the use of ordinary // The LocationFunc type is an adapter to allow the use of ordinary
@ -132,11 +123,10 @@ type LocationFunc func(context.Context, *ent.LocationMutation) (ent.Value, error
// Mutate calls f(ctx, m). // Mutate calls f(ctx, m).
func (f LocationFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { func (f LocationFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.LocationMutation) if mv, ok := m.(*ent.LocationMutation); ok {
if !ok { return f(ctx, mv)
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.LocationMutation", m)
} }
return f(ctx, mv) return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.LocationMutation", m)
} }
// The MaintenanceEntryFunc type is an adapter to allow the use of ordinary // The MaintenanceEntryFunc type is an adapter to allow the use of ordinary
@ -145,11 +135,10 @@ type MaintenanceEntryFunc func(context.Context, *ent.MaintenanceEntryMutation) (
// Mutate calls f(ctx, m). // Mutate calls f(ctx, m).
func (f MaintenanceEntryFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { func (f MaintenanceEntryFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.MaintenanceEntryMutation) if mv, ok := m.(*ent.MaintenanceEntryMutation); ok {
if !ok { return f(ctx, mv)
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MaintenanceEntryMutation", m)
} }
return f(ctx, mv) return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MaintenanceEntryMutation", m)
} }
// The UserFunc type is an adapter to allow the use of ordinary // The UserFunc type is an adapter to allow the use of ordinary
@ -158,11 +147,10 @@ type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error)
// Mutate calls f(ctx, m). // Mutate calls f(ctx, m).
func (f UserFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { func (f UserFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.UserMutation) if mv, ok := m.(*ent.UserMutation); ok {
if !ok { return f(ctx, mv)
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserMutation", m)
} }
return f(ctx, mv) return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserMutation", m)
} }
// Condition is a hook condition function. // Condition is a hook condition function.

File diff suppressed because it is too large Load diff

View file

@ -486,50 +486,8 @@ func (ic *ItemCreate) Mutation() *ItemMutation {
// Save creates the Item in the database. // Save creates the Item in the database.
func (ic *ItemCreate) Save(ctx context.Context) (*Item, error) { func (ic *ItemCreate) Save(ctx context.Context) (*Item, error) {
var (
err error
node *Item
)
ic.defaults() ic.defaults()
if len(ic.hooks) == 0 { return withHooks[*Item, ItemMutation](ctx, ic.sqlSave, ic.mutation, ic.hooks)
if err = ic.check(); err != nil {
return nil, err
}
node, err = ic.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ItemMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = ic.check(); err != nil {
return nil, err
}
ic.mutation = mutation
if node, err = ic.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(ic.hooks) - 1; i >= 0; i-- {
if ic.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = ic.hooks[i](mut)
}
v, err := mut.Mutate(ctx, ic.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Item)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from ItemMutation", v)
}
node = nv
}
return node, err
} }
// SaveX calls Save and panics if Save returns an error. // SaveX calls Save and panics if Save returns an error.
@ -682,6 +640,9 @@ func (ic *ItemCreate) check() error {
} }
func (ic *ItemCreate) sqlSave(ctx context.Context) (*Item, error) { func (ic *ItemCreate) sqlSave(ctx context.Context) (*Item, error) {
if err := ic.check(); err != nil {
return nil, err
}
_node, _spec := ic.createSpec() _node, _spec := ic.createSpec()
if err := sqlgraph.CreateNode(ctx, ic.driver, _spec); err != nil { if err := sqlgraph.CreateNode(ctx, ic.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) { if sqlgraph.IsConstraintError(err) {
@ -696,6 +657,8 @@ func (ic *ItemCreate) sqlSave(ctx context.Context) (*Item, error) {
return nil, err return nil, err
} }
} }
ic.mutation.id = &_node.ID
ic.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -4,7 +4,6 @@ package ent
import ( import (
"context" "context"
"fmt"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
@ -28,34 +27,7 @@ func (id *ItemDelete) Where(ps ...predicate.Item) *ItemDelete {
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (id *ItemDelete) Exec(ctx context.Context) (int, error) { func (id *ItemDelete) Exec(ctx context.Context) (int, error) {
var ( return withHooks[int, ItemMutation](ctx, id.sqlExec, id.mutation, id.hooks)
err error
affected int
)
if len(id.hooks) == 0 {
affected, err = id.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ItemMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
id.mutation = mutation
affected, err = id.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(id.hooks) - 1; i >= 0; i-- {
if id.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = id.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, id.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
@ -88,6 +60,7 @@ func (id *ItemDelete) sqlExec(ctx context.Context) (int, error) {
if err != nil && sqlgraph.IsConstraintError(err) { if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
id.mutation.done = true
return affected, err return affected, err
} }

View file

@ -30,6 +30,7 @@ type ItemQuery struct {
unique *bool unique *bool
order []OrderFunc order []OrderFunc
fields []string fields []string
inters []Interceptor
predicates []predicate.Item predicates []predicate.Item
withParent *ItemQuery withParent *ItemQuery
withChildren *ItemQuery withChildren *ItemQuery
@ -51,13 +52,13 @@ func (iq *ItemQuery) Where(ps ...predicate.Item) *ItemQuery {
return iq return iq
} }
// Limit adds a limit step to the query. // Limit the number of records to be returned by this query.
func (iq *ItemQuery) Limit(limit int) *ItemQuery { func (iq *ItemQuery) Limit(limit int) *ItemQuery {
iq.limit = &limit iq.limit = &limit
return iq return iq
} }
// Offset adds an offset step to the query. // Offset to start from.
func (iq *ItemQuery) Offset(offset int) *ItemQuery { func (iq *ItemQuery) Offset(offset int) *ItemQuery {
iq.offset = &offset iq.offset = &offset
return iq return iq
@ -70,7 +71,7 @@ func (iq *ItemQuery) Unique(unique bool) *ItemQuery {
return iq return iq
} }
// Order adds an order step to the query. // Order specifies how the records should be ordered.
func (iq *ItemQuery) Order(o ...OrderFunc) *ItemQuery { func (iq *ItemQuery) Order(o ...OrderFunc) *ItemQuery {
iq.order = append(iq.order, o...) iq.order = append(iq.order, o...)
return iq return iq
@ -78,7 +79,7 @@ func (iq *ItemQuery) Order(o ...OrderFunc) *ItemQuery {
// QueryParent chains the current query on the "parent" edge. // QueryParent chains the current query on the "parent" edge.
func (iq *ItemQuery) QueryParent() *ItemQuery { func (iq *ItemQuery) QueryParent() *ItemQuery {
query := &ItemQuery{config: iq.config} query := (&ItemClient{config: iq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := iq.prepareQuery(ctx); err != nil { if err := iq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -100,7 +101,7 @@ func (iq *ItemQuery) QueryParent() *ItemQuery {
// QueryChildren chains the current query on the "children" edge. // QueryChildren chains the current query on the "children" edge.
func (iq *ItemQuery) QueryChildren() *ItemQuery { func (iq *ItemQuery) QueryChildren() *ItemQuery {
query := &ItemQuery{config: iq.config} query := (&ItemClient{config: iq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := iq.prepareQuery(ctx); err != nil { if err := iq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -122,7 +123,7 @@ func (iq *ItemQuery) QueryChildren() *ItemQuery {
// QueryGroup chains the current query on the "group" edge. // QueryGroup chains the current query on the "group" edge.
func (iq *ItemQuery) QueryGroup() *GroupQuery { func (iq *ItemQuery) QueryGroup() *GroupQuery {
query := &GroupQuery{config: iq.config} query := (&GroupClient{config: iq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := iq.prepareQuery(ctx); err != nil { if err := iq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -144,7 +145,7 @@ func (iq *ItemQuery) QueryGroup() *GroupQuery {
// QueryLabel chains the current query on the "label" edge. // QueryLabel chains the current query on the "label" edge.
func (iq *ItemQuery) QueryLabel() *LabelQuery { func (iq *ItemQuery) QueryLabel() *LabelQuery {
query := &LabelQuery{config: iq.config} query := (&LabelClient{config: iq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := iq.prepareQuery(ctx); err != nil { if err := iq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -166,7 +167,7 @@ func (iq *ItemQuery) QueryLabel() *LabelQuery {
// QueryLocation chains the current query on the "location" edge. // QueryLocation chains the current query on the "location" edge.
func (iq *ItemQuery) QueryLocation() *LocationQuery { func (iq *ItemQuery) QueryLocation() *LocationQuery {
query := &LocationQuery{config: iq.config} query := (&LocationClient{config: iq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := iq.prepareQuery(ctx); err != nil { if err := iq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -188,7 +189,7 @@ func (iq *ItemQuery) QueryLocation() *LocationQuery {
// QueryFields chains the current query on the "fields" edge. // QueryFields chains the current query on the "fields" edge.
func (iq *ItemQuery) QueryFields() *ItemFieldQuery { func (iq *ItemQuery) QueryFields() *ItemFieldQuery {
query := &ItemFieldQuery{config: iq.config} query := (&ItemFieldClient{config: iq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := iq.prepareQuery(ctx); err != nil { if err := iq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -210,7 +211,7 @@ func (iq *ItemQuery) QueryFields() *ItemFieldQuery {
// QueryMaintenanceEntries chains the current query on the "maintenance_entries" edge. // QueryMaintenanceEntries chains the current query on the "maintenance_entries" edge.
func (iq *ItemQuery) QueryMaintenanceEntries() *MaintenanceEntryQuery { func (iq *ItemQuery) QueryMaintenanceEntries() *MaintenanceEntryQuery {
query := &MaintenanceEntryQuery{config: iq.config} query := (&MaintenanceEntryClient{config: iq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := iq.prepareQuery(ctx); err != nil { if err := iq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -232,7 +233,7 @@ func (iq *ItemQuery) QueryMaintenanceEntries() *MaintenanceEntryQuery {
// QueryAttachments chains the current query on the "attachments" edge. // QueryAttachments chains the current query on the "attachments" edge.
func (iq *ItemQuery) QueryAttachments() *AttachmentQuery { func (iq *ItemQuery) QueryAttachments() *AttachmentQuery {
query := &AttachmentQuery{config: iq.config} query := (&AttachmentClient{config: iq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := iq.prepareQuery(ctx); err != nil { if err := iq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -255,7 +256,7 @@ func (iq *ItemQuery) QueryAttachments() *AttachmentQuery {
// First returns the first Item entity from the query. // First returns the first Item entity from the query.
// Returns a *NotFoundError when no Item was found. // Returns a *NotFoundError when no Item was found.
func (iq *ItemQuery) First(ctx context.Context) (*Item, error) { func (iq *ItemQuery) First(ctx context.Context) (*Item, error) {
nodes, err := iq.Limit(1).All(ctx) nodes, err := iq.Limit(1).All(newQueryContext(ctx, TypeItem, "First"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -278,7 +279,7 @@ func (iq *ItemQuery) FirstX(ctx context.Context) *Item {
// Returns a *NotFoundError when no Item ID was found. // Returns a *NotFoundError when no Item ID was found.
func (iq *ItemQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { func (iq *ItemQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = iq.Limit(1).IDs(ctx); err != nil { if ids, err = iq.Limit(1).IDs(newQueryContext(ctx, TypeItem, "FirstID")); err != nil {
return return
} }
if len(ids) == 0 { if len(ids) == 0 {
@ -301,7 +302,7 @@ func (iq *ItemQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one Item entity is found. // Returns a *NotSingularError when more than one Item entity is found.
// Returns a *NotFoundError when no Item entities are found. // Returns a *NotFoundError when no Item entities are found.
func (iq *ItemQuery) Only(ctx context.Context) (*Item, error) { func (iq *ItemQuery) Only(ctx context.Context) (*Item, error) {
nodes, err := iq.Limit(2).All(ctx) nodes, err := iq.Limit(2).All(newQueryContext(ctx, TypeItem, "Only"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -329,7 +330,7 @@ func (iq *ItemQuery) OnlyX(ctx context.Context) *Item {
// Returns a *NotFoundError when no entities are found. // Returns a *NotFoundError when no entities are found.
func (iq *ItemQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { func (iq *ItemQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = iq.Limit(2).IDs(ctx); err != nil { if ids, err = iq.Limit(2).IDs(newQueryContext(ctx, TypeItem, "OnlyID")); err != nil {
return return
} }
switch len(ids) { switch len(ids) {
@ -354,10 +355,12 @@ func (iq *ItemQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of Items. // All executes the query and returns a list of Items.
func (iq *ItemQuery) All(ctx context.Context) ([]*Item, error) { func (iq *ItemQuery) All(ctx context.Context) ([]*Item, error) {
ctx = newQueryContext(ctx, TypeItem, "All")
if err := iq.prepareQuery(ctx); err != nil { if err := iq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return iq.sqlAll(ctx) qr := querierAll[[]*Item, *ItemQuery]()
return withInterceptors[[]*Item](ctx, iq, qr, iq.inters)
} }
// AllX is like All, but panics if an error occurs. // AllX is like All, but panics if an error occurs.
@ -372,6 +375,7 @@ func (iq *ItemQuery) AllX(ctx context.Context) []*Item {
// IDs executes the query and returns a list of Item IDs. // IDs executes the query and returns a list of Item IDs.
func (iq *ItemQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (iq *ItemQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID var ids []uuid.UUID
ctx = newQueryContext(ctx, TypeItem, "IDs")
if err := iq.Select(item.FieldID).Scan(ctx, &ids); err != nil { if err := iq.Select(item.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
@ -389,10 +393,11 @@ func (iq *ItemQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query. // Count returns the count of the given query.
func (iq *ItemQuery) Count(ctx context.Context) (int, error) { func (iq *ItemQuery) Count(ctx context.Context) (int, error) {
ctx = newQueryContext(ctx, TypeItem, "Count")
if err := iq.prepareQuery(ctx); err != nil { if err := iq.prepareQuery(ctx); err != nil {
return 0, err return 0, err
} }
return iq.sqlCount(ctx) return withInterceptors[int](ctx, iq, querierCount[*ItemQuery](), iq.inters)
} }
// CountX is like Count, but panics if an error occurs. // CountX is like Count, but panics if an error occurs.
@ -406,10 +411,15 @@ func (iq *ItemQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph. // Exist returns true if the query has elements in the graph.
func (iq *ItemQuery) Exist(ctx context.Context) (bool, error) { func (iq *ItemQuery) Exist(ctx context.Context) (bool, error) {
if err := iq.prepareQuery(ctx); err != nil { ctx = newQueryContext(ctx, TypeItem, "Exist")
return false, err switch _, err := iq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
} }
return iq.sqlExist(ctx)
} }
// ExistX is like Exist, but panics if an error occurs. // ExistX is like Exist, but panics if an error occurs.
@ -432,6 +442,7 @@ func (iq *ItemQuery) Clone() *ItemQuery {
limit: iq.limit, limit: iq.limit,
offset: iq.offset, offset: iq.offset,
order: append([]OrderFunc{}, iq.order...), order: append([]OrderFunc{}, iq.order...),
inters: append([]Interceptor{}, iq.inters...),
predicates: append([]predicate.Item{}, iq.predicates...), predicates: append([]predicate.Item{}, iq.predicates...),
withParent: iq.withParent.Clone(), withParent: iq.withParent.Clone(),
withChildren: iq.withChildren.Clone(), withChildren: iq.withChildren.Clone(),
@ -451,7 +462,7 @@ func (iq *ItemQuery) Clone() *ItemQuery {
// WithParent tells the query-builder to eager-load the nodes that are connected to // WithParent tells the query-builder to eager-load the nodes that are connected to
// the "parent" edge. The optional arguments are used to configure the query builder of the edge. // the "parent" edge. The optional arguments are used to configure the query builder of the edge.
func (iq *ItemQuery) WithParent(opts ...func(*ItemQuery)) *ItemQuery { func (iq *ItemQuery) WithParent(opts ...func(*ItemQuery)) *ItemQuery {
query := &ItemQuery{config: iq.config} query := (&ItemClient{config: iq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -462,7 +473,7 @@ func (iq *ItemQuery) WithParent(opts ...func(*ItemQuery)) *ItemQuery {
// WithChildren tells the query-builder to eager-load the nodes that are connected to // WithChildren tells the query-builder to eager-load the nodes that are connected to
// the "children" edge. The optional arguments are used to configure the query builder of the edge. // the "children" edge. The optional arguments are used to configure the query builder of the edge.
func (iq *ItemQuery) WithChildren(opts ...func(*ItemQuery)) *ItemQuery { func (iq *ItemQuery) WithChildren(opts ...func(*ItemQuery)) *ItemQuery {
query := &ItemQuery{config: iq.config} query := (&ItemClient{config: iq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -473,7 +484,7 @@ func (iq *ItemQuery) WithChildren(opts ...func(*ItemQuery)) *ItemQuery {
// WithGroup tells the query-builder to eager-load the nodes that are connected to // WithGroup tells the query-builder to eager-load the nodes that are connected to
// the "group" edge. The optional arguments are used to configure the query builder of the edge. // the "group" edge. The optional arguments are used to configure the query builder of the edge.
func (iq *ItemQuery) WithGroup(opts ...func(*GroupQuery)) *ItemQuery { func (iq *ItemQuery) WithGroup(opts ...func(*GroupQuery)) *ItemQuery {
query := &GroupQuery{config: iq.config} query := (&GroupClient{config: iq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -484,7 +495,7 @@ func (iq *ItemQuery) WithGroup(opts ...func(*GroupQuery)) *ItemQuery {
// WithLabel tells the query-builder to eager-load the nodes that are connected to // WithLabel tells the query-builder to eager-load the nodes that are connected to
// the "label" edge. The optional arguments are used to configure the query builder of the edge. // the "label" edge. The optional arguments are used to configure the query builder of the edge.
func (iq *ItemQuery) WithLabel(opts ...func(*LabelQuery)) *ItemQuery { func (iq *ItemQuery) WithLabel(opts ...func(*LabelQuery)) *ItemQuery {
query := &LabelQuery{config: iq.config} query := (&LabelClient{config: iq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -495,7 +506,7 @@ func (iq *ItemQuery) WithLabel(opts ...func(*LabelQuery)) *ItemQuery {
// WithLocation tells the query-builder to eager-load the nodes that are connected to // WithLocation tells the query-builder to eager-load the nodes that are connected to
// the "location" edge. The optional arguments are used to configure the query builder of the edge. // the "location" edge. The optional arguments are used to configure the query builder of the edge.
func (iq *ItemQuery) WithLocation(opts ...func(*LocationQuery)) *ItemQuery { func (iq *ItemQuery) WithLocation(opts ...func(*LocationQuery)) *ItemQuery {
query := &LocationQuery{config: iq.config} query := (&LocationClient{config: iq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -506,7 +517,7 @@ func (iq *ItemQuery) WithLocation(opts ...func(*LocationQuery)) *ItemQuery {
// WithFields tells the query-builder to eager-load the nodes that are connected to // WithFields tells the query-builder to eager-load the nodes that are connected to
// the "fields" edge. The optional arguments are used to configure the query builder of the edge. // the "fields" edge. The optional arguments are used to configure the query builder of the edge.
func (iq *ItemQuery) WithFields(opts ...func(*ItemFieldQuery)) *ItemQuery { func (iq *ItemQuery) WithFields(opts ...func(*ItemFieldQuery)) *ItemQuery {
query := &ItemFieldQuery{config: iq.config} query := (&ItemFieldClient{config: iq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -517,7 +528,7 @@ func (iq *ItemQuery) WithFields(opts ...func(*ItemFieldQuery)) *ItemQuery {
// WithMaintenanceEntries tells the query-builder to eager-load the nodes that are connected to // WithMaintenanceEntries tells the query-builder to eager-load the nodes that are connected to
// the "maintenance_entries" edge. The optional arguments are used to configure the query builder of the edge. // the "maintenance_entries" edge. The optional arguments are used to configure the query builder of the edge.
func (iq *ItemQuery) WithMaintenanceEntries(opts ...func(*MaintenanceEntryQuery)) *ItemQuery { func (iq *ItemQuery) WithMaintenanceEntries(opts ...func(*MaintenanceEntryQuery)) *ItemQuery {
query := &MaintenanceEntryQuery{config: iq.config} query := (&MaintenanceEntryClient{config: iq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -528,7 +539,7 @@ func (iq *ItemQuery) WithMaintenanceEntries(opts ...func(*MaintenanceEntryQuery)
// WithAttachments tells the query-builder to eager-load the nodes that are connected to // WithAttachments tells the query-builder to eager-load the nodes that are connected to
// the "attachments" edge. The optional arguments are used to configure the query builder of the edge. // the "attachments" edge. The optional arguments are used to configure the query builder of the edge.
func (iq *ItemQuery) WithAttachments(opts ...func(*AttachmentQuery)) *ItemQuery { func (iq *ItemQuery) WithAttachments(opts ...func(*AttachmentQuery)) *ItemQuery {
query := &AttachmentQuery{config: iq.config} query := (&AttachmentClient{config: iq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -551,16 +562,11 @@ func (iq *ItemQuery) WithAttachments(opts ...func(*AttachmentQuery)) *ItemQuery
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (iq *ItemQuery) GroupBy(field string, fields ...string) *ItemGroupBy { func (iq *ItemQuery) GroupBy(field string, fields ...string) *ItemGroupBy {
grbuild := &ItemGroupBy{config: iq.config} iq.fields = append([]string{field}, fields...)
grbuild.fields = append([]string{field}, fields...) grbuild := &ItemGroupBy{build: iq}
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { grbuild.flds = &iq.fields
if err := iq.prepareQuery(ctx); err != nil {
return nil, err
}
return iq.sqlQuery(ctx), nil
}
grbuild.label = item.Label grbuild.label = item.Label
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan grbuild.scan = grbuild.Scan
return grbuild return grbuild
} }
@ -578,10 +584,10 @@ func (iq *ItemQuery) GroupBy(field string, fields ...string) *ItemGroupBy {
// Scan(ctx, &v) // Scan(ctx, &v)
func (iq *ItemQuery) Select(fields ...string) *ItemSelect { func (iq *ItemQuery) Select(fields ...string) *ItemSelect {
iq.fields = append(iq.fields, fields...) iq.fields = append(iq.fields, fields...)
selbuild := &ItemSelect{ItemQuery: iq} sbuild := &ItemSelect{ItemQuery: iq}
selbuild.label = item.Label sbuild.label = item.Label
selbuild.flds, selbuild.scan = &iq.fields, selbuild.Scan sbuild.flds, sbuild.scan = &iq.fields, sbuild.Scan
return selbuild return sbuild
} }
// Aggregate returns a ItemSelect configured with the given aggregations. // Aggregate returns a ItemSelect configured with the given aggregations.
@ -590,6 +596,16 @@ func (iq *ItemQuery) Aggregate(fns ...AggregateFunc) *ItemSelect {
} }
func (iq *ItemQuery) prepareQuery(ctx context.Context) error { func (iq *ItemQuery) prepareQuery(ctx context.Context) error {
for _, inter := range iq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, iq); err != nil {
return err
}
}
}
for _, f := range iq.fields { for _, f := range iq.fields {
if !item.ValidColumn(f) { if !item.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
@ -976,17 +992,6 @@ func (iq *ItemQuery) sqlCount(ctx context.Context) (int, error) {
return sqlgraph.CountNodes(ctx, iq.driver, _spec) return sqlgraph.CountNodes(ctx, iq.driver, _spec)
} }
func (iq *ItemQuery) sqlExist(ctx context.Context) (bool, error) {
switch _, err := iq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
func (iq *ItemQuery) querySpec() *sqlgraph.QuerySpec { func (iq *ItemQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
@ -1069,13 +1074,8 @@ func (iq *ItemQuery) sqlQuery(ctx context.Context) *sql.Selector {
// ItemGroupBy is the group-by builder for Item entities. // ItemGroupBy is the group-by builder for Item entities.
type ItemGroupBy struct { type ItemGroupBy struct {
config
selector selector
fields []string build *ItemQuery
fns []AggregateFunc
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
} }
// Aggregate adds the given aggregation functions to the group-by query. // Aggregate adds the given aggregation functions to the group-by query.
@ -1084,58 +1084,46 @@ func (igb *ItemGroupBy) Aggregate(fns ...AggregateFunc) *ItemGroupBy {
return igb return igb
} }
// Scan applies the group-by query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (igb *ItemGroupBy) Scan(ctx context.Context, v any) error { func (igb *ItemGroupBy) Scan(ctx context.Context, v any) error {
query, err := igb.path(ctx) ctx = newQueryContext(ctx, TypeItem, "GroupBy")
if err != nil { if err := igb.build.prepareQuery(ctx); err != nil {
return err return err
} }
igb.sql = query return scanWithInterceptors[*ItemQuery, *ItemGroupBy](ctx, igb.build, igb, igb.build.inters, v)
return igb.sqlScan(ctx, v)
} }
func (igb *ItemGroupBy) sqlScan(ctx context.Context, v any) error { func (igb *ItemGroupBy) sqlScan(ctx context.Context, root *ItemQuery, v any) error {
for _, f := range igb.fields { selector := root.sqlQuery(ctx).Select()
if !item.ValidColumn(f) { aggregation := make([]string, 0, len(igb.fns))
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} for _, fn := range igb.fns {
} aggregation = append(aggregation, fn(selector))
} }
selector := igb.sqlQuery() if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*igb.flds)+len(igb.fns))
for _, f := range *igb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*igb.flds...)...)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return err return err
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() query, args := selector.Query()
if err := igb.driver.Query(ctx, query, args, rows); err != nil { if err := igb.build.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }
defer rows.Close() defer rows.Close()
return sql.ScanSlice(rows, v) return sql.ScanSlice(rows, v)
} }
func (igb *ItemGroupBy) sqlQuery() *sql.Selector {
selector := igb.sql.Select()
aggregation := make([]string, 0, len(igb.fns))
for _, fn := range igb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(igb.fields)+len(igb.fns))
for _, f := range igb.fields {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
return selector.GroupBy(selector.Columns(igb.fields...)...)
}
// ItemSelect is the builder for selecting fields of Item entities. // ItemSelect is the builder for selecting fields of Item entities.
type ItemSelect struct { type ItemSelect struct {
*ItemQuery *ItemQuery
selector selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
@ -1146,26 +1134,27 @@ func (is *ItemSelect) Aggregate(fns ...AggregateFunc) *ItemSelect {
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (is *ItemSelect) Scan(ctx context.Context, v any) error { func (is *ItemSelect) Scan(ctx context.Context, v any) error {
ctx = newQueryContext(ctx, TypeItem, "Select")
if err := is.prepareQuery(ctx); err != nil { if err := is.prepareQuery(ctx); err != nil {
return err return err
} }
is.sql = is.ItemQuery.sqlQuery(ctx) return scanWithInterceptors[*ItemQuery, *ItemSelect](ctx, is.ItemQuery, is, is.inters, v)
return is.sqlScan(ctx, v)
} }
func (is *ItemSelect) sqlScan(ctx context.Context, v any) error { func (is *ItemSelect) sqlScan(ctx context.Context, root *ItemQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(is.fns)) aggregation := make([]string, 0, len(is.fns))
for _, fn := range is.fns { for _, fn := range is.fns {
aggregation = append(aggregation, fn(is.sql)) aggregation = append(aggregation, fn(selector))
} }
switch n := len(*is.selector.flds); { switch n := len(*is.selector.flds); {
case n == 0 && len(aggregation) > 0: case n == 0 && len(aggregation) > 0:
is.sql.Select(aggregation...) selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0: case n != 0 && len(aggregation) > 0:
is.sql.AppendSelect(aggregation...) selector.AppendSelect(aggregation...)
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := is.sql.Query() query, args := selector.Query()
if err := is.driver.Query(ctx, query, args, rows); err != nil { if err := is.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }

View file

@ -667,41 +667,8 @@ func (iu *ItemUpdate) RemoveAttachments(a ...*Attachment) *ItemUpdate {
// Save executes the query and returns the number of nodes affected by the update operation. // Save executes the query and returns the number of nodes affected by the update operation.
func (iu *ItemUpdate) Save(ctx context.Context) (int, error) { func (iu *ItemUpdate) Save(ctx context.Context) (int, error) {
var (
err error
affected int
)
iu.defaults() iu.defaults()
if len(iu.hooks) == 0 { return withHooks[int, ItemMutation](ctx, iu.sqlSave, iu.mutation, iu.hooks)
if err = iu.check(); err != nil {
return 0, err
}
affected, err = iu.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ItemMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = iu.check(); err != nil {
return 0, err
}
iu.mutation = mutation
affected, err = iu.sqlSave(ctx)
mutation.done = true
return affected, err
})
for i := len(iu.hooks) - 1; i >= 0; i-- {
if iu.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = iu.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, iu.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -783,6 +750,9 @@ func (iu *ItemUpdate) check() error {
} }
func (iu *ItemUpdate) sqlSave(ctx context.Context) (n int, err error) { func (iu *ItemUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := iu.check(); err != nil {
return n, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: item.Table, Table: item.Table,
@ -1297,6 +1267,7 @@ func (iu *ItemUpdate) sqlSave(ctx context.Context) (n int, err error) {
} }
return 0, err return 0, err
} }
iu.mutation.done = true
return n, nil return n, nil
} }
@ -1947,47 +1918,8 @@ func (iuo *ItemUpdateOne) Select(field string, fields ...string) *ItemUpdateOne
// Save executes the query and returns the updated Item entity. // Save executes the query and returns the updated Item entity.
func (iuo *ItemUpdateOne) Save(ctx context.Context) (*Item, error) { func (iuo *ItemUpdateOne) Save(ctx context.Context) (*Item, error) {
var (
err error
node *Item
)
iuo.defaults() iuo.defaults()
if len(iuo.hooks) == 0 { return withHooks[*Item, ItemMutation](ctx, iuo.sqlSave, iuo.mutation, iuo.hooks)
if err = iuo.check(); err != nil {
return nil, err
}
node, err = iuo.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ItemMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = iuo.check(); err != nil {
return nil, err
}
iuo.mutation = mutation
node, err = iuo.sqlSave(ctx)
mutation.done = true
return node, err
})
for i := len(iuo.hooks) - 1; i >= 0; i-- {
if iuo.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = iuo.hooks[i](mut)
}
v, err := mut.Mutate(ctx, iuo.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Item)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from ItemMutation", v)
}
node = nv
}
return node, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -2069,6 +2001,9 @@ func (iuo *ItemUpdateOne) check() error {
} }
func (iuo *ItemUpdateOne) sqlSave(ctx context.Context) (_node *Item, err error) { func (iuo *ItemUpdateOne) sqlSave(ctx context.Context) (_node *Item, err error) {
if err := iuo.check(); err != nil {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: item.Table, Table: item.Table,
@ -2603,5 +2538,6 @@ func (iuo *ItemUpdateOne) sqlSave(ctx context.Context) (_node *Item, err error)
} }
return nil, err return nil, err
} }
iuo.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -13,774 +13,502 @@ import (
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.
func ID(id uuid.UUID) predicate.ItemField { func ID(id uuid.UUID) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDEQ applies the EQ predicate on the ID field. // IDEQ applies the EQ predicate on the ID field.
func IDEQ(id uuid.UUID) predicate.ItemField { func IDEQ(id uuid.UUID) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDNEQ applies the NEQ predicate on the ID field. // IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id uuid.UUID) predicate.ItemField { func IDNEQ(id uuid.UUID) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldNEQ(FieldID, id))
s.Where(sql.NEQ(s.C(FieldID), id))
})
} }
// IDIn applies the In predicate on the ID field. // IDIn applies the In predicate on the ID field.
func IDIn(ids ...uuid.UUID) predicate.ItemField { func IDIn(ids ...uuid.UUID) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.In(s.C(FieldID), v...))
})
} }
// IDNotIn applies the NotIn predicate on the ID field. // IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...uuid.UUID) predicate.ItemField { func IDNotIn(ids ...uuid.UUID) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldNotIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.NotIn(s.C(FieldID), v...))
})
} }
// IDGT applies the GT predicate on the ID field. // IDGT applies the GT predicate on the ID field.
func IDGT(id uuid.UUID) predicate.ItemField { func IDGT(id uuid.UUID) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldGT(FieldID, id))
s.Where(sql.GT(s.C(FieldID), id))
})
} }
// IDGTE applies the GTE predicate on the ID field. // IDGTE applies the GTE predicate on the ID field.
func IDGTE(id uuid.UUID) predicate.ItemField { func IDGTE(id uuid.UUID) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldGTE(FieldID, id))
s.Where(sql.GTE(s.C(FieldID), id))
})
} }
// IDLT applies the LT predicate on the ID field. // IDLT applies the LT predicate on the ID field.
func IDLT(id uuid.UUID) predicate.ItemField { func IDLT(id uuid.UUID) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldLT(FieldID, id))
s.Where(sql.LT(s.C(FieldID), id))
})
} }
// IDLTE applies the LTE predicate on the ID field. // IDLTE applies the LTE predicate on the ID field.
func IDLTE(id uuid.UUID) predicate.ItemField { func IDLTE(id uuid.UUID) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldLTE(FieldID, id))
s.Where(sql.LTE(s.C(FieldID), id))
})
} }
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. // CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.ItemField { func CreatedAt(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. // UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.ItemField { func UpdatedAt(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// Name applies equality check predicate on the "name" field. It's identical to NameEQ. // Name applies equality check predicate on the "name" field. It's identical to NameEQ.
func Name(v string) predicate.ItemField { func Name(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEQ(FieldName, v))
s.Where(sql.EQ(s.C(FieldName), v))
})
} }
// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. // Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ.
func Description(v string) predicate.ItemField { func Description(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEQ(FieldDescription, v))
s.Where(sql.EQ(s.C(FieldDescription), v))
})
} }
// TextValue applies equality check predicate on the "text_value" field. It's identical to TextValueEQ. // TextValue applies equality check predicate on the "text_value" field. It's identical to TextValueEQ.
func TextValue(v string) predicate.ItemField { func TextValue(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEQ(FieldTextValue, v))
s.Where(sql.EQ(s.C(FieldTextValue), v))
})
} }
// NumberValue applies equality check predicate on the "number_value" field. It's identical to NumberValueEQ. // NumberValue applies equality check predicate on the "number_value" field. It's identical to NumberValueEQ.
func NumberValue(v int) predicate.ItemField { func NumberValue(v int) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEQ(FieldNumberValue, v))
s.Where(sql.EQ(s.C(FieldNumberValue), v))
})
} }
// BooleanValue applies equality check predicate on the "boolean_value" field. It's identical to BooleanValueEQ. // BooleanValue applies equality check predicate on the "boolean_value" field. It's identical to BooleanValueEQ.
func BooleanValue(v bool) predicate.ItemField { func BooleanValue(v bool) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEQ(FieldBooleanValue, v))
s.Where(sql.EQ(s.C(FieldBooleanValue), v))
})
} }
// TimeValue applies equality check predicate on the "time_value" field. It's identical to TimeValueEQ. // TimeValue applies equality check predicate on the "time_value" field. It's identical to TimeValueEQ.
func TimeValue(v time.Time) predicate.ItemField { func TimeValue(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEQ(FieldTimeValue, v))
s.Where(sql.EQ(s.C(FieldTimeValue), v))
})
} }
// CreatedAtEQ applies the EQ predicate on the "created_at" field. // CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.ItemField { func CreatedAtEQ(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. // CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.ItemField { func CreatedAtNEQ(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldNEQ(FieldCreatedAt, v))
s.Where(sql.NEQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtIn applies the In predicate on the "created_at" field. // CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.ItemField { func CreatedAtIn(vs ...time.Time) predicate.ItemField {
v := make([]any, len(vs)) return predicate.ItemField(sql.FieldIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.ItemField(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. // CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.ItemField { func CreatedAtNotIn(vs ...time.Time) predicate.ItemField {
v := make([]any, len(vs)) return predicate.ItemField(sql.FieldNotIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.ItemField(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtGT applies the GT predicate on the "created_at" field. // CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.ItemField { func CreatedAtGT(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldGT(FieldCreatedAt, v))
s.Where(sql.GT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtGTE applies the GTE predicate on the "created_at" field. // CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.ItemField { func CreatedAtGTE(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldGTE(FieldCreatedAt, v))
s.Where(sql.GTE(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLT applies the LT predicate on the "created_at" field. // CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.ItemField { func CreatedAtLT(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldLT(FieldCreatedAt, v))
s.Where(sql.LT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLTE applies the LTE predicate on the "created_at" field. // CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.ItemField { func CreatedAtLTE(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldLTE(FieldCreatedAt, v))
s.Where(sql.LTE(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. // UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.ItemField { func UpdatedAtEQ(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. // UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.ItemField { func UpdatedAtNEQ(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldNEQ(FieldUpdatedAt, v))
s.Where(sql.NEQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtIn applies the In predicate on the "updated_at" field. // UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.ItemField { func UpdatedAtIn(vs ...time.Time) predicate.ItemField {
v := make([]any, len(vs)) return predicate.ItemField(sql.FieldIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.ItemField(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. // UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.ItemField { func UpdatedAtNotIn(vs ...time.Time) predicate.ItemField {
v := make([]any, len(vs)) return predicate.ItemField(sql.FieldNotIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.ItemField(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtGT applies the GT predicate on the "updated_at" field. // UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.ItemField { func UpdatedAtGT(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldGT(FieldUpdatedAt, v))
s.Where(sql.GT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. // UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.ItemField { func UpdatedAtGTE(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldGTE(FieldUpdatedAt, v))
s.Where(sql.GTE(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLT applies the LT predicate on the "updated_at" field. // UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.ItemField { func UpdatedAtLT(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldLT(FieldUpdatedAt, v))
s.Where(sql.LT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. // UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.ItemField { func UpdatedAtLTE(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldLTE(FieldUpdatedAt, v))
s.Where(sql.LTE(s.C(FieldUpdatedAt), v))
})
} }
// NameEQ applies the EQ predicate on the "name" field. // NameEQ applies the EQ predicate on the "name" field.
func NameEQ(v string) predicate.ItemField { func NameEQ(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEQ(FieldName, v))
s.Where(sql.EQ(s.C(FieldName), v))
})
} }
// NameNEQ applies the NEQ predicate on the "name" field. // NameNEQ applies the NEQ predicate on the "name" field.
func NameNEQ(v string) predicate.ItemField { func NameNEQ(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldNEQ(FieldName, v))
s.Where(sql.NEQ(s.C(FieldName), v))
})
} }
// NameIn applies the In predicate on the "name" field. // NameIn applies the In predicate on the "name" field.
func NameIn(vs ...string) predicate.ItemField { func NameIn(vs ...string) predicate.ItemField {
v := make([]any, len(vs)) return predicate.ItemField(sql.FieldIn(FieldName, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.ItemField(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldName), v...))
})
} }
// NameNotIn applies the NotIn predicate on the "name" field. // NameNotIn applies the NotIn predicate on the "name" field.
func NameNotIn(vs ...string) predicate.ItemField { func NameNotIn(vs ...string) predicate.ItemField {
v := make([]any, len(vs)) return predicate.ItemField(sql.FieldNotIn(FieldName, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.ItemField(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldName), v...))
})
} }
// NameGT applies the GT predicate on the "name" field. // NameGT applies the GT predicate on the "name" field.
func NameGT(v string) predicate.ItemField { func NameGT(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldGT(FieldName, v))
s.Where(sql.GT(s.C(FieldName), v))
})
} }
// NameGTE applies the GTE predicate on the "name" field. // NameGTE applies the GTE predicate on the "name" field.
func NameGTE(v string) predicate.ItemField { func NameGTE(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldGTE(FieldName, v))
s.Where(sql.GTE(s.C(FieldName), v))
})
} }
// NameLT applies the LT predicate on the "name" field. // NameLT applies the LT predicate on the "name" field.
func NameLT(v string) predicate.ItemField { func NameLT(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldLT(FieldName, v))
s.Where(sql.LT(s.C(FieldName), v))
})
} }
// NameLTE applies the LTE predicate on the "name" field. // NameLTE applies the LTE predicate on the "name" field.
func NameLTE(v string) predicate.ItemField { func NameLTE(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldLTE(FieldName, v))
s.Where(sql.LTE(s.C(FieldName), v))
})
} }
// NameContains applies the Contains predicate on the "name" field. // NameContains applies the Contains predicate on the "name" field.
func NameContains(v string) predicate.ItemField { func NameContains(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldContains(FieldName, v))
s.Where(sql.Contains(s.C(FieldName), v))
})
} }
// NameHasPrefix applies the HasPrefix predicate on the "name" field. // NameHasPrefix applies the HasPrefix predicate on the "name" field.
func NameHasPrefix(v string) predicate.ItemField { func NameHasPrefix(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldHasPrefix(FieldName, v))
s.Where(sql.HasPrefix(s.C(FieldName), v))
})
} }
// NameHasSuffix applies the HasSuffix predicate on the "name" field. // NameHasSuffix applies the HasSuffix predicate on the "name" field.
func NameHasSuffix(v string) predicate.ItemField { func NameHasSuffix(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldHasSuffix(FieldName, v))
s.Where(sql.HasSuffix(s.C(FieldName), v))
})
} }
// NameEqualFold applies the EqualFold predicate on the "name" field. // NameEqualFold applies the EqualFold predicate on the "name" field.
func NameEqualFold(v string) predicate.ItemField { func NameEqualFold(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEqualFold(FieldName, v))
s.Where(sql.EqualFold(s.C(FieldName), v))
})
} }
// NameContainsFold applies the ContainsFold predicate on the "name" field. // NameContainsFold applies the ContainsFold predicate on the "name" field.
func NameContainsFold(v string) predicate.ItemField { func NameContainsFold(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldContainsFold(FieldName, v))
s.Where(sql.ContainsFold(s.C(FieldName), v))
})
} }
// DescriptionEQ applies the EQ predicate on the "description" field. // DescriptionEQ applies the EQ predicate on the "description" field.
func DescriptionEQ(v string) predicate.ItemField { func DescriptionEQ(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEQ(FieldDescription, v))
s.Where(sql.EQ(s.C(FieldDescription), v))
})
} }
// DescriptionNEQ applies the NEQ predicate on the "description" field. // DescriptionNEQ applies the NEQ predicate on the "description" field.
func DescriptionNEQ(v string) predicate.ItemField { func DescriptionNEQ(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldNEQ(FieldDescription, v))
s.Where(sql.NEQ(s.C(FieldDescription), v))
})
} }
// DescriptionIn applies the In predicate on the "description" field. // DescriptionIn applies the In predicate on the "description" field.
func DescriptionIn(vs ...string) predicate.ItemField { func DescriptionIn(vs ...string) predicate.ItemField {
v := make([]any, len(vs)) return predicate.ItemField(sql.FieldIn(FieldDescription, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.ItemField(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldDescription), v...))
})
} }
// DescriptionNotIn applies the NotIn predicate on the "description" field. // DescriptionNotIn applies the NotIn predicate on the "description" field.
func DescriptionNotIn(vs ...string) predicate.ItemField { func DescriptionNotIn(vs ...string) predicate.ItemField {
v := make([]any, len(vs)) return predicate.ItemField(sql.FieldNotIn(FieldDescription, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.ItemField(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldDescription), v...))
})
} }
// DescriptionGT applies the GT predicate on the "description" field. // DescriptionGT applies the GT predicate on the "description" field.
func DescriptionGT(v string) predicate.ItemField { func DescriptionGT(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldGT(FieldDescription, v))
s.Where(sql.GT(s.C(FieldDescription), v))
})
} }
// DescriptionGTE applies the GTE predicate on the "description" field. // DescriptionGTE applies the GTE predicate on the "description" field.
func DescriptionGTE(v string) predicate.ItemField { func DescriptionGTE(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldGTE(FieldDescription, v))
s.Where(sql.GTE(s.C(FieldDescription), v))
})
} }
// DescriptionLT applies the LT predicate on the "description" field. // DescriptionLT applies the LT predicate on the "description" field.
func DescriptionLT(v string) predicate.ItemField { func DescriptionLT(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldLT(FieldDescription, v))
s.Where(sql.LT(s.C(FieldDescription), v))
})
} }
// DescriptionLTE applies the LTE predicate on the "description" field. // DescriptionLTE applies the LTE predicate on the "description" field.
func DescriptionLTE(v string) predicate.ItemField { func DescriptionLTE(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldLTE(FieldDescription, v))
s.Where(sql.LTE(s.C(FieldDescription), v))
})
} }
// DescriptionContains applies the Contains predicate on the "description" field. // DescriptionContains applies the Contains predicate on the "description" field.
func DescriptionContains(v string) predicate.ItemField { func DescriptionContains(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldContains(FieldDescription, v))
s.Where(sql.Contains(s.C(FieldDescription), v))
})
} }
// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. // DescriptionHasPrefix applies the HasPrefix predicate on the "description" field.
func DescriptionHasPrefix(v string) predicate.ItemField { func DescriptionHasPrefix(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldHasPrefix(FieldDescription, v))
s.Where(sql.HasPrefix(s.C(FieldDescription), v))
})
} }
// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. // DescriptionHasSuffix applies the HasSuffix predicate on the "description" field.
func DescriptionHasSuffix(v string) predicate.ItemField { func DescriptionHasSuffix(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldHasSuffix(FieldDescription, v))
s.Where(sql.HasSuffix(s.C(FieldDescription), v))
})
} }
// DescriptionIsNil applies the IsNil predicate on the "description" field. // DescriptionIsNil applies the IsNil predicate on the "description" field.
func DescriptionIsNil() predicate.ItemField { func DescriptionIsNil() predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldIsNull(FieldDescription))
s.Where(sql.IsNull(s.C(FieldDescription)))
})
} }
// DescriptionNotNil applies the NotNil predicate on the "description" field. // DescriptionNotNil applies the NotNil predicate on the "description" field.
func DescriptionNotNil() predicate.ItemField { func DescriptionNotNil() predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldNotNull(FieldDescription))
s.Where(sql.NotNull(s.C(FieldDescription)))
})
} }
// DescriptionEqualFold applies the EqualFold predicate on the "description" field. // DescriptionEqualFold applies the EqualFold predicate on the "description" field.
func DescriptionEqualFold(v string) predicate.ItemField { func DescriptionEqualFold(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEqualFold(FieldDescription, v))
s.Where(sql.EqualFold(s.C(FieldDescription), v))
})
} }
// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. // DescriptionContainsFold applies the ContainsFold predicate on the "description" field.
func DescriptionContainsFold(v string) predicate.ItemField { func DescriptionContainsFold(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldContainsFold(FieldDescription, v))
s.Where(sql.ContainsFold(s.C(FieldDescription), v))
})
} }
// TypeEQ applies the EQ predicate on the "type" field. // TypeEQ applies the EQ predicate on the "type" field.
func TypeEQ(v Type) predicate.ItemField { func TypeEQ(v Type) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEQ(FieldType, v))
s.Where(sql.EQ(s.C(FieldType), v))
})
} }
// TypeNEQ applies the NEQ predicate on the "type" field. // TypeNEQ applies the NEQ predicate on the "type" field.
func TypeNEQ(v Type) predicate.ItemField { func TypeNEQ(v Type) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldNEQ(FieldType, v))
s.Where(sql.NEQ(s.C(FieldType), v))
})
} }
// TypeIn applies the In predicate on the "type" field. // TypeIn applies the In predicate on the "type" field.
func TypeIn(vs ...Type) predicate.ItemField { func TypeIn(vs ...Type) predicate.ItemField {
v := make([]any, len(vs)) return predicate.ItemField(sql.FieldIn(FieldType, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.ItemField(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldType), v...))
})
} }
// TypeNotIn applies the NotIn predicate on the "type" field. // TypeNotIn applies the NotIn predicate on the "type" field.
func TypeNotIn(vs ...Type) predicate.ItemField { func TypeNotIn(vs ...Type) predicate.ItemField {
v := make([]any, len(vs)) return predicate.ItemField(sql.FieldNotIn(FieldType, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.ItemField(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldType), v...))
})
} }
// TextValueEQ applies the EQ predicate on the "text_value" field. // TextValueEQ applies the EQ predicate on the "text_value" field.
func TextValueEQ(v string) predicate.ItemField { func TextValueEQ(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEQ(FieldTextValue, v))
s.Where(sql.EQ(s.C(FieldTextValue), v))
})
} }
// TextValueNEQ applies the NEQ predicate on the "text_value" field. // TextValueNEQ applies the NEQ predicate on the "text_value" field.
func TextValueNEQ(v string) predicate.ItemField { func TextValueNEQ(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldNEQ(FieldTextValue, v))
s.Where(sql.NEQ(s.C(FieldTextValue), v))
})
} }
// TextValueIn applies the In predicate on the "text_value" field. // TextValueIn applies the In predicate on the "text_value" field.
func TextValueIn(vs ...string) predicate.ItemField { func TextValueIn(vs ...string) predicate.ItemField {
v := make([]any, len(vs)) return predicate.ItemField(sql.FieldIn(FieldTextValue, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.ItemField(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldTextValue), v...))
})
} }
// TextValueNotIn applies the NotIn predicate on the "text_value" field. // TextValueNotIn applies the NotIn predicate on the "text_value" field.
func TextValueNotIn(vs ...string) predicate.ItemField { func TextValueNotIn(vs ...string) predicate.ItemField {
v := make([]any, len(vs)) return predicate.ItemField(sql.FieldNotIn(FieldTextValue, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.ItemField(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldTextValue), v...))
})
} }
// TextValueGT applies the GT predicate on the "text_value" field. // TextValueGT applies the GT predicate on the "text_value" field.
func TextValueGT(v string) predicate.ItemField { func TextValueGT(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldGT(FieldTextValue, v))
s.Where(sql.GT(s.C(FieldTextValue), v))
})
} }
// TextValueGTE applies the GTE predicate on the "text_value" field. // TextValueGTE applies the GTE predicate on the "text_value" field.
func TextValueGTE(v string) predicate.ItemField { func TextValueGTE(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldGTE(FieldTextValue, v))
s.Where(sql.GTE(s.C(FieldTextValue), v))
})
} }
// TextValueLT applies the LT predicate on the "text_value" field. // TextValueLT applies the LT predicate on the "text_value" field.
func TextValueLT(v string) predicate.ItemField { func TextValueLT(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldLT(FieldTextValue, v))
s.Where(sql.LT(s.C(FieldTextValue), v))
})
} }
// TextValueLTE applies the LTE predicate on the "text_value" field. // TextValueLTE applies the LTE predicate on the "text_value" field.
func TextValueLTE(v string) predicate.ItemField { func TextValueLTE(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldLTE(FieldTextValue, v))
s.Where(sql.LTE(s.C(FieldTextValue), v))
})
} }
// TextValueContains applies the Contains predicate on the "text_value" field. // TextValueContains applies the Contains predicate on the "text_value" field.
func TextValueContains(v string) predicate.ItemField { func TextValueContains(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldContains(FieldTextValue, v))
s.Where(sql.Contains(s.C(FieldTextValue), v))
})
} }
// TextValueHasPrefix applies the HasPrefix predicate on the "text_value" field. // TextValueHasPrefix applies the HasPrefix predicate on the "text_value" field.
func TextValueHasPrefix(v string) predicate.ItemField { func TextValueHasPrefix(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldHasPrefix(FieldTextValue, v))
s.Where(sql.HasPrefix(s.C(FieldTextValue), v))
})
} }
// TextValueHasSuffix applies the HasSuffix predicate on the "text_value" field. // TextValueHasSuffix applies the HasSuffix predicate on the "text_value" field.
func TextValueHasSuffix(v string) predicate.ItemField { func TextValueHasSuffix(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldHasSuffix(FieldTextValue, v))
s.Where(sql.HasSuffix(s.C(FieldTextValue), v))
})
} }
// TextValueIsNil applies the IsNil predicate on the "text_value" field. // TextValueIsNil applies the IsNil predicate on the "text_value" field.
func TextValueIsNil() predicate.ItemField { func TextValueIsNil() predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldIsNull(FieldTextValue))
s.Where(sql.IsNull(s.C(FieldTextValue)))
})
} }
// TextValueNotNil applies the NotNil predicate on the "text_value" field. // TextValueNotNil applies the NotNil predicate on the "text_value" field.
func TextValueNotNil() predicate.ItemField { func TextValueNotNil() predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldNotNull(FieldTextValue))
s.Where(sql.NotNull(s.C(FieldTextValue)))
})
} }
// TextValueEqualFold applies the EqualFold predicate on the "text_value" field. // TextValueEqualFold applies the EqualFold predicate on the "text_value" field.
func TextValueEqualFold(v string) predicate.ItemField { func TextValueEqualFold(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEqualFold(FieldTextValue, v))
s.Where(sql.EqualFold(s.C(FieldTextValue), v))
})
} }
// TextValueContainsFold applies the ContainsFold predicate on the "text_value" field. // TextValueContainsFold applies the ContainsFold predicate on the "text_value" field.
func TextValueContainsFold(v string) predicate.ItemField { func TextValueContainsFold(v string) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldContainsFold(FieldTextValue, v))
s.Where(sql.ContainsFold(s.C(FieldTextValue), v))
})
} }
// NumberValueEQ applies the EQ predicate on the "number_value" field. // NumberValueEQ applies the EQ predicate on the "number_value" field.
func NumberValueEQ(v int) predicate.ItemField { func NumberValueEQ(v int) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEQ(FieldNumberValue, v))
s.Where(sql.EQ(s.C(FieldNumberValue), v))
})
} }
// NumberValueNEQ applies the NEQ predicate on the "number_value" field. // NumberValueNEQ applies the NEQ predicate on the "number_value" field.
func NumberValueNEQ(v int) predicate.ItemField { func NumberValueNEQ(v int) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldNEQ(FieldNumberValue, v))
s.Where(sql.NEQ(s.C(FieldNumberValue), v))
})
} }
// NumberValueIn applies the In predicate on the "number_value" field. // NumberValueIn applies the In predicate on the "number_value" field.
func NumberValueIn(vs ...int) predicate.ItemField { func NumberValueIn(vs ...int) predicate.ItemField {
v := make([]any, len(vs)) return predicate.ItemField(sql.FieldIn(FieldNumberValue, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.ItemField(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldNumberValue), v...))
})
} }
// NumberValueNotIn applies the NotIn predicate on the "number_value" field. // NumberValueNotIn applies the NotIn predicate on the "number_value" field.
func NumberValueNotIn(vs ...int) predicate.ItemField { func NumberValueNotIn(vs ...int) predicate.ItemField {
v := make([]any, len(vs)) return predicate.ItemField(sql.FieldNotIn(FieldNumberValue, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.ItemField(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldNumberValue), v...))
})
} }
// NumberValueGT applies the GT predicate on the "number_value" field. // NumberValueGT applies the GT predicate on the "number_value" field.
func NumberValueGT(v int) predicate.ItemField { func NumberValueGT(v int) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldGT(FieldNumberValue, v))
s.Where(sql.GT(s.C(FieldNumberValue), v))
})
} }
// NumberValueGTE applies the GTE predicate on the "number_value" field. // NumberValueGTE applies the GTE predicate on the "number_value" field.
func NumberValueGTE(v int) predicate.ItemField { func NumberValueGTE(v int) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldGTE(FieldNumberValue, v))
s.Where(sql.GTE(s.C(FieldNumberValue), v))
})
} }
// NumberValueLT applies the LT predicate on the "number_value" field. // NumberValueLT applies the LT predicate on the "number_value" field.
func NumberValueLT(v int) predicate.ItemField { func NumberValueLT(v int) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldLT(FieldNumberValue, v))
s.Where(sql.LT(s.C(FieldNumberValue), v))
})
} }
// NumberValueLTE applies the LTE predicate on the "number_value" field. // NumberValueLTE applies the LTE predicate on the "number_value" field.
func NumberValueLTE(v int) predicate.ItemField { func NumberValueLTE(v int) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldLTE(FieldNumberValue, v))
s.Where(sql.LTE(s.C(FieldNumberValue), v))
})
} }
// NumberValueIsNil applies the IsNil predicate on the "number_value" field. // NumberValueIsNil applies the IsNil predicate on the "number_value" field.
func NumberValueIsNil() predicate.ItemField { func NumberValueIsNil() predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldIsNull(FieldNumberValue))
s.Where(sql.IsNull(s.C(FieldNumberValue)))
})
} }
// NumberValueNotNil applies the NotNil predicate on the "number_value" field. // NumberValueNotNil applies the NotNil predicate on the "number_value" field.
func NumberValueNotNil() predicate.ItemField { func NumberValueNotNil() predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldNotNull(FieldNumberValue))
s.Where(sql.NotNull(s.C(FieldNumberValue)))
})
} }
// BooleanValueEQ applies the EQ predicate on the "boolean_value" field. // BooleanValueEQ applies the EQ predicate on the "boolean_value" field.
func BooleanValueEQ(v bool) predicate.ItemField { func BooleanValueEQ(v bool) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEQ(FieldBooleanValue, v))
s.Where(sql.EQ(s.C(FieldBooleanValue), v))
})
} }
// BooleanValueNEQ applies the NEQ predicate on the "boolean_value" field. // BooleanValueNEQ applies the NEQ predicate on the "boolean_value" field.
func BooleanValueNEQ(v bool) predicate.ItemField { func BooleanValueNEQ(v bool) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldNEQ(FieldBooleanValue, v))
s.Where(sql.NEQ(s.C(FieldBooleanValue), v))
})
} }
// TimeValueEQ applies the EQ predicate on the "time_value" field. // TimeValueEQ applies the EQ predicate on the "time_value" field.
func TimeValueEQ(v time.Time) predicate.ItemField { func TimeValueEQ(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldEQ(FieldTimeValue, v))
s.Where(sql.EQ(s.C(FieldTimeValue), v))
})
} }
// TimeValueNEQ applies the NEQ predicate on the "time_value" field. // TimeValueNEQ applies the NEQ predicate on the "time_value" field.
func TimeValueNEQ(v time.Time) predicate.ItemField { func TimeValueNEQ(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldNEQ(FieldTimeValue, v))
s.Where(sql.NEQ(s.C(FieldTimeValue), v))
})
} }
// TimeValueIn applies the In predicate on the "time_value" field. // TimeValueIn applies the In predicate on the "time_value" field.
func TimeValueIn(vs ...time.Time) predicate.ItemField { func TimeValueIn(vs ...time.Time) predicate.ItemField {
v := make([]any, len(vs)) return predicate.ItemField(sql.FieldIn(FieldTimeValue, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.ItemField(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldTimeValue), v...))
})
} }
// TimeValueNotIn applies the NotIn predicate on the "time_value" field. // TimeValueNotIn applies the NotIn predicate on the "time_value" field.
func TimeValueNotIn(vs ...time.Time) predicate.ItemField { func TimeValueNotIn(vs ...time.Time) predicate.ItemField {
v := make([]any, len(vs)) return predicate.ItemField(sql.FieldNotIn(FieldTimeValue, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.ItemField(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldTimeValue), v...))
})
} }
// TimeValueGT applies the GT predicate on the "time_value" field. // TimeValueGT applies the GT predicate on the "time_value" field.
func TimeValueGT(v time.Time) predicate.ItemField { func TimeValueGT(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldGT(FieldTimeValue, v))
s.Where(sql.GT(s.C(FieldTimeValue), v))
})
} }
// TimeValueGTE applies the GTE predicate on the "time_value" field. // TimeValueGTE applies the GTE predicate on the "time_value" field.
func TimeValueGTE(v time.Time) predicate.ItemField { func TimeValueGTE(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldGTE(FieldTimeValue, v))
s.Where(sql.GTE(s.C(FieldTimeValue), v))
})
} }
// TimeValueLT applies the LT predicate on the "time_value" field. // TimeValueLT applies the LT predicate on the "time_value" field.
func TimeValueLT(v time.Time) predicate.ItemField { func TimeValueLT(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldLT(FieldTimeValue, v))
s.Where(sql.LT(s.C(FieldTimeValue), v))
})
} }
// TimeValueLTE applies the LTE predicate on the "time_value" field. // TimeValueLTE applies the LTE predicate on the "time_value" field.
func TimeValueLTE(v time.Time) predicate.ItemField { func TimeValueLTE(v time.Time) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(sql.FieldLTE(FieldTimeValue, v))
s.Where(sql.LTE(s.C(FieldTimeValue), v))
})
} }
// HasItem applies the HasEdge predicate on the "item" edge. // HasItem applies the HasEdge predicate on the "item" edge.
@ -788,7 +516,6 @@ func HasItem() predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) { return predicate.ItemField(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(ItemTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ItemTable, ItemColumn), sqlgraph.Edge(sqlgraph.M2O, true, ItemTable, ItemColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)

View file

@ -172,50 +172,8 @@ func (ifc *ItemFieldCreate) Mutation() *ItemFieldMutation {
// Save creates the ItemField in the database. // Save creates the ItemField in the database.
func (ifc *ItemFieldCreate) Save(ctx context.Context) (*ItemField, error) { func (ifc *ItemFieldCreate) Save(ctx context.Context) (*ItemField, error) {
var (
err error
node *ItemField
)
ifc.defaults() ifc.defaults()
if len(ifc.hooks) == 0 { return withHooks[*ItemField, ItemFieldMutation](ctx, ifc.sqlSave, ifc.mutation, ifc.hooks)
if err = ifc.check(); err != nil {
return nil, err
}
node, err = ifc.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ItemFieldMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = ifc.check(); err != nil {
return nil, err
}
ifc.mutation = mutation
if node, err = ifc.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(ifc.hooks) - 1; i >= 0; i-- {
if ifc.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = ifc.hooks[i](mut)
}
v, err := mut.Mutate(ctx, ifc.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*ItemField)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from ItemFieldMutation", v)
}
node = nv
}
return node, err
} }
// SaveX calls Save and panics if Save returns an error. // SaveX calls Save and panics if Save returns an error.
@ -308,6 +266,9 @@ func (ifc *ItemFieldCreate) check() error {
} }
func (ifc *ItemFieldCreate) sqlSave(ctx context.Context) (*ItemField, error) { func (ifc *ItemFieldCreate) sqlSave(ctx context.Context) (*ItemField, error) {
if err := ifc.check(); err != nil {
return nil, err
}
_node, _spec := ifc.createSpec() _node, _spec := ifc.createSpec()
if err := sqlgraph.CreateNode(ctx, ifc.driver, _spec); err != nil { if err := sqlgraph.CreateNode(ctx, ifc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) { if sqlgraph.IsConstraintError(err) {
@ -322,6 +283,8 @@ func (ifc *ItemFieldCreate) sqlSave(ctx context.Context) (*ItemField, error) {
return nil, err return nil, err
} }
} }
ifc.mutation.id = &_node.ID
ifc.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -4,7 +4,6 @@ package ent
import ( import (
"context" "context"
"fmt"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
@ -28,34 +27,7 @@ func (ifd *ItemFieldDelete) Where(ps ...predicate.ItemField) *ItemFieldDelete {
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (ifd *ItemFieldDelete) Exec(ctx context.Context) (int, error) { func (ifd *ItemFieldDelete) Exec(ctx context.Context) (int, error) {
var ( return withHooks[int, ItemFieldMutation](ctx, ifd.sqlExec, ifd.mutation, ifd.hooks)
err error
affected int
)
if len(ifd.hooks) == 0 {
affected, err = ifd.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ItemFieldMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
ifd.mutation = mutation
affected, err = ifd.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(ifd.hooks) - 1; i >= 0; i-- {
if ifd.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = ifd.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, ifd.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
@ -88,6 +60,7 @@ func (ifd *ItemFieldDelete) sqlExec(ctx context.Context) (int, error) {
if err != nil && sqlgraph.IsConstraintError(err) { if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
ifd.mutation.done = true
return affected, err return affected, err
} }

View file

@ -24,6 +24,7 @@ type ItemFieldQuery struct {
unique *bool unique *bool
order []OrderFunc order []OrderFunc
fields []string fields []string
inters []Interceptor
predicates []predicate.ItemField predicates []predicate.ItemField
withItem *ItemQuery withItem *ItemQuery
withFKs bool withFKs bool
@ -38,13 +39,13 @@ func (ifq *ItemFieldQuery) Where(ps ...predicate.ItemField) *ItemFieldQuery {
return ifq return ifq
} }
// Limit adds a limit step to the query. // Limit the number of records to be returned by this query.
func (ifq *ItemFieldQuery) Limit(limit int) *ItemFieldQuery { func (ifq *ItemFieldQuery) Limit(limit int) *ItemFieldQuery {
ifq.limit = &limit ifq.limit = &limit
return ifq return ifq
} }
// Offset adds an offset step to the query. // Offset to start from.
func (ifq *ItemFieldQuery) Offset(offset int) *ItemFieldQuery { func (ifq *ItemFieldQuery) Offset(offset int) *ItemFieldQuery {
ifq.offset = &offset ifq.offset = &offset
return ifq return ifq
@ -57,7 +58,7 @@ func (ifq *ItemFieldQuery) Unique(unique bool) *ItemFieldQuery {
return ifq return ifq
} }
// Order adds an order step to the query. // Order specifies how the records should be ordered.
func (ifq *ItemFieldQuery) Order(o ...OrderFunc) *ItemFieldQuery { func (ifq *ItemFieldQuery) Order(o ...OrderFunc) *ItemFieldQuery {
ifq.order = append(ifq.order, o...) ifq.order = append(ifq.order, o...)
return ifq return ifq
@ -65,7 +66,7 @@ func (ifq *ItemFieldQuery) Order(o ...OrderFunc) *ItemFieldQuery {
// QueryItem chains the current query on the "item" edge. // QueryItem chains the current query on the "item" edge.
func (ifq *ItemFieldQuery) QueryItem() *ItemQuery { func (ifq *ItemFieldQuery) QueryItem() *ItemQuery {
query := &ItemQuery{config: ifq.config} query := (&ItemClient{config: ifq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := ifq.prepareQuery(ctx); err != nil { if err := ifq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -88,7 +89,7 @@ func (ifq *ItemFieldQuery) QueryItem() *ItemQuery {
// First returns the first ItemField entity from the query. // First returns the first ItemField entity from the query.
// Returns a *NotFoundError when no ItemField was found. // Returns a *NotFoundError when no ItemField was found.
func (ifq *ItemFieldQuery) First(ctx context.Context) (*ItemField, error) { func (ifq *ItemFieldQuery) First(ctx context.Context) (*ItemField, error) {
nodes, err := ifq.Limit(1).All(ctx) nodes, err := ifq.Limit(1).All(newQueryContext(ctx, TypeItemField, "First"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -111,7 +112,7 @@ func (ifq *ItemFieldQuery) FirstX(ctx context.Context) *ItemField {
// Returns a *NotFoundError when no ItemField ID was found. // Returns a *NotFoundError when no ItemField ID was found.
func (ifq *ItemFieldQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { func (ifq *ItemFieldQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = ifq.Limit(1).IDs(ctx); err != nil { if ids, err = ifq.Limit(1).IDs(newQueryContext(ctx, TypeItemField, "FirstID")); err != nil {
return return
} }
if len(ids) == 0 { if len(ids) == 0 {
@ -134,7 +135,7 @@ func (ifq *ItemFieldQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one ItemField entity is found. // Returns a *NotSingularError when more than one ItemField entity is found.
// Returns a *NotFoundError when no ItemField entities are found. // Returns a *NotFoundError when no ItemField entities are found.
func (ifq *ItemFieldQuery) Only(ctx context.Context) (*ItemField, error) { func (ifq *ItemFieldQuery) Only(ctx context.Context) (*ItemField, error) {
nodes, err := ifq.Limit(2).All(ctx) nodes, err := ifq.Limit(2).All(newQueryContext(ctx, TypeItemField, "Only"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -162,7 +163,7 @@ func (ifq *ItemFieldQuery) OnlyX(ctx context.Context) *ItemField {
// Returns a *NotFoundError when no entities are found. // Returns a *NotFoundError when no entities are found.
func (ifq *ItemFieldQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { func (ifq *ItemFieldQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = ifq.Limit(2).IDs(ctx); err != nil { if ids, err = ifq.Limit(2).IDs(newQueryContext(ctx, TypeItemField, "OnlyID")); err != nil {
return return
} }
switch len(ids) { switch len(ids) {
@ -187,10 +188,12 @@ func (ifq *ItemFieldQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of ItemFields. // All executes the query and returns a list of ItemFields.
func (ifq *ItemFieldQuery) All(ctx context.Context) ([]*ItemField, error) { func (ifq *ItemFieldQuery) All(ctx context.Context) ([]*ItemField, error) {
ctx = newQueryContext(ctx, TypeItemField, "All")
if err := ifq.prepareQuery(ctx); err != nil { if err := ifq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return ifq.sqlAll(ctx) qr := querierAll[[]*ItemField, *ItemFieldQuery]()
return withInterceptors[[]*ItemField](ctx, ifq, qr, ifq.inters)
} }
// AllX is like All, but panics if an error occurs. // AllX is like All, but panics if an error occurs.
@ -205,6 +208,7 @@ func (ifq *ItemFieldQuery) AllX(ctx context.Context) []*ItemField {
// IDs executes the query and returns a list of ItemField IDs. // IDs executes the query and returns a list of ItemField IDs.
func (ifq *ItemFieldQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (ifq *ItemFieldQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID var ids []uuid.UUID
ctx = newQueryContext(ctx, TypeItemField, "IDs")
if err := ifq.Select(itemfield.FieldID).Scan(ctx, &ids); err != nil { if err := ifq.Select(itemfield.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
@ -222,10 +226,11 @@ func (ifq *ItemFieldQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query. // Count returns the count of the given query.
func (ifq *ItemFieldQuery) Count(ctx context.Context) (int, error) { func (ifq *ItemFieldQuery) Count(ctx context.Context) (int, error) {
ctx = newQueryContext(ctx, TypeItemField, "Count")
if err := ifq.prepareQuery(ctx); err != nil { if err := ifq.prepareQuery(ctx); err != nil {
return 0, err return 0, err
} }
return ifq.sqlCount(ctx) return withInterceptors[int](ctx, ifq, querierCount[*ItemFieldQuery](), ifq.inters)
} }
// CountX is like Count, but panics if an error occurs. // CountX is like Count, but panics if an error occurs.
@ -239,10 +244,15 @@ func (ifq *ItemFieldQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph. // Exist returns true if the query has elements in the graph.
func (ifq *ItemFieldQuery) Exist(ctx context.Context) (bool, error) { func (ifq *ItemFieldQuery) Exist(ctx context.Context) (bool, error) {
if err := ifq.prepareQuery(ctx); err != nil { ctx = newQueryContext(ctx, TypeItemField, "Exist")
return false, err switch _, err := ifq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
} }
return ifq.sqlExist(ctx)
} }
// ExistX is like Exist, but panics if an error occurs. // ExistX is like Exist, but panics if an error occurs.
@ -265,6 +275,7 @@ func (ifq *ItemFieldQuery) Clone() *ItemFieldQuery {
limit: ifq.limit, limit: ifq.limit,
offset: ifq.offset, offset: ifq.offset,
order: append([]OrderFunc{}, ifq.order...), order: append([]OrderFunc{}, ifq.order...),
inters: append([]Interceptor{}, ifq.inters...),
predicates: append([]predicate.ItemField{}, ifq.predicates...), predicates: append([]predicate.ItemField{}, ifq.predicates...),
withItem: ifq.withItem.Clone(), withItem: ifq.withItem.Clone(),
// clone intermediate query. // clone intermediate query.
@ -277,7 +288,7 @@ func (ifq *ItemFieldQuery) Clone() *ItemFieldQuery {
// WithItem tells the query-builder to eager-load the nodes that are connected to // WithItem tells the query-builder to eager-load the nodes that are connected to
// the "item" edge. The optional arguments are used to configure the query builder of the edge. // the "item" edge. The optional arguments are used to configure the query builder of the edge.
func (ifq *ItemFieldQuery) WithItem(opts ...func(*ItemQuery)) *ItemFieldQuery { func (ifq *ItemFieldQuery) WithItem(opts ...func(*ItemQuery)) *ItemFieldQuery {
query := &ItemQuery{config: ifq.config} query := (&ItemClient{config: ifq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -300,16 +311,11 @@ func (ifq *ItemFieldQuery) WithItem(opts ...func(*ItemQuery)) *ItemFieldQuery {
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (ifq *ItemFieldQuery) GroupBy(field string, fields ...string) *ItemFieldGroupBy { func (ifq *ItemFieldQuery) GroupBy(field string, fields ...string) *ItemFieldGroupBy {
grbuild := &ItemFieldGroupBy{config: ifq.config} ifq.fields = append([]string{field}, fields...)
grbuild.fields = append([]string{field}, fields...) grbuild := &ItemFieldGroupBy{build: ifq}
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { grbuild.flds = &ifq.fields
if err := ifq.prepareQuery(ctx); err != nil {
return nil, err
}
return ifq.sqlQuery(ctx), nil
}
grbuild.label = itemfield.Label grbuild.label = itemfield.Label
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan grbuild.scan = grbuild.Scan
return grbuild return grbuild
} }
@ -327,10 +333,10 @@ func (ifq *ItemFieldQuery) GroupBy(field string, fields ...string) *ItemFieldGro
// Scan(ctx, &v) // Scan(ctx, &v)
func (ifq *ItemFieldQuery) Select(fields ...string) *ItemFieldSelect { func (ifq *ItemFieldQuery) Select(fields ...string) *ItemFieldSelect {
ifq.fields = append(ifq.fields, fields...) ifq.fields = append(ifq.fields, fields...)
selbuild := &ItemFieldSelect{ItemFieldQuery: ifq} sbuild := &ItemFieldSelect{ItemFieldQuery: ifq}
selbuild.label = itemfield.Label sbuild.label = itemfield.Label
selbuild.flds, selbuild.scan = &ifq.fields, selbuild.Scan sbuild.flds, sbuild.scan = &ifq.fields, sbuild.Scan
return selbuild return sbuild
} }
// Aggregate returns a ItemFieldSelect configured with the given aggregations. // Aggregate returns a ItemFieldSelect configured with the given aggregations.
@ -339,6 +345,16 @@ func (ifq *ItemFieldQuery) Aggregate(fns ...AggregateFunc) *ItemFieldSelect {
} }
func (ifq *ItemFieldQuery) prepareQuery(ctx context.Context) error { func (ifq *ItemFieldQuery) prepareQuery(ctx context.Context) error {
for _, inter := range ifq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, ifq); err != nil {
return err
}
}
}
for _, f := range ifq.fields { for _, f := range ifq.fields {
if !itemfield.ValidColumn(f) { if !itemfield.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
@ -435,17 +451,6 @@ func (ifq *ItemFieldQuery) sqlCount(ctx context.Context) (int, error) {
return sqlgraph.CountNodes(ctx, ifq.driver, _spec) return sqlgraph.CountNodes(ctx, ifq.driver, _spec)
} }
func (ifq *ItemFieldQuery) sqlExist(ctx context.Context) (bool, error) {
switch _, err := ifq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
func (ifq *ItemFieldQuery) querySpec() *sqlgraph.QuerySpec { func (ifq *ItemFieldQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
@ -528,13 +533,8 @@ func (ifq *ItemFieldQuery) sqlQuery(ctx context.Context) *sql.Selector {
// ItemFieldGroupBy is the group-by builder for ItemField entities. // ItemFieldGroupBy is the group-by builder for ItemField entities.
type ItemFieldGroupBy struct { type ItemFieldGroupBy struct {
config
selector selector
fields []string build *ItemFieldQuery
fns []AggregateFunc
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
} }
// Aggregate adds the given aggregation functions to the group-by query. // Aggregate adds the given aggregation functions to the group-by query.
@ -543,58 +543,46 @@ func (ifgb *ItemFieldGroupBy) Aggregate(fns ...AggregateFunc) *ItemFieldGroupBy
return ifgb return ifgb
} }
// Scan applies the group-by query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (ifgb *ItemFieldGroupBy) Scan(ctx context.Context, v any) error { func (ifgb *ItemFieldGroupBy) Scan(ctx context.Context, v any) error {
query, err := ifgb.path(ctx) ctx = newQueryContext(ctx, TypeItemField, "GroupBy")
if err != nil { if err := ifgb.build.prepareQuery(ctx); err != nil {
return err return err
} }
ifgb.sql = query return scanWithInterceptors[*ItemFieldQuery, *ItemFieldGroupBy](ctx, ifgb.build, ifgb, ifgb.build.inters, v)
return ifgb.sqlScan(ctx, v)
} }
func (ifgb *ItemFieldGroupBy) sqlScan(ctx context.Context, v any) error { func (ifgb *ItemFieldGroupBy) sqlScan(ctx context.Context, root *ItemFieldQuery, v any) error {
for _, f := range ifgb.fields { selector := root.sqlQuery(ctx).Select()
if !itemfield.ValidColumn(f) { aggregation := make([]string, 0, len(ifgb.fns))
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} for _, fn := range ifgb.fns {
} aggregation = append(aggregation, fn(selector))
} }
selector := ifgb.sqlQuery() if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*ifgb.flds)+len(ifgb.fns))
for _, f := range *ifgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*ifgb.flds...)...)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return err return err
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() query, args := selector.Query()
if err := ifgb.driver.Query(ctx, query, args, rows); err != nil { if err := ifgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }
defer rows.Close() defer rows.Close()
return sql.ScanSlice(rows, v) return sql.ScanSlice(rows, v)
} }
func (ifgb *ItemFieldGroupBy) sqlQuery() *sql.Selector {
selector := ifgb.sql.Select()
aggregation := make([]string, 0, len(ifgb.fns))
for _, fn := range ifgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(ifgb.fields)+len(ifgb.fns))
for _, f := range ifgb.fields {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
return selector.GroupBy(selector.Columns(ifgb.fields...)...)
}
// ItemFieldSelect is the builder for selecting fields of ItemField entities. // ItemFieldSelect is the builder for selecting fields of ItemField entities.
type ItemFieldSelect struct { type ItemFieldSelect struct {
*ItemFieldQuery *ItemFieldQuery
selector selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
@ -605,26 +593,27 @@ func (ifs *ItemFieldSelect) Aggregate(fns ...AggregateFunc) *ItemFieldSelect {
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (ifs *ItemFieldSelect) Scan(ctx context.Context, v any) error { func (ifs *ItemFieldSelect) Scan(ctx context.Context, v any) error {
ctx = newQueryContext(ctx, TypeItemField, "Select")
if err := ifs.prepareQuery(ctx); err != nil { if err := ifs.prepareQuery(ctx); err != nil {
return err return err
} }
ifs.sql = ifs.ItemFieldQuery.sqlQuery(ctx) return scanWithInterceptors[*ItemFieldQuery, *ItemFieldSelect](ctx, ifs.ItemFieldQuery, ifs, ifs.inters, v)
return ifs.sqlScan(ctx, v)
} }
func (ifs *ItemFieldSelect) sqlScan(ctx context.Context, v any) error { func (ifs *ItemFieldSelect) sqlScan(ctx context.Context, root *ItemFieldQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(ifs.fns)) aggregation := make([]string, 0, len(ifs.fns))
for _, fn := range ifs.fns { for _, fn := range ifs.fns {
aggregation = append(aggregation, fn(ifs.sql)) aggregation = append(aggregation, fn(selector))
} }
switch n := len(*ifs.selector.flds); { switch n := len(*ifs.selector.flds); {
case n == 0 && len(aggregation) > 0: case n == 0 && len(aggregation) > 0:
ifs.sql.Select(aggregation...) selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0: case n != 0 && len(aggregation) > 0:
ifs.sql.AppendSelect(aggregation...) selector.AppendSelect(aggregation...)
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := ifs.sql.Query() query, args := selector.Query()
if err := ifs.driver.Query(ctx, query, args, rows); err != nil { if err := ifs.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }

View file

@ -175,41 +175,8 @@ func (ifu *ItemFieldUpdate) ClearItem() *ItemFieldUpdate {
// Save executes the query and returns the number of nodes affected by the update operation. // Save executes the query and returns the number of nodes affected by the update operation.
func (ifu *ItemFieldUpdate) Save(ctx context.Context) (int, error) { func (ifu *ItemFieldUpdate) Save(ctx context.Context) (int, error) {
var (
err error
affected int
)
ifu.defaults() ifu.defaults()
if len(ifu.hooks) == 0 { return withHooks[int, ItemFieldMutation](ctx, ifu.sqlSave, ifu.mutation, ifu.hooks)
if err = ifu.check(); err != nil {
return 0, err
}
affected, err = ifu.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ItemFieldMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = ifu.check(); err != nil {
return 0, err
}
ifu.mutation = mutation
affected, err = ifu.sqlSave(ctx)
mutation.done = true
return affected, err
})
for i := len(ifu.hooks) - 1; i >= 0; i-- {
if ifu.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = ifu.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, ifu.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -268,6 +235,9 @@ func (ifu *ItemFieldUpdate) check() error {
} }
func (ifu *ItemFieldUpdate) sqlSave(ctx context.Context) (n int, err error) { func (ifu *ItemFieldUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := ifu.check(); err != nil {
return n, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: itemfield.Table, Table: itemfield.Table,
@ -364,6 +334,7 @@ func (ifu *ItemFieldUpdate) sqlSave(ctx context.Context) (n int, err error) {
} }
return 0, err return 0, err
} }
ifu.mutation.done = true
return n, nil return n, nil
} }
@ -527,47 +498,8 @@ func (ifuo *ItemFieldUpdateOne) Select(field string, fields ...string) *ItemFiel
// Save executes the query and returns the updated ItemField entity. // Save executes the query and returns the updated ItemField entity.
func (ifuo *ItemFieldUpdateOne) Save(ctx context.Context) (*ItemField, error) { func (ifuo *ItemFieldUpdateOne) Save(ctx context.Context) (*ItemField, error) {
var (
err error
node *ItemField
)
ifuo.defaults() ifuo.defaults()
if len(ifuo.hooks) == 0 { return withHooks[*ItemField, ItemFieldMutation](ctx, ifuo.sqlSave, ifuo.mutation, ifuo.hooks)
if err = ifuo.check(); err != nil {
return nil, err
}
node, err = ifuo.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ItemFieldMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = ifuo.check(); err != nil {
return nil, err
}
ifuo.mutation = mutation
node, err = ifuo.sqlSave(ctx)
mutation.done = true
return node, err
})
for i := len(ifuo.hooks) - 1; i >= 0; i-- {
if ifuo.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = ifuo.hooks[i](mut)
}
v, err := mut.Mutate(ctx, ifuo.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*ItemField)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from ItemFieldMutation", v)
}
node = nv
}
return node, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -626,6 +558,9 @@ func (ifuo *ItemFieldUpdateOne) check() error {
} }
func (ifuo *ItemFieldUpdateOne) sqlSave(ctx context.Context) (_node *ItemField, err error) { func (ifuo *ItemFieldUpdateOne) sqlSave(ctx context.Context) (_node *ItemField, err error) {
if err := ifuo.check(); err != nil {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: itemfield.Table, Table: itemfield.Table,
@ -742,5 +677,6 @@ func (ifuo *ItemFieldUpdateOne) sqlSave(ctx context.Context) (_node *ItemField,
} }
return nil, err return nil, err
} }
ifuo.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -13,561 +13,367 @@ import (
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.
func ID(id uuid.UUID) predicate.Label { func ID(id uuid.UUID) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDEQ applies the EQ predicate on the ID field. // IDEQ applies the EQ predicate on the ID field.
func IDEQ(id uuid.UUID) predicate.Label { func IDEQ(id uuid.UUID) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDNEQ applies the NEQ predicate on the ID field. // IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id uuid.UUID) predicate.Label { func IDNEQ(id uuid.UUID) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldNEQ(FieldID, id))
s.Where(sql.NEQ(s.C(FieldID), id))
})
} }
// IDIn applies the In predicate on the ID field. // IDIn applies the In predicate on the ID field.
func IDIn(ids ...uuid.UUID) predicate.Label { func IDIn(ids ...uuid.UUID) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.In(s.C(FieldID), v...))
})
} }
// IDNotIn applies the NotIn predicate on the ID field. // IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...uuid.UUID) predicate.Label { func IDNotIn(ids ...uuid.UUID) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldNotIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.NotIn(s.C(FieldID), v...))
})
} }
// IDGT applies the GT predicate on the ID field. // IDGT applies the GT predicate on the ID field.
func IDGT(id uuid.UUID) predicate.Label { func IDGT(id uuid.UUID) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldGT(FieldID, id))
s.Where(sql.GT(s.C(FieldID), id))
})
} }
// IDGTE applies the GTE predicate on the ID field. // IDGTE applies the GTE predicate on the ID field.
func IDGTE(id uuid.UUID) predicate.Label { func IDGTE(id uuid.UUID) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldGTE(FieldID, id))
s.Where(sql.GTE(s.C(FieldID), id))
})
} }
// IDLT applies the LT predicate on the ID field. // IDLT applies the LT predicate on the ID field.
func IDLT(id uuid.UUID) predicate.Label { func IDLT(id uuid.UUID) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldLT(FieldID, id))
s.Where(sql.LT(s.C(FieldID), id))
})
} }
// IDLTE applies the LTE predicate on the ID field. // IDLTE applies the LTE predicate on the ID field.
func IDLTE(id uuid.UUID) predicate.Label { func IDLTE(id uuid.UUID) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldLTE(FieldID, id))
s.Where(sql.LTE(s.C(FieldID), id))
})
} }
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. // CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.Label { func CreatedAt(v time.Time) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. // UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.Label { func UpdatedAt(v time.Time) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// Name applies equality check predicate on the "name" field. It's identical to NameEQ. // Name applies equality check predicate on the "name" field. It's identical to NameEQ.
func Name(v string) predicate.Label { func Name(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldEQ(FieldName, v))
s.Where(sql.EQ(s.C(FieldName), v))
})
} }
// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. // Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ.
func Description(v string) predicate.Label { func Description(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldEQ(FieldDescription, v))
s.Where(sql.EQ(s.C(FieldDescription), v))
})
} }
// Color applies equality check predicate on the "color" field. It's identical to ColorEQ. // Color applies equality check predicate on the "color" field. It's identical to ColorEQ.
func Color(v string) predicate.Label { func Color(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldEQ(FieldColor, v))
s.Where(sql.EQ(s.C(FieldColor), v))
})
} }
// CreatedAtEQ applies the EQ predicate on the "created_at" field. // CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.Label { func CreatedAtEQ(v time.Time) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. // CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.Label { func CreatedAtNEQ(v time.Time) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldNEQ(FieldCreatedAt, v))
s.Where(sql.NEQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtIn applies the In predicate on the "created_at" field. // CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.Label { func CreatedAtIn(vs ...time.Time) predicate.Label {
v := make([]any, len(vs)) return predicate.Label(sql.FieldIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Label(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. // CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.Label { func CreatedAtNotIn(vs ...time.Time) predicate.Label {
v := make([]any, len(vs)) return predicate.Label(sql.FieldNotIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Label(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtGT applies the GT predicate on the "created_at" field. // CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.Label { func CreatedAtGT(v time.Time) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldGT(FieldCreatedAt, v))
s.Where(sql.GT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtGTE applies the GTE predicate on the "created_at" field. // CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.Label { func CreatedAtGTE(v time.Time) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldGTE(FieldCreatedAt, v))
s.Where(sql.GTE(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLT applies the LT predicate on the "created_at" field. // CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.Label { func CreatedAtLT(v time.Time) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldLT(FieldCreatedAt, v))
s.Where(sql.LT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLTE applies the LTE predicate on the "created_at" field. // CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.Label { func CreatedAtLTE(v time.Time) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldLTE(FieldCreatedAt, v))
s.Where(sql.LTE(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. // UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.Label { func UpdatedAtEQ(v time.Time) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. // UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.Label { func UpdatedAtNEQ(v time.Time) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldNEQ(FieldUpdatedAt, v))
s.Where(sql.NEQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtIn applies the In predicate on the "updated_at" field. // UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.Label { func UpdatedAtIn(vs ...time.Time) predicate.Label {
v := make([]any, len(vs)) return predicate.Label(sql.FieldIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Label(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. // UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.Label { func UpdatedAtNotIn(vs ...time.Time) predicate.Label {
v := make([]any, len(vs)) return predicate.Label(sql.FieldNotIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Label(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtGT applies the GT predicate on the "updated_at" field. // UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.Label { func UpdatedAtGT(v time.Time) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldGT(FieldUpdatedAt, v))
s.Where(sql.GT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. // UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.Label { func UpdatedAtGTE(v time.Time) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldGTE(FieldUpdatedAt, v))
s.Where(sql.GTE(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLT applies the LT predicate on the "updated_at" field. // UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.Label { func UpdatedAtLT(v time.Time) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldLT(FieldUpdatedAt, v))
s.Where(sql.LT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. // UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.Label { func UpdatedAtLTE(v time.Time) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldLTE(FieldUpdatedAt, v))
s.Where(sql.LTE(s.C(FieldUpdatedAt), v))
})
} }
// NameEQ applies the EQ predicate on the "name" field. // NameEQ applies the EQ predicate on the "name" field.
func NameEQ(v string) predicate.Label { func NameEQ(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldEQ(FieldName, v))
s.Where(sql.EQ(s.C(FieldName), v))
})
} }
// NameNEQ applies the NEQ predicate on the "name" field. // NameNEQ applies the NEQ predicate on the "name" field.
func NameNEQ(v string) predicate.Label { func NameNEQ(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldNEQ(FieldName, v))
s.Where(sql.NEQ(s.C(FieldName), v))
})
} }
// NameIn applies the In predicate on the "name" field. // NameIn applies the In predicate on the "name" field.
func NameIn(vs ...string) predicate.Label { func NameIn(vs ...string) predicate.Label {
v := make([]any, len(vs)) return predicate.Label(sql.FieldIn(FieldName, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Label(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldName), v...))
})
} }
// NameNotIn applies the NotIn predicate on the "name" field. // NameNotIn applies the NotIn predicate on the "name" field.
func NameNotIn(vs ...string) predicate.Label { func NameNotIn(vs ...string) predicate.Label {
v := make([]any, len(vs)) return predicate.Label(sql.FieldNotIn(FieldName, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Label(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldName), v...))
})
} }
// NameGT applies the GT predicate on the "name" field. // NameGT applies the GT predicate on the "name" field.
func NameGT(v string) predicate.Label { func NameGT(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldGT(FieldName, v))
s.Where(sql.GT(s.C(FieldName), v))
})
} }
// NameGTE applies the GTE predicate on the "name" field. // NameGTE applies the GTE predicate on the "name" field.
func NameGTE(v string) predicate.Label { func NameGTE(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldGTE(FieldName, v))
s.Where(sql.GTE(s.C(FieldName), v))
})
} }
// NameLT applies the LT predicate on the "name" field. // NameLT applies the LT predicate on the "name" field.
func NameLT(v string) predicate.Label { func NameLT(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldLT(FieldName, v))
s.Where(sql.LT(s.C(FieldName), v))
})
} }
// NameLTE applies the LTE predicate on the "name" field. // NameLTE applies the LTE predicate on the "name" field.
func NameLTE(v string) predicate.Label { func NameLTE(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldLTE(FieldName, v))
s.Where(sql.LTE(s.C(FieldName), v))
})
} }
// NameContains applies the Contains predicate on the "name" field. // NameContains applies the Contains predicate on the "name" field.
func NameContains(v string) predicate.Label { func NameContains(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldContains(FieldName, v))
s.Where(sql.Contains(s.C(FieldName), v))
})
} }
// NameHasPrefix applies the HasPrefix predicate on the "name" field. // NameHasPrefix applies the HasPrefix predicate on the "name" field.
func NameHasPrefix(v string) predicate.Label { func NameHasPrefix(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldHasPrefix(FieldName, v))
s.Where(sql.HasPrefix(s.C(FieldName), v))
})
} }
// NameHasSuffix applies the HasSuffix predicate on the "name" field. // NameHasSuffix applies the HasSuffix predicate on the "name" field.
func NameHasSuffix(v string) predicate.Label { func NameHasSuffix(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldHasSuffix(FieldName, v))
s.Where(sql.HasSuffix(s.C(FieldName), v))
})
} }
// NameEqualFold applies the EqualFold predicate on the "name" field. // NameEqualFold applies the EqualFold predicate on the "name" field.
func NameEqualFold(v string) predicate.Label { func NameEqualFold(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldEqualFold(FieldName, v))
s.Where(sql.EqualFold(s.C(FieldName), v))
})
} }
// NameContainsFold applies the ContainsFold predicate on the "name" field. // NameContainsFold applies the ContainsFold predicate on the "name" field.
func NameContainsFold(v string) predicate.Label { func NameContainsFold(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldContainsFold(FieldName, v))
s.Where(sql.ContainsFold(s.C(FieldName), v))
})
} }
// DescriptionEQ applies the EQ predicate on the "description" field. // DescriptionEQ applies the EQ predicate on the "description" field.
func DescriptionEQ(v string) predicate.Label { func DescriptionEQ(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldEQ(FieldDescription, v))
s.Where(sql.EQ(s.C(FieldDescription), v))
})
} }
// DescriptionNEQ applies the NEQ predicate on the "description" field. // DescriptionNEQ applies the NEQ predicate on the "description" field.
func DescriptionNEQ(v string) predicate.Label { func DescriptionNEQ(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldNEQ(FieldDescription, v))
s.Where(sql.NEQ(s.C(FieldDescription), v))
})
} }
// DescriptionIn applies the In predicate on the "description" field. // DescriptionIn applies the In predicate on the "description" field.
func DescriptionIn(vs ...string) predicate.Label { func DescriptionIn(vs ...string) predicate.Label {
v := make([]any, len(vs)) return predicate.Label(sql.FieldIn(FieldDescription, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Label(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldDescription), v...))
})
} }
// DescriptionNotIn applies the NotIn predicate on the "description" field. // DescriptionNotIn applies the NotIn predicate on the "description" field.
func DescriptionNotIn(vs ...string) predicate.Label { func DescriptionNotIn(vs ...string) predicate.Label {
v := make([]any, len(vs)) return predicate.Label(sql.FieldNotIn(FieldDescription, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Label(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldDescription), v...))
})
} }
// DescriptionGT applies the GT predicate on the "description" field. // DescriptionGT applies the GT predicate on the "description" field.
func DescriptionGT(v string) predicate.Label { func DescriptionGT(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldGT(FieldDescription, v))
s.Where(sql.GT(s.C(FieldDescription), v))
})
} }
// DescriptionGTE applies the GTE predicate on the "description" field. // DescriptionGTE applies the GTE predicate on the "description" field.
func DescriptionGTE(v string) predicate.Label { func DescriptionGTE(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldGTE(FieldDescription, v))
s.Where(sql.GTE(s.C(FieldDescription), v))
})
} }
// DescriptionLT applies the LT predicate on the "description" field. // DescriptionLT applies the LT predicate on the "description" field.
func DescriptionLT(v string) predicate.Label { func DescriptionLT(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldLT(FieldDescription, v))
s.Where(sql.LT(s.C(FieldDescription), v))
})
} }
// DescriptionLTE applies the LTE predicate on the "description" field. // DescriptionLTE applies the LTE predicate on the "description" field.
func DescriptionLTE(v string) predicate.Label { func DescriptionLTE(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldLTE(FieldDescription, v))
s.Where(sql.LTE(s.C(FieldDescription), v))
})
} }
// DescriptionContains applies the Contains predicate on the "description" field. // DescriptionContains applies the Contains predicate on the "description" field.
func DescriptionContains(v string) predicate.Label { func DescriptionContains(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldContains(FieldDescription, v))
s.Where(sql.Contains(s.C(FieldDescription), v))
})
} }
// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. // DescriptionHasPrefix applies the HasPrefix predicate on the "description" field.
func DescriptionHasPrefix(v string) predicate.Label { func DescriptionHasPrefix(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldHasPrefix(FieldDescription, v))
s.Where(sql.HasPrefix(s.C(FieldDescription), v))
})
} }
// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. // DescriptionHasSuffix applies the HasSuffix predicate on the "description" field.
func DescriptionHasSuffix(v string) predicate.Label { func DescriptionHasSuffix(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldHasSuffix(FieldDescription, v))
s.Where(sql.HasSuffix(s.C(FieldDescription), v))
})
} }
// DescriptionIsNil applies the IsNil predicate on the "description" field. // DescriptionIsNil applies the IsNil predicate on the "description" field.
func DescriptionIsNil() predicate.Label { func DescriptionIsNil() predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldIsNull(FieldDescription))
s.Where(sql.IsNull(s.C(FieldDescription)))
})
} }
// DescriptionNotNil applies the NotNil predicate on the "description" field. // DescriptionNotNil applies the NotNil predicate on the "description" field.
func DescriptionNotNil() predicate.Label { func DescriptionNotNil() predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldNotNull(FieldDescription))
s.Where(sql.NotNull(s.C(FieldDescription)))
})
} }
// DescriptionEqualFold applies the EqualFold predicate on the "description" field. // DescriptionEqualFold applies the EqualFold predicate on the "description" field.
func DescriptionEqualFold(v string) predicate.Label { func DescriptionEqualFold(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldEqualFold(FieldDescription, v))
s.Where(sql.EqualFold(s.C(FieldDescription), v))
})
} }
// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. // DescriptionContainsFold applies the ContainsFold predicate on the "description" field.
func DescriptionContainsFold(v string) predicate.Label { func DescriptionContainsFold(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldContainsFold(FieldDescription, v))
s.Where(sql.ContainsFold(s.C(FieldDescription), v))
})
} }
// ColorEQ applies the EQ predicate on the "color" field. // ColorEQ applies the EQ predicate on the "color" field.
func ColorEQ(v string) predicate.Label { func ColorEQ(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldEQ(FieldColor, v))
s.Where(sql.EQ(s.C(FieldColor), v))
})
} }
// ColorNEQ applies the NEQ predicate on the "color" field. // ColorNEQ applies the NEQ predicate on the "color" field.
func ColorNEQ(v string) predicate.Label { func ColorNEQ(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldNEQ(FieldColor, v))
s.Where(sql.NEQ(s.C(FieldColor), v))
})
} }
// ColorIn applies the In predicate on the "color" field. // ColorIn applies the In predicate on the "color" field.
func ColorIn(vs ...string) predicate.Label { func ColorIn(vs ...string) predicate.Label {
v := make([]any, len(vs)) return predicate.Label(sql.FieldIn(FieldColor, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Label(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldColor), v...))
})
} }
// ColorNotIn applies the NotIn predicate on the "color" field. // ColorNotIn applies the NotIn predicate on the "color" field.
func ColorNotIn(vs ...string) predicate.Label { func ColorNotIn(vs ...string) predicate.Label {
v := make([]any, len(vs)) return predicate.Label(sql.FieldNotIn(FieldColor, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Label(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldColor), v...))
})
} }
// ColorGT applies the GT predicate on the "color" field. // ColorGT applies the GT predicate on the "color" field.
func ColorGT(v string) predicate.Label { func ColorGT(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldGT(FieldColor, v))
s.Where(sql.GT(s.C(FieldColor), v))
})
} }
// ColorGTE applies the GTE predicate on the "color" field. // ColorGTE applies the GTE predicate on the "color" field.
func ColorGTE(v string) predicate.Label { func ColorGTE(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldGTE(FieldColor, v))
s.Where(sql.GTE(s.C(FieldColor), v))
})
} }
// ColorLT applies the LT predicate on the "color" field. // ColorLT applies the LT predicate on the "color" field.
func ColorLT(v string) predicate.Label { func ColorLT(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldLT(FieldColor, v))
s.Where(sql.LT(s.C(FieldColor), v))
})
} }
// ColorLTE applies the LTE predicate on the "color" field. // ColorLTE applies the LTE predicate on the "color" field.
func ColorLTE(v string) predicate.Label { func ColorLTE(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldLTE(FieldColor, v))
s.Where(sql.LTE(s.C(FieldColor), v))
})
} }
// ColorContains applies the Contains predicate on the "color" field. // ColorContains applies the Contains predicate on the "color" field.
func ColorContains(v string) predicate.Label { func ColorContains(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldContains(FieldColor, v))
s.Where(sql.Contains(s.C(FieldColor), v))
})
} }
// ColorHasPrefix applies the HasPrefix predicate on the "color" field. // ColorHasPrefix applies the HasPrefix predicate on the "color" field.
func ColorHasPrefix(v string) predicate.Label { func ColorHasPrefix(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldHasPrefix(FieldColor, v))
s.Where(sql.HasPrefix(s.C(FieldColor), v))
})
} }
// ColorHasSuffix applies the HasSuffix predicate on the "color" field. // ColorHasSuffix applies the HasSuffix predicate on the "color" field.
func ColorHasSuffix(v string) predicate.Label { func ColorHasSuffix(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldHasSuffix(FieldColor, v))
s.Where(sql.HasSuffix(s.C(FieldColor), v))
})
} }
// ColorIsNil applies the IsNil predicate on the "color" field. // ColorIsNil applies the IsNil predicate on the "color" field.
func ColorIsNil() predicate.Label { func ColorIsNil() predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldIsNull(FieldColor))
s.Where(sql.IsNull(s.C(FieldColor)))
})
} }
// ColorNotNil applies the NotNil predicate on the "color" field. // ColorNotNil applies the NotNil predicate on the "color" field.
func ColorNotNil() predicate.Label { func ColorNotNil() predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldNotNull(FieldColor))
s.Where(sql.NotNull(s.C(FieldColor)))
})
} }
// ColorEqualFold applies the EqualFold predicate on the "color" field. // ColorEqualFold applies the EqualFold predicate on the "color" field.
func ColorEqualFold(v string) predicate.Label { func ColorEqualFold(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldEqualFold(FieldColor, v))
s.Where(sql.EqualFold(s.C(FieldColor), v))
})
} }
// ColorContainsFold applies the ContainsFold predicate on the "color" field. // ColorContainsFold applies the ContainsFold predicate on the "color" field.
func ColorContainsFold(v string) predicate.Label { func ColorContainsFold(v string) predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(sql.FieldContainsFold(FieldColor, v))
s.Where(sql.ContainsFold(s.C(FieldColor), v))
})
} }
// HasGroup applies the HasEdge predicate on the "group" edge. // HasGroup applies the HasEdge predicate on the "group" edge.
@ -575,7 +381,6 @@ func HasGroup() predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(GroupTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn), sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)
@ -603,7 +408,6 @@ func HasItems() predicate.Label {
return predicate.Label(func(s *sql.Selector) { return predicate.Label(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(ItemsTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, ItemsTable, ItemsPrimaryKey...), sqlgraph.Edge(sqlgraph.M2M, false, ItemsTable, ItemsPrimaryKey...),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)

View file

@ -132,50 +132,8 @@ func (lc *LabelCreate) Mutation() *LabelMutation {
// Save creates the Label in the database. // Save creates the Label in the database.
func (lc *LabelCreate) Save(ctx context.Context) (*Label, error) { func (lc *LabelCreate) Save(ctx context.Context) (*Label, error) {
var (
err error
node *Label
)
lc.defaults() lc.defaults()
if len(lc.hooks) == 0 { return withHooks[*Label, LabelMutation](ctx, lc.sqlSave, lc.mutation, lc.hooks)
if err = lc.check(); err != nil {
return nil, err
}
node, err = lc.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*LabelMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = lc.check(); err != nil {
return nil, err
}
lc.mutation = mutation
if node, err = lc.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(lc.hooks) - 1; i >= 0; i-- {
if lc.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = lc.hooks[i](mut)
}
v, err := mut.Mutate(ctx, lc.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Label)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from LabelMutation", v)
}
node = nv
}
return node, err
} }
// SaveX calls Save and panics if Save returns an error. // SaveX calls Save and panics if Save returns an error.
@ -249,6 +207,9 @@ func (lc *LabelCreate) check() error {
} }
func (lc *LabelCreate) sqlSave(ctx context.Context) (*Label, error) { func (lc *LabelCreate) sqlSave(ctx context.Context) (*Label, error) {
if err := lc.check(); err != nil {
return nil, err
}
_node, _spec := lc.createSpec() _node, _spec := lc.createSpec()
if err := sqlgraph.CreateNode(ctx, lc.driver, _spec); err != nil { if err := sqlgraph.CreateNode(ctx, lc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) { if sqlgraph.IsConstraintError(err) {
@ -263,6 +224,8 @@ func (lc *LabelCreate) sqlSave(ctx context.Context) (*Label, error) {
return nil, err return nil, err
} }
} }
lc.mutation.id = &_node.ID
lc.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -4,7 +4,6 @@ package ent
import ( import (
"context" "context"
"fmt"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
@ -28,34 +27,7 @@ func (ld *LabelDelete) Where(ps ...predicate.Label) *LabelDelete {
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (ld *LabelDelete) Exec(ctx context.Context) (int, error) { func (ld *LabelDelete) Exec(ctx context.Context) (int, error) {
var ( return withHooks[int, LabelMutation](ctx, ld.sqlExec, ld.mutation, ld.hooks)
err error
affected int
)
if len(ld.hooks) == 0 {
affected, err = ld.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*LabelMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
ld.mutation = mutation
affected, err = ld.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(ld.hooks) - 1; i >= 0; i-- {
if ld.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = ld.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, ld.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
@ -88,6 +60,7 @@ func (ld *LabelDelete) sqlExec(ctx context.Context) (int, error) {
if err != nil && sqlgraph.IsConstraintError(err) { if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
ld.mutation.done = true
return affected, err return affected, err
} }

View file

@ -26,6 +26,7 @@ type LabelQuery struct {
unique *bool unique *bool
order []OrderFunc order []OrderFunc
fields []string fields []string
inters []Interceptor
predicates []predicate.Label predicates []predicate.Label
withGroup *GroupQuery withGroup *GroupQuery
withItems *ItemQuery withItems *ItemQuery
@ -41,13 +42,13 @@ func (lq *LabelQuery) Where(ps ...predicate.Label) *LabelQuery {
return lq return lq
} }
// Limit adds a limit step to the query. // Limit the number of records to be returned by this query.
func (lq *LabelQuery) Limit(limit int) *LabelQuery { func (lq *LabelQuery) Limit(limit int) *LabelQuery {
lq.limit = &limit lq.limit = &limit
return lq return lq
} }
// Offset adds an offset step to the query. // Offset to start from.
func (lq *LabelQuery) Offset(offset int) *LabelQuery { func (lq *LabelQuery) Offset(offset int) *LabelQuery {
lq.offset = &offset lq.offset = &offset
return lq return lq
@ -60,7 +61,7 @@ func (lq *LabelQuery) Unique(unique bool) *LabelQuery {
return lq return lq
} }
// Order adds an order step to the query. // Order specifies how the records should be ordered.
func (lq *LabelQuery) Order(o ...OrderFunc) *LabelQuery { func (lq *LabelQuery) Order(o ...OrderFunc) *LabelQuery {
lq.order = append(lq.order, o...) lq.order = append(lq.order, o...)
return lq return lq
@ -68,7 +69,7 @@ func (lq *LabelQuery) Order(o ...OrderFunc) *LabelQuery {
// QueryGroup chains the current query on the "group" edge. // QueryGroup chains the current query on the "group" edge.
func (lq *LabelQuery) QueryGroup() *GroupQuery { func (lq *LabelQuery) QueryGroup() *GroupQuery {
query := &GroupQuery{config: lq.config} query := (&GroupClient{config: lq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := lq.prepareQuery(ctx); err != nil { if err := lq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -90,7 +91,7 @@ func (lq *LabelQuery) QueryGroup() *GroupQuery {
// QueryItems chains the current query on the "items" edge. // QueryItems chains the current query on the "items" edge.
func (lq *LabelQuery) QueryItems() *ItemQuery { func (lq *LabelQuery) QueryItems() *ItemQuery {
query := &ItemQuery{config: lq.config} query := (&ItemClient{config: lq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := lq.prepareQuery(ctx); err != nil { if err := lq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -113,7 +114,7 @@ func (lq *LabelQuery) QueryItems() *ItemQuery {
// First returns the first Label entity from the query. // First returns the first Label entity from the query.
// Returns a *NotFoundError when no Label was found. // Returns a *NotFoundError when no Label was found.
func (lq *LabelQuery) First(ctx context.Context) (*Label, error) { func (lq *LabelQuery) First(ctx context.Context) (*Label, error) {
nodes, err := lq.Limit(1).All(ctx) nodes, err := lq.Limit(1).All(newQueryContext(ctx, TypeLabel, "First"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -136,7 +137,7 @@ func (lq *LabelQuery) FirstX(ctx context.Context) *Label {
// Returns a *NotFoundError when no Label ID was found. // Returns a *NotFoundError when no Label ID was found.
func (lq *LabelQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { func (lq *LabelQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = lq.Limit(1).IDs(ctx); err != nil { if ids, err = lq.Limit(1).IDs(newQueryContext(ctx, TypeLabel, "FirstID")); err != nil {
return return
} }
if len(ids) == 0 { if len(ids) == 0 {
@ -159,7 +160,7 @@ func (lq *LabelQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one Label entity is found. // Returns a *NotSingularError when more than one Label entity is found.
// Returns a *NotFoundError when no Label entities are found. // Returns a *NotFoundError when no Label entities are found.
func (lq *LabelQuery) Only(ctx context.Context) (*Label, error) { func (lq *LabelQuery) Only(ctx context.Context) (*Label, error) {
nodes, err := lq.Limit(2).All(ctx) nodes, err := lq.Limit(2).All(newQueryContext(ctx, TypeLabel, "Only"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -187,7 +188,7 @@ func (lq *LabelQuery) OnlyX(ctx context.Context) *Label {
// Returns a *NotFoundError when no entities are found. // Returns a *NotFoundError when no entities are found.
func (lq *LabelQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { func (lq *LabelQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = lq.Limit(2).IDs(ctx); err != nil { if ids, err = lq.Limit(2).IDs(newQueryContext(ctx, TypeLabel, "OnlyID")); err != nil {
return return
} }
switch len(ids) { switch len(ids) {
@ -212,10 +213,12 @@ func (lq *LabelQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of Labels. // All executes the query and returns a list of Labels.
func (lq *LabelQuery) All(ctx context.Context) ([]*Label, error) { func (lq *LabelQuery) All(ctx context.Context) ([]*Label, error) {
ctx = newQueryContext(ctx, TypeLabel, "All")
if err := lq.prepareQuery(ctx); err != nil { if err := lq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return lq.sqlAll(ctx) qr := querierAll[[]*Label, *LabelQuery]()
return withInterceptors[[]*Label](ctx, lq, qr, lq.inters)
} }
// AllX is like All, but panics if an error occurs. // AllX is like All, but panics if an error occurs.
@ -230,6 +233,7 @@ func (lq *LabelQuery) AllX(ctx context.Context) []*Label {
// IDs executes the query and returns a list of Label IDs. // IDs executes the query and returns a list of Label IDs.
func (lq *LabelQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (lq *LabelQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID var ids []uuid.UUID
ctx = newQueryContext(ctx, TypeLabel, "IDs")
if err := lq.Select(label.FieldID).Scan(ctx, &ids); err != nil { if err := lq.Select(label.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
@ -247,10 +251,11 @@ func (lq *LabelQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query. // Count returns the count of the given query.
func (lq *LabelQuery) Count(ctx context.Context) (int, error) { func (lq *LabelQuery) Count(ctx context.Context) (int, error) {
ctx = newQueryContext(ctx, TypeLabel, "Count")
if err := lq.prepareQuery(ctx); err != nil { if err := lq.prepareQuery(ctx); err != nil {
return 0, err return 0, err
} }
return lq.sqlCount(ctx) return withInterceptors[int](ctx, lq, querierCount[*LabelQuery](), lq.inters)
} }
// CountX is like Count, but panics if an error occurs. // CountX is like Count, but panics if an error occurs.
@ -264,10 +269,15 @@ func (lq *LabelQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph. // Exist returns true if the query has elements in the graph.
func (lq *LabelQuery) Exist(ctx context.Context) (bool, error) { func (lq *LabelQuery) Exist(ctx context.Context) (bool, error) {
if err := lq.prepareQuery(ctx); err != nil { ctx = newQueryContext(ctx, TypeLabel, "Exist")
return false, err switch _, err := lq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
} }
return lq.sqlExist(ctx)
} }
// ExistX is like Exist, but panics if an error occurs. // ExistX is like Exist, but panics if an error occurs.
@ -290,6 +300,7 @@ func (lq *LabelQuery) Clone() *LabelQuery {
limit: lq.limit, limit: lq.limit,
offset: lq.offset, offset: lq.offset,
order: append([]OrderFunc{}, lq.order...), order: append([]OrderFunc{}, lq.order...),
inters: append([]Interceptor{}, lq.inters...),
predicates: append([]predicate.Label{}, lq.predicates...), predicates: append([]predicate.Label{}, lq.predicates...),
withGroup: lq.withGroup.Clone(), withGroup: lq.withGroup.Clone(),
withItems: lq.withItems.Clone(), withItems: lq.withItems.Clone(),
@ -303,7 +314,7 @@ func (lq *LabelQuery) Clone() *LabelQuery {
// WithGroup tells the query-builder to eager-load the nodes that are connected to // WithGroup tells the query-builder to eager-load the nodes that are connected to
// the "group" edge. The optional arguments are used to configure the query builder of the edge. // the "group" edge. The optional arguments are used to configure the query builder of the edge.
func (lq *LabelQuery) WithGroup(opts ...func(*GroupQuery)) *LabelQuery { func (lq *LabelQuery) WithGroup(opts ...func(*GroupQuery)) *LabelQuery {
query := &GroupQuery{config: lq.config} query := (&GroupClient{config: lq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -314,7 +325,7 @@ func (lq *LabelQuery) WithGroup(opts ...func(*GroupQuery)) *LabelQuery {
// WithItems tells the query-builder to eager-load the nodes that are connected to // WithItems tells the query-builder to eager-load the nodes that are connected to
// the "items" edge. The optional arguments are used to configure the query builder of the edge. // the "items" edge. The optional arguments are used to configure the query builder of the edge.
func (lq *LabelQuery) WithItems(opts ...func(*ItemQuery)) *LabelQuery { func (lq *LabelQuery) WithItems(opts ...func(*ItemQuery)) *LabelQuery {
query := &ItemQuery{config: lq.config} query := (&ItemClient{config: lq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -337,16 +348,11 @@ func (lq *LabelQuery) WithItems(opts ...func(*ItemQuery)) *LabelQuery {
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (lq *LabelQuery) GroupBy(field string, fields ...string) *LabelGroupBy { func (lq *LabelQuery) GroupBy(field string, fields ...string) *LabelGroupBy {
grbuild := &LabelGroupBy{config: lq.config} lq.fields = append([]string{field}, fields...)
grbuild.fields = append([]string{field}, fields...) grbuild := &LabelGroupBy{build: lq}
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { grbuild.flds = &lq.fields
if err := lq.prepareQuery(ctx); err != nil {
return nil, err
}
return lq.sqlQuery(ctx), nil
}
grbuild.label = label.Label grbuild.label = label.Label
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan grbuild.scan = grbuild.Scan
return grbuild return grbuild
} }
@ -364,10 +370,10 @@ func (lq *LabelQuery) GroupBy(field string, fields ...string) *LabelGroupBy {
// Scan(ctx, &v) // Scan(ctx, &v)
func (lq *LabelQuery) Select(fields ...string) *LabelSelect { func (lq *LabelQuery) Select(fields ...string) *LabelSelect {
lq.fields = append(lq.fields, fields...) lq.fields = append(lq.fields, fields...)
selbuild := &LabelSelect{LabelQuery: lq} sbuild := &LabelSelect{LabelQuery: lq}
selbuild.label = label.Label sbuild.label = label.Label
selbuild.flds, selbuild.scan = &lq.fields, selbuild.Scan sbuild.flds, sbuild.scan = &lq.fields, sbuild.Scan
return selbuild return sbuild
} }
// Aggregate returns a LabelSelect configured with the given aggregations. // Aggregate returns a LabelSelect configured with the given aggregations.
@ -376,6 +382,16 @@ func (lq *LabelQuery) Aggregate(fns ...AggregateFunc) *LabelSelect {
} }
func (lq *LabelQuery) prepareQuery(ctx context.Context) error { func (lq *LabelQuery) prepareQuery(ctx context.Context) error {
for _, inter := range lq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, lq); err != nil {
return err
}
}
}
for _, f := range lq.fields { for _, f := range lq.fields {
if !label.ValidColumn(f) { if !label.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
@ -538,17 +554,6 @@ func (lq *LabelQuery) sqlCount(ctx context.Context) (int, error) {
return sqlgraph.CountNodes(ctx, lq.driver, _spec) return sqlgraph.CountNodes(ctx, lq.driver, _spec)
} }
func (lq *LabelQuery) sqlExist(ctx context.Context) (bool, error) {
switch _, err := lq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
func (lq *LabelQuery) querySpec() *sqlgraph.QuerySpec { func (lq *LabelQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
@ -631,13 +636,8 @@ func (lq *LabelQuery) sqlQuery(ctx context.Context) *sql.Selector {
// LabelGroupBy is the group-by builder for Label entities. // LabelGroupBy is the group-by builder for Label entities.
type LabelGroupBy struct { type LabelGroupBy struct {
config
selector selector
fields []string build *LabelQuery
fns []AggregateFunc
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
} }
// Aggregate adds the given aggregation functions to the group-by query. // Aggregate adds the given aggregation functions to the group-by query.
@ -646,58 +646,46 @@ func (lgb *LabelGroupBy) Aggregate(fns ...AggregateFunc) *LabelGroupBy {
return lgb return lgb
} }
// Scan applies the group-by query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (lgb *LabelGroupBy) Scan(ctx context.Context, v any) error { func (lgb *LabelGroupBy) Scan(ctx context.Context, v any) error {
query, err := lgb.path(ctx) ctx = newQueryContext(ctx, TypeLabel, "GroupBy")
if err != nil { if err := lgb.build.prepareQuery(ctx); err != nil {
return err return err
} }
lgb.sql = query return scanWithInterceptors[*LabelQuery, *LabelGroupBy](ctx, lgb.build, lgb, lgb.build.inters, v)
return lgb.sqlScan(ctx, v)
} }
func (lgb *LabelGroupBy) sqlScan(ctx context.Context, v any) error { func (lgb *LabelGroupBy) sqlScan(ctx context.Context, root *LabelQuery, v any) error {
for _, f := range lgb.fields { selector := root.sqlQuery(ctx).Select()
if !label.ValidColumn(f) { aggregation := make([]string, 0, len(lgb.fns))
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} for _, fn := range lgb.fns {
} aggregation = append(aggregation, fn(selector))
} }
selector := lgb.sqlQuery() if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*lgb.flds)+len(lgb.fns))
for _, f := range *lgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*lgb.flds...)...)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return err return err
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() query, args := selector.Query()
if err := lgb.driver.Query(ctx, query, args, rows); err != nil { if err := lgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }
defer rows.Close() defer rows.Close()
return sql.ScanSlice(rows, v) return sql.ScanSlice(rows, v)
} }
func (lgb *LabelGroupBy) sqlQuery() *sql.Selector {
selector := lgb.sql.Select()
aggregation := make([]string, 0, len(lgb.fns))
for _, fn := range lgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(lgb.fields)+len(lgb.fns))
for _, f := range lgb.fields {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
return selector.GroupBy(selector.Columns(lgb.fields...)...)
}
// LabelSelect is the builder for selecting fields of Label entities. // LabelSelect is the builder for selecting fields of Label entities.
type LabelSelect struct { type LabelSelect struct {
*LabelQuery *LabelQuery
selector selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
@ -708,26 +696,27 @@ func (ls *LabelSelect) Aggregate(fns ...AggregateFunc) *LabelSelect {
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (ls *LabelSelect) Scan(ctx context.Context, v any) error { func (ls *LabelSelect) Scan(ctx context.Context, v any) error {
ctx = newQueryContext(ctx, TypeLabel, "Select")
if err := ls.prepareQuery(ctx); err != nil { if err := ls.prepareQuery(ctx); err != nil {
return err return err
} }
ls.sql = ls.LabelQuery.sqlQuery(ctx) return scanWithInterceptors[*LabelQuery, *LabelSelect](ctx, ls.LabelQuery, ls, ls.inters, v)
return ls.sqlScan(ctx, v)
} }
func (ls *LabelSelect) sqlScan(ctx context.Context, v any) error { func (ls *LabelSelect) sqlScan(ctx context.Context, root *LabelQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(ls.fns)) aggregation := make([]string, 0, len(ls.fns))
for _, fn := range ls.fns { for _, fn := range ls.fns {
aggregation = append(aggregation, fn(ls.sql)) aggregation = append(aggregation, fn(selector))
} }
switch n := len(*ls.selector.flds); { switch n := len(*ls.selector.flds); {
case n == 0 && len(aggregation) > 0: case n == 0 && len(aggregation) > 0:
ls.sql.Select(aggregation...) selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0: case n != 0 && len(aggregation) > 0:
ls.sql.AppendSelect(aggregation...) selector.AppendSelect(aggregation...)
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := ls.sql.Query() query, args := selector.Query()
if err := ls.driver.Query(ctx, query, args, rows); err != nil { if err := ls.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }

View file

@ -143,41 +143,8 @@ func (lu *LabelUpdate) RemoveItems(i ...*Item) *LabelUpdate {
// Save executes the query and returns the number of nodes affected by the update operation. // Save executes the query and returns the number of nodes affected by the update operation.
func (lu *LabelUpdate) Save(ctx context.Context) (int, error) { func (lu *LabelUpdate) Save(ctx context.Context) (int, error) {
var (
err error
affected int
)
lu.defaults() lu.defaults()
if len(lu.hooks) == 0 { return withHooks[int, LabelMutation](ctx, lu.sqlSave, lu.mutation, lu.hooks)
if err = lu.check(); err != nil {
return 0, err
}
affected, err = lu.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*LabelMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = lu.check(); err != nil {
return 0, err
}
lu.mutation = mutation
affected, err = lu.sqlSave(ctx)
mutation.done = true
return affected, err
})
for i := len(lu.hooks) - 1; i >= 0; i-- {
if lu.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = lu.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, lu.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -234,6 +201,9 @@ func (lu *LabelUpdate) check() error {
} }
func (lu *LabelUpdate) sqlSave(ctx context.Context) (n int, err error) { func (lu *LabelUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := lu.check(); err != nil {
return n, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: label.Table, Table: label.Table,
@ -366,6 +336,7 @@ func (lu *LabelUpdate) sqlSave(ctx context.Context) (n int, err error) {
} }
return 0, err return 0, err
} }
lu.mutation.done = true
return n, nil return n, nil
} }
@ -496,47 +467,8 @@ func (luo *LabelUpdateOne) Select(field string, fields ...string) *LabelUpdateOn
// Save executes the query and returns the updated Label entity. // Save executes the query and returns the updated Label entity.
func (luo *LabelUpdateOne) Save(ctx context.Context) (*Label, error) { func (luo *LabelUpdateOne) Save(ctx context.Context) (*Label, error) {
var (
err error
node *Label
)
luo.defaults() luo.defaults()
if len(luo.hooks) == 0 { return withHooks[*Label, LabelMutation](ctx, luo.sqlSave, luo.mutation, luo.hooks)
if err = luo.check(); err != nil {
return nil, err
}
node, err = luo.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*LabelMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = luo.check(); err != nil {
return nil, err
}
luo.mutation = mutation
node, err = luo.sqlSave(ctx)
mutation.done = true
return node, err
})
for i := len(luo.hooks) - 1; i >= 0; i-- {
if luo.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = luo.hooks[i](mut)
}
v, err := mut.Mutate(ctx, luo.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Label)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from LabelMutation", v)
}
node = nv
}
return node, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -593,6 +525,9 @@ func (luo *LabelUpdateOne) check() error {
} }
func (luo *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error) { func (luo *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error) {
if err := luo.check(); err != nil {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: label.Table, Table: label.Table,
@ -745,5 +680,6 @@ func (luo *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error
} }
return nil, err return nil, err
} }
luo.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -13,441 +13,287 @@ import (
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.
func ID(id uuid.UUID) predicate.Location { func ID(id uuid.UUID) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDEQ applies the EQ predicate on the ID field. // IDEQ applies the EQ predicate on the ID field.
func IDEQ(id uuid.UUID) predicate.Location { func IDEQ(id uuid.UUID) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDNEQ applies the NEQ predicate on the ID field. // IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id uuid.UUID) predicate.Location { func IDNEQ(id uuid.UUID) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldNEQ(FieldID, id))
s.Where(sql.NEQ(s.C(FieldID), id))
})
} }
// IDIn applies the In predicate on the ID field. // IDIn applies the In predicate on the ID field.
func IDIn(ids ...uuid.UUID) predicate.Location { func IDIn(ids ...uuid.UUID) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.In(s.C(FieldID), v...))
})
} }
// IDNotIn applies the NotIn predicate on the ID field. // IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...uuid.UUID) predicate.Location { func IDNotIn(ids ...uuid.UUID) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldNotIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.NotIn(s.C(FieldID), v...))
})
} }
// IDGT applies the GT predicate on the ID field. // IDGT applies the GT predicate on the ID field.
func IDGT(id uuid.UUID) predicate.Location { func IDGT(id uuid.UUID) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldGT(FieldID, id))
s.Where(sql.GT(s.C(FieldID), id))
})
} }
// IDGTE applies the GTE predicate on the ID field. // IDGTE applies the GTE predicate on the ID field.
func IDGTE(id uuid.UUID) predicate.Location { func IDGTE(id uuid.UUID) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldGTE(FieldID, id))
s.Where(sql.GTE(s.C(FieldID), id))
})
} }
// IDLT applies the LT predicate on the ID field. // IDLT applies the LT predicate on the ID field.
func IDLT(id uuid.UUID) predicate.Location { func IDLT(id uuid.UUID) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldLT(FieldID, id))
s.Where(sql.LT(s.C(FieldID), id))
})
} }
// IDLTE applies the LTE predicate on the ID field. // IDLTE applies the LTE predicate on the ID field.
func IDLTE(id uuid.UUID) predicate.Location { func IDLTE(id uuid.UUID) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldLTE(FieldID, id))
s.Where(sql.LTE(s.C(FieldID), id))
})
} }
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. // CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.Location { func CreatedAt(v time.Time) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. // UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.Location { func UpdatedAt(v time.Time) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// Name applies equality check predicate on the "name" field. It's identical to NameEQ. // Name applies equality check predicate on the "name" field. It's identical to NameEQ.
func Name(v string) predicate.Location { func Name(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldEQ(FieldName, v))
s.Where(sql.EQ(s.C(FieldName), v))
})
} }
// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. // Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ.
func Description(v string) predicate.Location { func Description(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldEQ(FieldDescription, v))
s.Where(sql.EQ(s.C(FieldDescription), v))
})
} }
// CreatedAtEQ applies the EQ predicate on the "created_at" field. // CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.Location { func CreatedAtEQ(v time.Time) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. // CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.Location { func CreatedAtNEQ(v time.Time) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldNEQ(FieldCreatedAt, v))
s.Where(sql.NEQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtIn applies the In predicate on the "created_at" field. // CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.Location { func CreatedAtIn(vs ...time.Time) predicate.Location {
v := make([]any, len(vs)) return predicate.Location(sql.FieldIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Location(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. // CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.Location { func CreatedAtNotIn(vs ...time.Time) predicate.Location {
v := make([]any, len(vs)) return predicate.Location(sql.FieldNotIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Location(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtGT applies the GT predicate on the "created_at" field. // CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.Location { func CreatedAtGT(v time.Time) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldGT(FieldCreatedAt, v))
s.Where(sql.GT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtGTE applies the GTE predicate on the "created_at" field. // CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.Location { func CreatedAtGTE(v time.Time) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldGTE(FieldCreatedAt, v))
s.Where(sql.GTE(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLT applies the LT predicate on the "created_at" field. // CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.Location { func CreatedAtLT(v time.Time) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldLT(FieldCreatedAt, v))
s.Where(sql.LT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLTE applies the LTE predicate on the "created_at" field. // CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.Location { func CreatedAtLTE(v time.Time) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldLTE(FieldCreatedAt, v))
s.Where(sql.LTE(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. // UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.Location { func UpdatedAtEQ(v time.Time) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. // UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.Location { func UpdatedAtNEQ(v time.Time) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldNEQ(FieldUpdatedAt, v))
s.Where(sql.NEQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtIn applies the In predicate on the "updated_at" field. // UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.Location { func UpdatedAtIn(vs ...time.Time) predicate.Location {
v := make([]any, len(vs)) return predicate.Location(sql.FieldIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Location(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. // UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.Location { func UpdatedAtNotIn(vs ...time.Time) predicate.Location {
v := make([]any, len(vs)) return predicate.Location(sql.FieldNotIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Location(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtGT applies the GT predicate on the "updated_at" field. // UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.Location { func UpdatedAtGT(v time.Time) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldGT(FieldUpdatedAt, v))
s.Where(sql.GT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. // UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.Location { func UpdatedAtGTE(v time.Time) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldGTE(FieldUpdatedAt, v))
s.Where(sql.GTE(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLT applies the LT predicate on the "updated_at" field. // UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.Location { func UpdatedAtLT(v time.Time) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldLT(FieldUpdatedAt, v))
s.Where(sql.LT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. // UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.Location { func UpdatedAtLTE(v time.Time) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldLTE(FieldUpdatedAt, v))
s.Where(sql.LTE(s.C(FieldUpdatedAt), v))
})
} }
// NameEQ applies the EQ predicate on the "name" field. // NameEQ applies the EQ predicate on the "name" field.
func NameEQ(v string) predicate.Location { func NameEQ(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldEQ(FieldName, v))
s.Where(sql.EQ(s.C(FieldName), v))
})
} }
// NameNEQ applies the NEQ predicate on the "name" field. // NameNEQ applies the NEQ predicate on the "name" field.
func NameNEQ(v string) predicate.Location { func NameNEQ(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldNEQ(FieldName, v))
s.Where(sql.NEQ(s.C(FieldName), v))
})
} }
// NameIn applies the In predicate on the "name" field. // NameIn applies the In predicate on the "name" field.
func NameIn(vs ...string) predicate.Location { func NameIn(vs ...string) predicate.Location {
v := make([]any, len(vs)) return predicate.Location(sql.FieldIn(FieldName, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Location(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldName), v...))
})
} }
// NameNotIn applies the NotIn predicate on the "name" field. // NameNotIn applies the NotIn predicate on the "name" field.
func NameNotIn(vs ...string) predicate.Location { func NameNotIn(vs ...string) predicate.Location {
v := make([]any, len(vs)) return predicate.Location(sql.FieldNotIn(FieldName, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Location(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldName), v...))
})
} }
// NameGT applies the GT predicate on the "name" field. // NameGT applies the GT predicate on the "name" field.
func NameGT(v string) predicate.Location { func NameGT(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldGT(FieldName, v))
s.Where(sql.GT(s.C(FieldName), v))
})
} }
// NameGTE applies the GTE predicate on the "name" field. // NameGTE applies the GTE predicate on the "name" field.
func NameGTE(v string) predicate.Location { func NameGTE(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldGTE(FieldName, v))
s.Where(sql.GTE(s.C(FieldName), v))
})
} }
// NameLT applies the LT predicate on the "name" field. // NameLT applies the LT predicate on the "name" field.
func NameLT(v string) predicate.Location { func NameLT(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldLT(FieldName, v))
s.Where(sql.LT(s.C(FieldName), v))
})
} }
// NameLTE applies the LTE predicate on the "name" field. // NameLTE applies the LTE predicate on the "name" field.
func NameLTE(v string) predicate.Location { func NameLTE(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldLTE(FieldName, v))
s.Where(sql.LTE(s.C(FieldName), v))
})
} }
// NameContains applies the Contains predicate on the "name" field. // NameContains applies the Contains predicate on the "name" field.
func NameContains(v string) predicate.Location { func NameContains(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldContains(FieldName, v))
s.Where(sql.Contains(s.C(FieldName), v))
})
} }
// NameHasPrefix applies the HasPrefix predicate on the "name" field. // NameHasPrefix applies the HasPrefix predicate on the "name" field.
func NameHasPrefix(v string) predicate.Location { func NameHasPrefix(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldHasPrefix(FieldName, v))
s.Where(sql.HasPrefix(s.C(FieldName), v))
})
} }
// NameHasSuffix applies the HasSuffix predicate on the "name" field. // NameHasSuffix applies the HasSuffix predicate on the "name" field.
func NameHasSuffix(v string) predicate.Location { func NameHasSuffix(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldHasSuffix(FieldName, v))
s.Where(sql.HasSuffix(s.C(FieldName), v))
})
} }
// NameEqualFold applies the EqualFold predicate on the "name" field. // NameEqualFold applies the EqualFold predicate on the "name" field.
func NameEqualFold(v string) predicate.Location { func NameEqualFold(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldEqualFold(FieldName, v))
s.Where(sql.EqualFold(s.C(FieldName), v))
})
} }
// NameContainsFold applies the ContainsFold predicate on the "name" field. // NameContainsFold applies the ContainsFold predicate on the "name" field.
func NameContainsFold(v string) predicate.Location { func NameContainsFold(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldContainsFold(FieldName, v))
s.Where(sql.ContainsFold(s.C(FieldName), v))
})
} }
// DescriptionEQ applies the EQ predicate on the "description" field. // DescriptionEQ applies the EQ predicate on the "description" field.
func DescriptionEQ(v string) predicate.Location { func DescriptionEQ(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldEQ(FieldDescription, v))
s.Where(sql.EQ(s.C(FieldDescription), v))
})
} }
// DescriptionNEQ applies the NEQ predicate on the "description" field. // DescriptionNEQ applies the NEQ predicate on the "description" field.
func DescriptionNEQ(v string) predicate.Location { func DescriptionNEQ(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldNEQ(FieldDescription, v))
s.Where(sql.NEQ(s.C(FieldDescription), v))
})
} }
// DescriptionIn applies the In predicate on the "description" field. // DescriptionIn applies the In predicate on the "description" field.
func DescriptionIn(vs ...string) predicate.Location { func DescriptionIn(vs ...string) predicate.Location {
v := make([]any, len(vs)) return predicate.Location(sql.FieldIn(FieldDescription, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Location(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldDescription), v...))
})
} }
// DescriptionNotIn applies the NotIn predicate on the "description" field. // DescriptionNotIn applies the NotIn predicate on the "description" field.
func DescriptionNotIn(vs ...string) predicate.Location { func DescriptionNotIn(vs ...string) predicate.Location {
v := make([]any, len(vs)) return predicate.Location(sql.FieldNotIn(FieldDescription, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.Location(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldDescription), v...))
})
} }
// DescriptionGT applies the GT predicate on the "description" field. // DescriptionGT applies the GT predicate on the "description" field.
func DescriptionGT(v string) predicate.Location { func DescriptionGT(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldGT(FieldDescription, v))
s.Where(sql.GT(s.C(FieldDescription), v))
})
} }
// DescriptionGTE applies the GTE predicate on the "description" field. // DescriptionGTE applies the GTE predicate on the "description" field.
func DescriptionGTE(v string) predicate.Location { func DescriptionGTE(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldGTE(FieldDescription, v))
s.Where(sql.GTE(s.C(FieldDescription), v))
})
} }
// DescriptionLT applies the LT predicate on the "description" field. // DescriptionLT applies the LT predicate on the "description" field.
func DescriptionLT(v string) predicate.Location { func DescriptionLT(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldLT(FieldDescription, v))
s.Where(sql.LT(s.C(FieldDescription), v))
})
} }
// DescriptionLTE applies the LTE predicate on the "description" field. // DescriptionLTE applies the LTE predicate on the "description" field.
func DescriptionLTE(v string) predicate.Location { func DescriptionLTE(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldLTE(FieldDescription, v))
s.Where(sql.LTE(s.C(FieldDescription), v))
})
} }
// DescriptionContains applies the Contains predicate on the "description" field. // DescriptionContains applies the Contains predicate on the "description" field.
func DescriptionContains(v string) predicate.Location { func DescriptionContains(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldContains(FieldDescription, v))
s.Where(sql.Contains(s.C(FieldDescription), v))
})
} }
// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. // DescriptionHasPrefix applies the HasPrefix predicate on the "description" field.
func DescriptionHasPrefix(v string) predicate.Location { func DescriptionHasPrefix(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldHasPrefix(FieldDescription, v))
s.Where(sql.HasPrefix(s.C(FieldDescription), v))
})
} }
// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. // DescriptionHasSuffix applies the HasSuffix predicate on the "description" field.
func DescriptionHasSuffix(v string) predicate.Location { func DescriptionHasSuffix(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldHasSuffix(FieldDescription, v))
s.Where(sql.HasSuffix(s.C(FieldDescription), v))
})
} }
// DescriptionIsNil applies the IsNil predicate on the "description" field. // DescriptionIsNil applies the IsNil predicate on the "description" field.
func DescriptionIsNil() predicate.Location { func DescriptionIsNil() predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldIsNull(FieldDescription))
s.Where(sql.IsNull(s.C(FieldDescription)))
})
} }
// DescriptionNotNil applies the NotNil predicate on the "description" field. // DescriptionNotNil applies the NotNil predicate on the "description" field.
func DescriptionNotNil() predicate.Location { func DescriptionNotNil() predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldNotNull(FieldDescription))
s.Where(sql.NotNull(s.C(FieldDescription)))
})
} }
// DescriptionEqualFold applies the EqualFold predicate on the "description" field. // DescriptionEqualFold applies the EqualFold predicate on the "description" field.
func DescriptionEqualFold(v string) predicate.Location { func DescriptionEqualFold(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldEqualFold(FieldDescription, v))
s.Where(sql.EqualFold(s.C(FieldDescription), v))
})
} }
// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. // DescriptionContainsFold applies the ContainsFold predicate on the "description" field.
func DescriptionContainsFold(v string) predicate.Location { func DescriptionContainsFold(v string) predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(sql.FieldContainsFold(FieldDescription, v))
s.Where(sql.ContainsFold(s.C(FieldDescription), v))
})
} }
// HasParent applies the HasEdge predicate on the "parent" edge. // HasParent applies the HasEdge predicate on the "parent" edge.
@ -455,7 +301,6 @@ func HasParent() predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(ParentTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)
@ -483,7 +328,6 @@ func HasChildren() predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(ChildrenTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)
@ -511,7 +355,6 @@ func HasGroup() predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(GroupTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn), sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)
@ -539,7 +382,6 @@ func HasItems() predicate.Location {
return predicate.Location(func(s *sql.Selector) { return predicate.Location(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(ItemsTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, ItemsTable, ItemsColumn), sqlgraph.Edge(sqlgraph.O2M, false, ItemsTable, ItemsColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)

View file

@ -152,50 +152,8 @@ func (lc *LocationCreate) Mutation() *LocationMutation {
// Save creates the Location in the database. // Save creates the Location in the database.
func (lc *LocationCreate) Save(ctx context.Context) (*Location, error) { func (lc *LocationCreate) Save(ctx context.Context) (*Location, error) {
var (
err error
node *Location
)
lc.defaults() lc.defaults()
if len(lc.hooks) == 0 { return withHooks[*Location, LocationMutation](ctx, lc.sqlSave, lc.mutation, lc.hooks)
if err = lc.check(); err != nil {
return nil, err
}
node, err = lc.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*LocationMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = lc.check(); err != nil {
return nil, err
}
lc.mutation = mutation
if node, err = lc.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(lc.hooks) - 1; i >= 0; i-- {
if lc.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = lc.hooks[i](mut)
}
v, err := mut.Mutate(ctx, lc.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Location)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from LocationMutation", v)
}
node = nv
}
return node, err
} }
// SaveX calls Save and panics if Save returns an error. // SaveX calls Save and panics if Save returns an error.
@ -264,6 +222,9 @@ func (lc *LocationCreate) check() error {
} }
func (lc *LocationCreate) sqlSave(ctx context.Context) (*Location, error) { func (lc *LocationCreate) sqlSave(ctx context.Context) (*Location, error) {
if err := lc.check(); err != nil {
return nil, err
}
_node, _spec := lc.createSpec() _node, _spec := lc.createSpec()
if err := sqlgraph.CreateNode(ctx, lc.driver, _spec); err != nil { if err := sqlgraph.CreateNode(ctx, lc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) { if sqlgraph.IsConstraintError(err) {
@ -278,6 +239,8 @@ func (lc *LocationCreate) sqlSave(ctx context.Context) (*Location, error) {
return nil, err return nil, err
} }
} }
lc.mutation.id = &_node.ID
lc.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -4,7 +4,6 @@ package ent
import ( import (
"context" "context"
"fmt"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
@ -28,34 +27,7 @@ func (ld *LocationDelete) Where(ps ...predicate.Location) *LocationDelete {
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (ld *LocationDelete) Exec(ctx context.Context) (int, error) { func (ld *LocationDelete) Exec(ctx context.Context) (int, error) {
var ( return withHooks[int, LocationMutation](ctx, ld.sqlExec, ld.mutation, ld.hooks)
err error
affected int
)
if len(ld.hooks) == 0 {
affected, err = ld.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*LocationMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
ld.mutation = mutation
affected, err = ld.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(ld.hooks) - 1; i >= 0; i-- {
if ld.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = ld.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, ld.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
@ -88,6 +60,7 @@ func (ld *LocationDelete) sqlExec(ctx context.Context) (int, error) {
if err != nil && sqlgraph.IsConstraintError(err) { if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
ld.mutation.done = true
return affected, err return affected, err
} }

View file

@ -26,6 +26,7 @@ type LocationQuery struct {
unique *bool unique *bool
order []OrderFunc order []OrderFunc
fields []string fields []string
inters []Interceptor
predicates []predicate.Location predicates []predicate.Location
withParent *LocationQuery withParent *LocationQuery
withChildren *LocationQuery withChildren *LocationQuery
@ -43,13 +44,13 @@ func (lq *LocationQuery) Where(ps ...predicate.Location) *LocationQuery {
return lq return lq
} }
// Limit adds a limit step to the query. // Limit the number of records to be returned by this query.
func (lq *LocationQuery) Limit(limit int) *LocationQuery { func (lq *LocationQuery) Limit(limit int) *LocationQuery {
lq.limit = &limit lq.limit = &limit
return lq return lq
} }
// Offset adds an offset step to the query. // Offset to start from.
func (lq *LocationQuery) Offset(offset int) *LocationQuery { func (lq *LocationQuery) Offset(offset int) *LocationQuery {
lq.offset = &offset lq.offset = &offset
return lq return lq
@ -62,7 +63,7 @@ func (lq *LocationQuery) Unique(unique bool) *LocationQuery {
return lq return lq
} }
// Order adds an order step to the query. // Order specifies how the records should be ordered.
func (lq *LocationQuery) Order(o ...OrderFunc) *LocationQuery { func (lq *LocationQuery) Order(o ...OrderFunc) *LocationQuery {
lq.order = append(lq.order, o...) lq.order = append(lq.order, o...)
return lq return lq
@ -70,7 +71,7 @@ func (lq *LocationQuery) Order(o ...OrderFunc) *LocationQuery {
// QueryParent chains the current query on the "parent" edge. // QueryParent chains the current query on the "parent" edge.
func (lq *LocationQuery) QueryParent() *LocationQuery { func (lq *LocationQuery) QueryParent() *LocationQuery {
query := &LocationQuery{config: lq.config} query := (&LocationClient{config: lq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := lq.prepareQuery(ctx); err != nil { if err := lq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -92,7 +93,7 @@ func (lq *LocationQuery) QueryParent() *LocationQuery {
// QueryChildren chains the current query on the "children" edge. // QueryChildren chains the current query on the "children" edge.
func (lq *LocationQuery) QueryChildren() *LocationQuery { func (lq *LocationQuery) QueryChildren() *LocationQuery {
query := &LocationQuery{config: lq.config} query := (&LocationClient{config: lq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := lq.prepareQuery(ctx); err != nil { if err := lq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -114,7 +115,7 @@ func (lq *LocationQuery) QueryChildren() *LocationQuery {
// QueryGroup chains the current query on the "group" edge. // QueryGroup chains the current query on the "group" edge.
func (lq *LocationQuery) QueryGroup() *GroupQuery { func (lq *LocationQuery) QueryGroup() *GroupQuery {
query := &GroupQuery{config: lq.config} query := (&GroupClient{config: lq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := lq.prepareQuery(ctx); err != nil { if err := lq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -136,7 +137,7 @@ func (lq *LocationQuery) QueryGroup() *GroupQuery {
// QueryItems chains the current query on the "items" edge. // QueryItems chains the current query on the "items" edge.
func (lq *LocationQuery) QueryItems() *ItemQuery { func (lq *LocationQuery) QueryItems() *ItemQuery {
query := &ItemQuery{config: lq.config} query := (&ItemClient{config: lq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := lq.prepareQuery(ctx); err != nil { if err := lq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -159,7 +160,7 @@ func (lq *LocationQuery) QueryItems() *ItemQuery {
// First returns the first Location entity from the query. // First returns the first Location entity from the query.
// Returns a *NotFoundError when no Location was found. // Returns a *NotFoundError when no Location was found.
func (lq *LocationQuery) First(ctx context.Context) (*Location, error) { func (lq *LocationQuery) First(ctx context.Context) (*Location, error) {
nodes, err := lq.Limit(1).All(ctx) nodes, err := lq.Limit(1).All(newQueryContext(ctx, TypeLocation, "First"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -182,7 +183,7 @@ func (lq *LocationQuery) FirstX(ctx context.Context) *Location {
// Returns a *NotFoundError when no Location ID was found. // Returns a *NotFoundError when no Location ID was found.
func (lq *LocationQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { func (lq *LocationQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = lq.Limit(1).IDs(ctx); err != nil { if ids, err = lq.Limit(1).IDs(newQueryContext(ctx, TypeLocation, "FirstID")); err != nil {
return return
} }
if len(ids) == 0 { if len(ids) == 0 {
@ -205,7 +206,7 @@ func (lq *LocationQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one Location entity is found. // Returns a *NotSingularError when more than one Location entity is found.
// Returns a *NotFoundError when no Location entities are found. // Returns a *NotFoundError when no Location entities are found.
func (lq *LocationQuery) Only(ctx context.Context) (*Location, error) { func (lq *LocationQuery) Only(ctx context.Context) (*Location, error) {
nodes, err := lq.Limit(2).All(ctx) nodes, err := lq.Limit(2).All(newQueryContext(ctx, TypeLocation, "Only"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -233,7 +234,7 @@ func (lq *LocationQuery) OnlyX(ctx context.Context) *Location {
// Returns a *NotFoundError when no entities are found. // Returns a *NotFoundError when no entities are found.
func (lq *LocationQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { func (lq *LocationQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = lq.Limit(2).IDs(ctx); err != nil { if ids, err = lq.Limit(2).IDs(newQueryContext(ctx, TypeLocation, "OnlyID")); err != nil {
return return
} }
switch len(ids) { switch len(ids) {
@ -258,10 +259,12 @@ func (lq *LocationQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of Locations. // All executes the query and returns a list of Locations.
func (lq *LocationQuery) All(ctx context.Context) ([]*Location, error) { func (lq *LocationQuery) All(ctx context.Context) ([]*Location, error) {
ctx = newQueryContext(ctx, TypeLocation, "All")
if err := lq.prepareQuery(ctx); err != nil { if err := lq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return lq.sqlAll(ctx) qr := querierAll[[]*Location, *LocationQuery]()
return withInterceptors[[]*Location](ctx, lq, qr, lq.inters)
} }
// AllX is like All, but panics if an error occurs. // AllX is like All, but panics if an error occurs.
@ -276,6 +279,7 @@ func (lq *LocationQuery) AllX(ctx context.Context) []*Location {
// IDs executes the query and returns a list of Location IDs. // IDs executes the query and returns a list of Location IDs.
func (lq *LocationQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (lq *LocationQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID var ids []uuid.UUID
ctx = newQueryContext(ctx, TypeLocation, "IDs")
if err := lq.Select(location.FieldID).Scan(ctx, &ids); err != nil { if err := lq.Select(location.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
@ -293,10 +297,11 @@ func (lq *LocationQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query. // Count returns the count of the given query.
func (lq *LocationQuery) Count(ctx context.Context) (int, error) { func (lq *LocationQuery) Count(ctx context.Context) (int, error) {
ctx = newQueryContext(ctx, TypeLocation, "Count")
if err := lq.prepareQuery(ctx); err != nil { if err := lq.prepareQuery(ctx); err != nil {
return 0, err return 0, err
} }
return lq.sqlCount(ctx) return withInterceptors[int](ctx, lq, querierCount[*LocationQuery](), lq.inters)
} }
// CountX is like Count, but panics if an error occurs. // CountX is like Count, but panics if an error occurs.
@ -310,10 +315,15 @@ func (lq *LocationQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph. // Exist returns true if the query has elements in the graph.
func (lq *LocationQuery) Exist(ctx context.Context) (bool, error) { func (lq *LocationQuery) Exist(ctx context.Context) (bool, error) {
if err := lq.prepareQuery(ctx); err != nil { ctx = newQueryContext(ctx, TypeLocation, "Exist")
return false, err switch _, err := lq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
} }
return lq.sqlExist(ctx)
} }
// ExistX is like Exist, but panics if an error occurs. // ExistX is like Exist, but panics if an error occurs.
@ -336,6 +346,7 @@ func (lq *LocationQuery) Clone() *LocationQuery {
limit: lq.limit, limit: lq.limit,
offset: lq.offset, offset: lq.offset,
order: append([]OrderFunc{}, lq.order...), order: append([]OrderFunc{}, lq.order...),
inters: append([]Interceptor{}, lq.inters...),
predicates: append([]predicate.Location{}, lq.predicates...), predicates: append([]predicate.Location{}, lq.predicates...),
withParent: lq.withParent.Clone(), withParent: lq.withParent.Clone(),
withChildren: lq.withChildren.Clone(), withChildren: lq.withChildren.Clone(),
@ -351,7 +362,7 @@ func (lq *LocationQuery) Clone() *LocationQuery {
// WithParent tells the query-builder to eager-load the nodes that are connected to // WithParent tells the query-builder to eager-load the nodes that are connected to
// the "parent" edge. The optional arguments are used to configure the query builder of the edge. // the "parent" edge. The optional arguments are used to configure the query builder of the edge.
func (lq *LocationQuery) WithParent(opts ...func(*LocationQuery)) *LocationQuery { func (lq *LocationQuery) WithParent(opts ...func(*LocationQuery)) *LocationQuery {
query := &LocationQuery{config: lq.config} query := (&LocationClient{config: lq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -362,7 +373,7 @@ func (lq *LocationQuery) WithParent(opts ...func(*LocationQuery)) *LocationQuery
// WithChildren tells the query-builder to eager-load the nodes that are connected to // WithChildren tells the query-builder to eager-load the nodes that are connected to
// the "children" edge. The optional arguments are used to configure the query builder of the edge. // the "children" edge. The optional arguments are used to configure the query builder of the edge.
func (lq *LocationQuery) WithChildren(opts ...func(*LocationQuery)) *LocationQuery { func (lq *LocationQuery) WithChildren(opts ...func(*LocationQuery)) *LocationQuery {
query := &LocationQuery{config: lq.config} query := (&LocationClient{config: lq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -373,7 +384,7 @@ func (lq *LocationQuery) WithChildren(opts ...func(*LocationQuery)) *LocationQue
// WithGroup tells the query-builder to eager-load the nodes that are connected to // WithGroup tells the query-builder to eager-load the nodes that are connected to
// the "group" edge. The optional arguments are used to configure the query builder of the edge. // the "group" edge. The optional arguments are used to configure the query builder of the edge.
func (lq *LocationQuery) WithGroup(opts ...func(*GroupQuery)) *LocationQuery { func (lq *LocationQuery) WithGroup(opts ...func(*GroupQuery)) *LocationQuery {
query := &GroupQuery{config: lq.config} query := (&GroupClient{config: lq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -384,7 +395,7 @@ func (lq *LocationQuery) WithGroup(opts ...func(*GroupQuery)) *LocationQuery {
// WithItems tells the query-builder to eager-load the nodes that are connected to // WithItems tells the query-builder to eager-load the nodes that are connected to
// the "items" edge. The optional arguments are used to configure the query builder of the edge. // the "items" edge. The optional arguments are used to configure the query builder of the edge.
func (lq *LocationQuery) WithItems(opts ...func(*ItemQuery)) *LocationQuery { func (lq *LocationQuery) WithItems(opts ...func(*ItemQuery)) *LocationQuery {
query := &ItemQuery{config: lq.config} query := (&ItemClient{config: lq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -407,16 +418,11 @@ func (lq *LocationQuery) WithItems(opts ...func(*ItemQuery)) *LocationQuery {
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (lq *LocationQuery) GroupBy(field string, fields ...string) *LocationGroupBy { func (lq *LocationQuery) GroupBy(field string, fields ...string) *LocationGroupBy {
grbuild := &LocationGroupBy{config: lq.config} lq.fields = append([]string{field}, fields...)
grbuild.fields = append([]string{field}, fields...) grbuild := &LocationGroupBy{build: lq}
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { grbuild.flds = &lq.fields
if err := lq.prepareQuery(ctx); err != nil {
return nil, err
}
return lq.sqlQuery(ctx), nil
}
grbuild.label = location.Label grbuild.label = location.Label
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan grbuild.scan = grbuild.Scan
return grbuild return grbuild
} }
@ -434,10 +440,10 @@ func (lq *LocationQuery) GroupBy(field string, fields ...string) *LocationGroupB
// Scan(ctx, &v) // Scan(ctx, &v)
func (lq *LocationQuery) Select(fields ...string) *LocationSelect { func (lq *LocationQuery) Select(fields ...string) *LocationSelect {
lq.fields = append(lq.fields, fields...) lq.fields = append(lq.fields, fields...)
selbuild := &LocationSelect{LocationQuery: lq} sbuild := &LocationSelect{LocationQuery: lq}
selbuild.label = location.Label sbuild.label = location.Label
selbuild.flds, selbuild.scan = &lq.fields, selbuild.Scan sbuild.flds, sbuild.scan = &lq.fields, sbuild.Scan
return selbuild return sbuild
} }
// Aggregate returns a LocationSelect configured with the given aggregations. // Aggregate returns a LocationSelect configured with the given aggregations.
@ -446,6 +452,16 @@ func (lq *LocationQuery) Aggregate(fns ...AggregateFunc) *LocationSelect {
} }
func (lq *LocationQuery) prepareQuery(ctx context.Context) error { func (lq *LocationQuery) prepareQuery(ctx context.Context) error {
for _, inter := range lq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, lq); err != nil {
return err
}
}
}
for _, f := range lq.fields { for _, f := range lq.fields {
if !location.ValidColumn(f) { if !location.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
@ -656,17 +672,6 @@ func (lq *LocationQuery) sqlCount(ctx context.Context) (int, error) {
return sqlgraph.CountNodes(ctx, lq.driver, _spec) return sqlgraph.CountNodes(ctx, lq.driver, _spec)
} }
func (lq *LocationQuery) sqlExist(ctx context.Context) (bool, error) {
switch _, err := lq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
func (lq *LocationQuery) querySpec() *sqlgraph.QuerySpec { func (lq *LocationQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
@ -749,13 +754,8 @@ func (lq *LocationQuery) sqlQuery(ctx context.Context) *sql.Selector {
// LocationGroupBy is the group-by builder for Location entities. // LocationGroupBy is the group-by builder for Location entities.
type LocationGroupBy struct { type LocationGroupBy struct {
config
selector selector
fields []string build *LocationQuery
fns []AggregateFunc
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
} }
// Aggregate adds the given aggregation functions to the group-by query. // Aggregate adds the given aggregation functions to the group-by query.
@ -764,58 +764,46 @@ func (lgb *LocationGroupBy) Aggregate(fns ...AggregateFunc) *LocationGroupBy {
return lgb return lgb
} }
// Scan applies the group-by query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (lgb *LocationGroupBy) Scan(ctx context.Context, v any) error { func (lgb *LocationGroupBy) Scan(ctx context.Context, v any) error {
query, err := lgb.path(ctx) ctx = newQueryContext(ctx, TypeLocation, "GroupBy")
if err != nil { if err := lgb.build.prepareQuery(ctx); err != nil {
return err return err
} }
lgb.sql = query return scanWithInterceptors[*LocationQuery, *LocationGroupBy](ctx, lgb.build, lgb, lgb.build.inters, v)
return lgb.sqlScan(ctx, v)
} }
func (lgb *LocationGroupBy) sqlScan(ctx context.Context, v any) error { func (lgb *LocationGroupBy) sqlScan(ctx context.Context, root *LocationQuery, v any) error {
for _, f := range lgb.fields { selector := root.sqlQuery(ctx).Select()
if !location.ValidColumn(f) { aggregation := make([]string, 0, len(lgb.fns))
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} for _, fn := range lgb.fns {
} aggregation = append(aggregation, fn(selector))
} }
selector := lgb.sqlQuery() if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*lgb.flds)+len(lgb.fns))
for _, f := range *lgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*lgb.flds...)...)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return err return err
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() query, args := selector.Query()
if err := lgb.driver.Query(ctx, query, args, rows); err != nil { if err := lgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }
defer rows.Close() defer rows.Close()
return sql.ScanSlice(rows, v) return sql.ScanSlice(rows, v)
} }
func (lgb *LocationGroupBy) sqlQuery() *sql.Selector {
selector := lgb.sql.Select()
aggregation := make([]string, 0, len(lgb.fns))
for _, fn := range lgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(lgb.fields)+len(lgb.fns))
for _, f := range lgb.fields {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
return selector.GroupBy(selector.Columns(lgb.fields...)...)
}
// LocationSelect is the builder for selecting fields of Location entities. // LocationSelect is the builder for selecting fields of Location entities.
type LocationSelect struct { type LocationSelect struct {
*LocationQuery *LocationQuery
selector selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
@ -826,26 +814,27 @@ func (ls *LocationSelect) Aggregate(fns ...AggregateFunc) *LocationSelect {
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (ls *LocationSelect) Scan(ctx context.Context, v any) error { func (ls *LocationSelect) Scan(ctx context.Context, v any) error {
ctx = newQueryContext(ctx, TypeLocation, "Select")
if err := ls.prepareQuery(ctx); err != nil { if err := ls.prepareQuery(ctx); err != nil {
return err return err
} }
ls.sql = ls.LocationQuery.sqlQuery(ctx) return scanWithInterceptors[*LocationQuery, *LocationSelect](ctx, ls.LocationQuery, ls, ls.inters, v)
return ls.sqlScan(ctx, v)
} }
func (ls *LocationSelect) sqlScan(ctx context.Context, v any) error { func (ls *LocationSelect) sqlScan(ctx context.Context, root *LocationQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(ls.fns)) aggregation := make([]string, 0, len(ls.fns))
for _, fn := range ls.fns { for _, fn := range ls.fns {
aggregation = append(aggregation, fn(ls.sql)) aggregation = append(aggregation, fn(selector))
} }
switch n := len(*ls.selector.flds); { switch n := len(*ls.selector.flds); {
case n == 0 && len(aggregation) > 0: case n == 0 && len(aggregation) > 0:
ls.sql.Select(aggregation...) selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0: case n != 0 && len(aggregation) > 0:
ls.sql.AppendSelect(aggregation...) selector.AppendSelect(aggregation...)
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := ls.sql.Query() query, args := selector.Query()
if err := ls.driver.Query(ctx, query, args, rows); err != nil { if err := ls.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }

View file

@ -184,41 +184,8 @@ func (lu *LocationUpdate) RemoveItems(i ...*Item) *LocationUpdate {
// Save executes the query and returns the number of nodes affected by the update operation. // Save executes the query and returns the number of nodes affected by the update operation.
func (lu *LocationUpdate) Save(ctx context.Context) (int, error) { func (lu *LocationUpdate) Save(ctx context.Context) (int, error) {
var (
err error
affected int
)
lu.defaults() lu.defaults()
if len(lu.hooks) == 0 { return withHooks[int, LocationMutation](ctx, lu.sqlSave, lu.mutation, lu.hooks)
if err = lu.check(); err != nil {
return 0, err
}
affected, err = lu.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*LocationMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = lu.check(); err != nil {
return 0, err
}
lu.mutation = mutation
affected, err = lu.sqlSave(ctx)
mutation.done = true
return affected, err
})
for i := len(lu.hooks) - 1; i >= 0; i-- {
if lu.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = lu.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, lu.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -270,6 +237,9 @@ func (lu *LocationUpdate) check() error {
} }
func (lu *LocationUpdate) sqlSave(ctx context.Context) (n int, err error) { func (lu *LocationUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := lu.check(); err != nil {
return n, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: location.Table, Table: location.Table,
@ -485,6 +455,7 @@ func (lu *LocationUpdate) sqlSave(ctx context.Context) (n int, err error) {
} }
return 0, err return 0, err
} }
lu.mutation.done = true
return n, nil return n, nil
} }
@ -656,47 +627,8 @@ func (luo *LocationUpdateOne) Select(field string, fields ...string) *LocationUp
// Save executes the query and returns the updated Location entity. // Save executes the query and returns the updated Location entity.
func (luo *LocationUpdateOne) Save(ctx context.Context) (*Location, error) { func (luo *LocationUpdateOne) Save(ctx context.Context) (*Location, error) {
var (
err error
node *Location
)
luo.defaults() luo.defaults()
if len(luo.hooks) == 0 { return withHooks[*Location, LocationMutation](ctx, luo.sqlSave, luo.mutation, luo.hooks)
if err = luo.check(); err != nil {
return nil, err
}
node, err = luo.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*LocationMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = luo.check(); err != nil {
return nil, err
}
luo.mutation = mutation
node, err = luo.sqlSave(ctx)
mutation.done = true
return node, err
})
for i := len(luo.hooks) - 1; i >= 0; i-- {
if luo.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = luo.hooks[i](mut)
}
v, err := mut.Mutate(ctx, luo.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Location)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from LocationMutation", v)
}
node = nv
}
return node, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -748,6 +680,9 @@ func (luo *LocationUpdateOne) check() error {
} }
func (luo *LocationUpdateOne) sqlSave(ctx context.Context) (_node *Location, err error) { func (luo *LocationUpdateOne) sqlSave(ctx context.Context) (_node *Location, err error) {
if err := luo.check(); err != nil {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: location.Table, Table: location.Table,
@ -983,5 +918,6 @@ func (luo *LocationUpdateOne) sqlSave(ctx context.Context) (_node *Location, err
} }
return nil, err return nil, err
} }
luo.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -13,626 +13,402 @@ import (
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.
func ID(id uuid.UUID) predicate.MaintenanceEntry { func ID(id uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDEQ applies the EQ predicate on the ID field. // IDEQ applies the EQ predicate on the ID field.
func IDEQ(id uuid.UUID) predicate.MaintenanceEntry { func IDEQ(id uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDNEQ applies the NEQ predicate on the ID field. // IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id uuid.UUID) predicate.MaintenanceEntry { func IDNEQ(id uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldNEQ(FieldID, id))
s.Where(sql.NEQ(s.C(FieldID), id))
})
} }
// IDIn applies the In predicate on the ID field. // IDIn applies the In predicate on the ID field.
func IDIn(ids ...uuid.UUID) predicate.MaintenanceEntry { func IDIn(ids ...uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.In(s.C(FieldID), v...))
})
} }
// IDNotIn applies the NotIn predicate on the ID field. // IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...uuid.UUID) predicate.MaintenanceEntry { func IDNotIn(ids ...uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldNotIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.NotIn(s.C(FieldID), v...))
})
} }
// IDGT applies the GT predicate on the ID field. // IDGT applies the GT predicate on the ID field.
func IDGT(id uuid.UUID) predicate.MaintenanceEntry { func IDGT(id uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldGT(FieldID, id))
s.Where(sql.GT(s.C(FieldID), id))
})
} }
// IDGTE applies the GTE predicate on the ID field. // IDGTE applies the GTE predicate on the ID field.
func IDGTE(id uuid.UUID) predicate.MaintenanceEntry { func IDGTE(id uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldGTE(FieldID, id))
s.Where(sql.GTE(s.C(FieldID), id))
})
} }
// IDLT applies the LT predicate on the ID field. // IDLT applies the LT predicate on the ID field.
func IDLT(id uuid.UUID) predicate.MaintenanceEntry { func IDLT(id uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldLT(FieldID, id))
s.Where(sql.LT(s.C(FieldID), id))
})
} }
// IDLTE applies the LTE predicate on the ID field. // IDLTE applies the LTE predicate on the ID field.
func IDLTE(id uuid.UUID) predicate.MaintenanceEntry { func IDLTE(id uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldLTE(FieldID, id))
s.Where(sql.LTE(s.C(FieldID), id))
})
} }
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. // CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.MaintenanceEntry { func CreatedAt(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. // UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.MaintenanceEntry { func UpdatedAt(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// ItemID applies equality check predicate on the "item_id" field. It's identical to ItemIDEQ. // ItemID applies equality check predicate on the "item_id" field. It's identical to ItemIDEQ.
func ItemID(v uuid.UUID) predicate.MaintenanceEntry { func ItemID(v uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldEQ(FieldItemID, v))
s.Where(sql.EQ(s.C(FieldItemID), v))
})
} }
// Date applies equality check predicate on the "date" field. It's identical to DateEQ. // Date applies equality check predicate on the "date" field. It's identical to DateEQ.
func Date(v time.Time) predicate.MaintenanceEntry { func Date(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldEQ(FieldDate, v))
s.Where(sql.EQ(s.C(FieldDate), v))
})
} }
// Name applies equality check predicate on the "name" field. It's identical to NameEQ. // Name applies equality check predicate on the "name" field. It's identical to NameEQ.
func Name(v string) predicate.MaintenanceEntry { func Name(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldEQ(FieldName, v))
s.Where(sql.EQ(s.C(FieldName), v))
})
} }
// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. // Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ.
func Description(v string) predicate.MaintenanceEntry { func Description(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldEQ(FieldDescription, v))
s.Where(sql.EQ(s.C(FieldDescription), v))
})
} }
// Cost applies equality check predicate on the "cost" field. It's identical to CostEQ. // Cost applies equality check predicate on the "cost" field. It's identical to CostEQ.
func Cost(v float64) predicate.MaintenanceEntry { func Cost(v float64) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldEQ(FieldCost, v))
s.Where(sql.EQ(s.C(FieldCost), v))
})
} }
// CreatedAtEQ applies the EQ predicate on the "created_at" field. // CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.MaintenanceEntry { func CreatedAtEQ(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. // CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.MaintenanceEntry { func CreatedAtNEQ(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldNEQ(FieldCreatedAt, v))
s.Where(sql.NEQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtIn applies the In predicate on the "created_at" field. // CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.MaintenanceEntry { func CreatedAtIn(vs ...time.Time) predicate.MaintenanceEntry {
v := make([]any, len(vs)) return predicate.MaintenanceEntry(sql.FieldIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.MaintenanceEntry(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. // CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.MaintenanceEntry { func CreatedAtNotIn(vs ...time.Time) predicate.MaintenanceEntry {
v := make([]any, len(vs)) return predicate.MaintenanceEntry(sql.FieldNotIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.MaintenanceEntry(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtGT applies the GT predicate on the "created_at" field. // CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.MaintenanceEntry { func CreatedAtGT(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldGT(FieldCreatedAt, v))
s.Where(sql.GT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtGTE applies the GTE predicate on the "created_at" field. // CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.MaintenanceEntry { func CreatedAtGTE(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldGTE(FieldCreatedAt, v))
s.Where(sql.GTE(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLT applies the LT predicate on the "created_at" field. // CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.MaintenanceEntry { func CreatedAtLT(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldLT(FieldCreatedAt, v))
s.Where(sql.LT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLTE applies the LTE predicate on the "created_at" field. // CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.MaintenanceEntry { func CreatedAtLTE(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldLTE(FieldCreatedAt, v))
s.Where(sql.LTE(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. // UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.MaintenanceEntry { func UpdatedAtEQ(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. // UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.MaintenanceEntry { func UpdatedAtNEQ(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldNEQ(FieldUpdatedAt, v))
s.Where(sql.NEQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtIn applies the In predicate on the "updated_at" field. // UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.MaintenanceEntry { func UpdatedAtIn(vs ...time.Time) predicate.MaintenanceEntry {
v := make([]any, len(vs)) return predicate.MaintenanceEntry(sql.FieldIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.MaintenanceEntry(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. // UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.MaintenanceEntry { func UpdatedAtNotIn(vs ...time.Time) predicate.MaintenanceEntry {
v := make([]any, len(vs)) return predicate.MaintenanceEntry(sql.FieldNotIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.MaintenanceEntry(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtGT applies the GT predicate on the "updated_at" field. // UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.MaintenanceEntry { func UpdatedAtGT(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldGT(FieldUpdatedAt, v))
s.Where(sql.GT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. // UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.MaintenanceEntry { func UpdatedAtGTE(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldGTE(FieldUpdatedAt, v))
s.Where(sql.GTE(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLT applies the LT predicate on the "updated_at" field. // UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.MaintenanceEntry { func UpdatedAtLT(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldLT(FieldUpdatedAt, v))
s.Where(sql.LT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. // UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.MaintenanceEntry { func UpdatedAtLTE(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldLTE(FieldUpdatedAt, v))
s.Where(sql.LTE(s.C(FieldUpdatedAt), v))
})
} }
// ItemIDEQ applies the EQ predicate on the "item_id" field. // ItemIDEQ applies the EQ predicate on the "item_id" field.
func ItemIDEQ(v uuid.UUID) predicate.MaintenanceEntry { func ItemIDEQ(v uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldEQ(FieldItemID, v))
s.Where(sql.EQ(s.C(FieldItemID), v))
})
} }
// ItemIDNEQ applies the NEQ predicate on the "item_id" field. // ItemIDNEQ applies the NEQ predicate on the "item_id" field.
func ItemIDNEQ(v uuid.UUID) predicate.MaintenanceEntry { func ItemIDNEQ(v uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldNEQ(FieldItemID, v))
s.Where(sql.NEQ(s.C(FieldItemID), v))
})
} }
// ItemIDIn applies the In predicate on the "item_id" field. // ItemIDIn applies the In predicate on the "item_id" field.
func ItemIDIn(vs ...uuid.UUID) predicate.MaintenanceEntry { func ItemIDIn(vs ...uuid.UUID) predicate.MaintenanceEntry {
v := make([]any, len(vs)) return predicate.MaintenanceEntry(sql.FieldIn(FieldItemID, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.MaintenanceEntry(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldItemID), v...))
})
} }
// ItemIDNotIn applies the NotIn predicate on the "item_id" field. // ItemIDNotIn applies the NotIn predicate on the "item_id" field.
func ItemIDNotIn(vs ...uuid.UUID) predicate.MaintenanceEntry { func ItemIDNotIn(vs ...uuid.UUID) predicate.MaintenanceEntry {
v := make([]any, len(vs)) return predicate.MaintenanceEntry(sql.FieldNotIn(FieldItemID, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.MaintenanceEntry(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldItemID), v...))
})
} }
// DateEQ applies the EQ predicate on the "date" field. // DateEQ applies the EQ predicate on the "date" field.
func DateEQ(v time.Time) predicate.MaintenanceEntry { func DateEQ(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldEQ(FieldDate, v))
s.Where(sql.EQ(s.C(FieldDate), v))
})
} }
// DateNEQ applies the NEQ predicate on the "date" field. // DateNEQ applies the NEQ predicate on the "date" field.
func DateNEQ(v time.Time) predicate.MaintenanceEntry { func DateNEQ(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldNEQ(FieldDate, v))
s.Where(sql.NEQ(s.C(FieldDate), v))
})
} }
// DateIn applies the In predicate on the "date" field. // DateIn applies the In predicate on the "date" field.
func DateIn(vs ...time.Time) predicate.MaintenanceEntry { func DateIn(vs ...time.Time) predicate.MaintenanceEntry {
v := make([]any, len(vs)) return predicate.MaintenanceEntry(sql.FieldIn(FieldDate, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.MaintenanceEntry(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldDate), v...))
})
} }
// DateNotIn applies the NotIn predicate on the "date" field. // DateNotIn applies the NotIn predicate on the "date" field.
func DateNotIn(vs ...time.Time) predicate.MaintenanceEntry { func DateNotIn(vs ...time.Time) predicate.MaintenanceEntry {
v := make([]any, len(vs)) return predicate.MaintenanceEntry(sql.FieldNotIn(FieldDate, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.MaintenanceEntry(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldDate), v...))
})
} }
// DateGT applies the GT predicate on the "date" field. // DateGT applies the GT predicate on the "date" field.
func DateGT(v time.Time) predicate.MaintenanceEntry { func DateGT(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldGT(FieldDate, v))
s.Where(sql.GT(s.C(FieldDate), v))
})
} }
// DateGTE applies the GTE predicate on the "date" field. // DateGTE applies the GTE predicate on the "date" field.
func DateGTE(v time.Time) predicate.MaintenanceEntry { func DateGTE(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldGTE(FieldDate, v))
s.Where(sql.GTE(s.C(FieldDate), v))
})
} }
// DateLT applies the LT predicate on the "date" field. // DateLT applies the LT predicate on the "date" field.
func DateLT(v time.Time) predicate.MaintenanceEntry { func DateLT(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldLT(FieldDate, v))
s.Where(sql.LT(s.C(FieldDate), v))
})
} }
// DateLTE applies the LTE predicate on the "date" field. // DateLTE applies the LTE predicate on the "date" field.
func DateLTE(v time.Time) predicate.MaintenanceEntry { func DateLTE(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldLTE(FieldDate, v))
s.Where(sql.LTE(s.C(FieldDate), v))
})
} }
// NameEQ applies the EQ predicate on the "name" field. // NameEQ applies the EQ predicate on the "name" field.
func NameEQ(v string) predicate.MaintenanceEntry { func NameEQ(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldEQ(FieldName, v))
s.Where(sql.EQ(s.C(FieldName), v))
})
} }
// NameNEQ applies the NEQ predicate on the "name" field. // NameNEQ applies the NEQ predicate on the "name" field.
func NameNEQ(v string) predicate.MaintenanceEntry { func NameNEQ(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldNEQ(FieldName, v))
s.Where(sql.NEQ(s.C(FieldName), v))
})
} }
// NameIn applies the In predicate on the "name" field. // NameIn applies the In predicate on the "name" field.
func NameIn(vs ...string) predicate.MaintenanceEntry { func NameIn(vs ...string) predicate.MaintenanceEntry {
v := make([]any, len(vs)) return predicate.MaintenanceEntry(sql.FieldIn(FieldName, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.MaintenanceEntry(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldName), v...))
})
} }
// NameNotIn applies the NotIn predicate on the "name" field. // NameNotIn applies the NotIn predicate on the "name" field.
func NameNotIn(vs ...string) predicate.MaintenanceEntry { func NameNotIn(vs ...string) predicate.MaintenanceEntry {
v := make([]any, len(vs)) return predicate.MaintenanceEntry(sql.FieldNotIn(FieldName, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.MaintenanceEntry(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldName), v...))
})
} }
// NameGT applies the GT predicate on the "name" field. // NameGT applies the GT predicate on the "name" field.
func NameGT(v string) predicate.MaintenanceEntry { func NameGT(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldGT(FieldName, v))
s.Where(sql.GT(s.C(FieldName), v))
})
} }
// NameGTE applies the GTE predicate on the "name" field. // NameGTE applies the GTE predicate on the "name" field.
func NameGTE(v string) predicate.MaintenanceEntry { func NameGTE(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldGTE(FieldName, v))
s.Where(sql.GTE(s.C(FieldName), v))
})
} }
// NameLT applies the LT predicate on the "name" field. // NameLT applies the LT predicate on the "name" field.
func NameLT(v string) predicate.MaintenanceEntry { func NameLT(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldLT(FieldName, v))
s.Where(sql.LT(s.C(FieldName), v))
})
} }
// NameLTE applies the LTE predicate on the "name" field. // NameLTE applies the LTE predicate on the "name" field.
func NameLTE(v string) predicate.MaintenanceEntry { func NameLTE(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldLTE(FieldName, v))
s.Where(sql.LTE(s.C(FieldName), v))
})
} }
// NameContains applies the Contains predicate on the "name" field. // NameContains applies the Contains predicate on the "name" field.
func NameContains(v string) predicate.MaintenanceEntry { func NameContains(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldContains(FieldName, v))
s.Where(sql.Contains(s.C(FieldName), v))
})
} }
// NameHasPrefix applies the HasPrefix predicate on the "name" field. // NameHasPrefix applies the HasPrefix predicate on the "name" field.
func NameHasPrefix(v string) predicate.MaintenanceEntry { func NameHasPrefix(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldHasPrefix(FieldName, v))
s.Where(sql.HasPrefix(s.C(FieldName), v))
})
} }
// NameHasSuffix applies the HasSuffix predicate on the "name" field. // NameHasSuffix applies the HasSuffix predicate on the "name" field.
func NameHasSuffix(v string) predicate.MaintenanceEntry { func NameHasSuffix(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldHasSuffix(FieldName, v))
s.Where(sql.HasSuffix(s.C(FieldName), v))
})
} }
// NameEqualFold applies the EqualFold predicate on the "name" field. // NameEqualFold applies the EqualFold predicate on the "name" field.
func NameEqualFold(v string) predicate.MaintenanceEntry { func NameEqualFold(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldEqualFold(FieldName, v))
s.Where(sql.EqualFold(s.C(FieldName), v))
})
} }
// NameContainsFold applies the ContainsFold predicate on the "name" field. // NameContainsFold applies the ContainsFold predicate on the "name" field.
func NameContainsFold(v string) predicate.MaintenanceEntry { func NameContainsFold(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldContainsFold(FieldName, v))
s.Where(sql.ContainsFold(s.C(FieldName), v))
})
} }
// DescriptionEQ applies the EQ predicate on the "description" field. // DescriptionEQ applies the EQ predicate on the "description" field.
func DescriptionEQ(v string) predicate.MaintenanceEntry { func DescriptionEQ(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldEQ(FieldDescription, v))
s.Where(sql.EQ(s.C(FieldDescription), v))
})
} }
// DescriptionNEQ applies the NEQ predicate on the "description" field. // DescriptionNEQ applies the NEQ predicate on the "description" field.
func DescriptionNEQ(v string) predicate.MaintenanceEntry { func DescriptionNEQ(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldNEQ(FieldDescription, v))
s.Where(sql.NEQ(s.C(FieldDescription), v))
})
} }
// DescriptionIn applies the In predicate on the "description" field. // DescriptionIn applies the In predicate on the "description" field.
func DescriptionIn(vs ...string) predicate.MaintenanceEntry { func DescriptionIn(vs ...string) predicate.MaintenanceEntry {
v := make([]any, len(vs)) return predicate.MaintenanceEntry(sql.FieldIn(FieldDescription, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.MaintenanceEntry(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldDescription), v...))
})
} }
// DescriptionNotIn applies the NotIn predicate on the "description" field. // DescriptionNotIn applies the NotIn predicate on the "description" field.
func DescriptionNotIn(vs ...string) predicate.MaintenanceEntry { func DescriptionNotIn(vs ...string) predicate.MaintenanceEntry {
v := make([]any, len(vs)) return predicate.MaintenanceEntry(sql.FieldNotIn(FieldDescription, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.MaintenanceEntry(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldDescription), v...))
})
} }
// DescriptionGT applies the GT predicate on the "description" field. // DescriptionGT applies the GT predicate on the "description" field.
func DescriptionGT(v string) predicate.MaintenanceEntry { func DescriptionGT(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldGT(FieldDescription, v))
s.Where(sql.GT(s.C(FieldDescription), v))
})
} }
// DescriptionGTE applies the GTE predicate on the "description" field. // DescriptionGTE applies the GTE predicate on the "description" field.
func DescriptionGTE(v string) predicate.MaintenanceEntry { func DescriptionGTE(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldGTE(FieldDescription, v))
s.Where(sql.GTE(s.C(FieldDescription), v))
})
} }
// DescriptionLT applies the LT predicate on the "description" field. // DescriptionLT applies the LT predicate on the "description" field.
func DescriptionLT(v string) predicate.MaintenanceEntry { func DescriptionLT(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldLT(FieldDescription, v))
s.Where(sql.LT(s.C(FieldDescription), v))
})
} }
// DescriptionLTE applies the LTE predicate on the "description" field. // DescriptionLTE applies the LTE predicate on the "description" field.
func DescriptionLTE(v string) predicate.MaintenanceEntry { func DescriptionLTE(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldLTE(FieldDescription, v))
s.Where(sql.LTE(s.C(FieldDescription), v))
})
} }
// DescriptionContains applies the Contains predicate on the "description" field. // DescriptionContains applies the Contains predicate on the "description" field.
func DescriptionContains(v string) predicate.MaintenanceEntry { func DescriptionContains(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldContains(FieldDescription, v))
s.Where(sql.Contains(s.C(FieldDescription), v))
})
} }
// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. // DescriptionHasPrefix applies the HasPrefix predicate on the "description" field.
func DescriptionHasPrefix(v string) predicate.MaintenanceEntry { func DescriptionHasPrefix(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldHasPrefix(FieldDescription, v))
s.Where(sql.HasPrefix(s.C(FieldDescription), v))
})
} }
// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. // DescriptionHasSuffix applies the HasSuffix predicate on the "description" field.
func DescriptionHasSuffix(v string) predicate.MaintenanceEntry { func DescriptionHasSuffix(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldHasSuffix(FieldDescription, v))
s.Where(sql.HasSuffix(s.C(FieldDescription), v))
})
} }
// DescriptionIsNil applies the IsNil predicate on the "description" field. // DescriptionIsNil applies the IsNil predicate on the "description" field.
func DescriptionIsNil() predicate.MaintenanceEntry { func DescriptionIsNil() predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldIsNull(FieldDescription))
s.Where(sql.IsNull(s.C(FieldDescription)))
})
} }
// DescriptionNotNil applies the NotNil predicate on the "description" field. // DescriptionNotNil applies the NotNil predicate on the "description" field.
func DescriptionNotNil() predicate.MaintenanceEntry { func DescriptionNotNil() predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldNotNull(FieldDescription))
s.Where(sql.NotNull(s.C(FieldDescription)))
})
} }
// DescriptionEqualFold applies the EqualFold predicate on the "description" field. // DescriptionEqualFold applies the EqualFold predicate on the "description" field.
func DescriptionEqualFold(v string) predicate.MaintenanceEntry { func DescriptionEqualFold(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldEqualFold(FieldDescription, v))
s.Where(sql.EqualFold(s.C(FieldDescription), v))
})
} }
// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. // DescriptionContainsFold applies the ContainsFold predicate on the "description" field.
func DescriptionContainsFold(v string) predicate.MaintenanceEntry { func DescriptionContainsFold(v string) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldContainsFold(FieldDescription, v))
s.Where(sql.ContainsFold(s.C(FieldDescription), v))
})
} }
// CostEQ applies the EQ predicate on the "cost" field. // CostEQ applies the EQ predicate on the "cost" field.
func CostEQ(v float64) predicate.MaintenanceEntry { func CostEQ(v float64) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldEQ(FieldCost, v))
s.Where(sql.EQ(s.C(FieldCost), v))
})
} }
// CostNEQ applies the NEQ predicate on the "cost" field. // CostNEQ applies the NEQ predicate on the "cost" field.
func CostNEQ(v float64) predicate.MaintenanceEntry { func CostNEQ(v float64) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldNEQ(FieldCost, v))
s.Where(sql.NEQ(s.C(FieldCost), v))
})
} }
// CostIn applies the In predicate on the "cost" field. // CostIn applies the In predicate on the "cost" field.
func CostIn(vs ...float64) predicate.MaintenanceEntry { func CostIn(vs ...float64) predicate.MaintenanceEntry {
v := make([]any, len(vs)) return predicate.MaintenanceEntry(sql.FieldIn(FieldCost, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.MaintenanceEntry(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldCost), v...))
})
} }
// CostNotIn applies the NotIn predicate on the "cost" field. // CostNotIn applies the NotIn predicate on the "cost" field.
func CostNotIn(vs ...float64) predicate.MaintenanceEntry { func CostNotIn(vs ...float64) predicate.MaintenanceEntry {
v := make([]any, len(vs)) return predicate.MaintenanceEntry(sql.FieldNotIn(FieldCost, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.MaintenanceEntry(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldCost), v...))
})
} }
// CostGT applies the GT predicate on the "cost" field. // CostGT applies the GT predicate on the "cost" field.
func CostGT(v float64) predicate.MaintenanceEntry { func CostGT(v float64) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldGT(FieldCost, v))
s.Where(sql.GT(s.C(FieldCost), v))
})
} }
// CostGTE applies the GTE predicate on the "cost" field. // CostGTE applies the GTE predicate on the "cost" field.
func CostGTE(v float64) predicate.MaintenanceEntry { func CostGTE(v float64) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldGTE(FieldCost, v))
s.Where(sql.GTE(s.C(FieldCost), v))
})
} }
// CostLT applies the LT predicate on the "cost" field. // CostLT applies the LT predicate on the "cost" field.
func CostLT(v float64) predicate.MaintenanceEntry { func CostLT(v float64) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldLT(FieldCost, v))
s.Where(sql.LT(s.C(FieldCost), v))
})
} }
// CostLTE applies the LTE predicate on the "cost" field. // CostLTE applies the LTE predicate on the "cost" field.
func CostLTE(v float64) predicate.MaintenanceEntry { func CostLTE(v float64) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(sql.FieldLTE(FieldCost, v))
s.Where(sql.LTE(s.C(FieldCost), v))
})
} }
// HasItem applies the HasEdge predicate on the "item" edge. // HasItem applies the HasEdge predicate on the "item" edge.
@ -640,7 +416,6 @@ func HasItem() predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) { return predicate.MaintenanceEntry(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(ItemTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ItemTable, ItemColumn), sqlgraph.Edge(sqlgraph.M2O, true, ItemTable, ItemColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)

View file

@ -130,50 +130,8 @@ func (mec *MaintenanceEntryCreate) Mutation() *MaintenanceEntryMutation {
// Save creates the MaintenanceEntry in the database. // Save creates the MaintenanceEntry in the database.
func (mec *MaintenanceEntryCreate) Save(ctx context.Context) (*MaintenanceEntry, error) { func (mec *MaintenanceEntryCreate) Save(ctx context.Context) (*MaintenanceEntry, error) {
var (
err error
node *MaintenanceEntry
)
mec.defaults() mec.defaults()
if len(mec.hooks) == 0 { return withHooks[*MaintenanceEntry, MaintenanceEntryMutation](ctx, mec.sqlSave, mec.mutation, mec.hooks)
if err = mec.check(); err != nil {
return nil, err
}
node, err = mec.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*MaintenanceEntryMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = mec.check(); err != nil {
return nil, err
}
mec.mutation = mutation
if node, err = mec.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(mec.hooks) - 1; i >= 0; i-- {
if mec.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = mec.hooks[i](mut)
}
v, err := mut.Mutate(ctx, mec.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*MaintenanceEntry)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from MaintenanceEntryMutation", v)
}
node = nv
}
return node, err
} }
// SaveX calls Save and panics if Save returns an error. // SaveX calls Save and panics if Save returns an error.
@ -259,6 +217,9 @@ func (mec *MaintenanceEntryCreate) check() error {
} }
func (mec *MaintenanceEntryCreate) sqlSave(ctx context.Context) (*MaintenanceEntry, error) { func (mec *MaintenanceEntryCreate) sqlSave(ctx context.Context) (*MaintenanceEntry, error) {
if err := mec.check(); err != nil {
return nil, err
}
_node, _spec := mec.createSpec() _node, _spec := mec.createSpec()
if err := sqlgraph.CreateNode(ctx, mec.driver, _spec); err != nil { if err := sqlgraph.CreateNode(ctx, mec.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) { if sqlgraph.IsConstraintError(err) {
@ -273,6 +234,8 @@ func (mec *MaintenanceEntryCreate) sqlSave(ctx context.Context) (*MaintenanceEnt
return nil, err return nil, err
} }
} }
mec.mutation.id = &_node.ID
mec.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -4,7 +4,6 @@ package ent
import ( import (
"context" "context"
"fmt"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
@ -28,34 +27,7 @@ func (med *MaintenanceEntryDelete) Where(ps ...predicate.MaintenanceEntry) *Main
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (med *MaintenanceEntryDelete) Exec(ctx context.Context) (int, error) { func (med *MaintenanceEntryDelete) Exec(ctx context.Context) (int, error) {
var ( return withHooks[int, MaintenanceEntryMutation](ctx, med.sqlExec, med.mutation, med.hooks)
err error
affected int
)
if len(med.hooks) == 0 {
affected, err = med.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*MaintenanceEntryMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
med.mutation = mutation
affected, err = med.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(med.hooks) - 1; i >= 0; i-- {
if med.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = med.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, med.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
@ -88,6 +60,7 @@ func (med *MaintenanceEntryDelete) sqlExec(ctx context.Context) (int, error) {
if err != nil && sqlgraph.IsConstraintError(err) { if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
med.mutation.done = true
return affected, err return affected, err
} }

View file

@ -24,6 +24,7 @@ type MaintenanceEntryQuery struct {
unique *bool unique *bool
order []OrderFunc order []OrderFunc
fields []string fields []string
inters []Interceptor
predicates []predicate.MaintenanceEntry predicates []predicate.MaintenanceEntry
withItem *ItemQuery withItem *ItemQuery
// intermediate query (i.e. traversal path). // intermediate query (i.e. traversal path).
@ -37,13 +38,13 @@ func (meq *MaintenanceEntryQuery) Where(ps ...predicate.MaintenanceEntry) *Maint
return meq return meq
} }
// Limit adds a limit step to the query. // Limit the number of records to be returned by this query.
func (meq *MaintenanceEntryQuery) Limit(limit int) *MaintenanceEntryQuery { func (meq *MaintenanceEntryQuery) Limit(limit int) *MaintenanceEntryQuery {
meq.limit = &limit meq.limit = &limit
return meq return meq
} }
// Offset adds an offset step to the query. // Offset to start from.
func (meq *MaintenanceEntryQuery) Offset(offset int) *MaintenanceEntryQuery { func (meq *MaintenanceEntryQuery) Offset(offset int) *MaintenanceEntryQuery {
meq.offset = &offset meq.offset = &offset
return meq return meq
@ -56,7 +57,7 @@ func (meq *MaintenanceEntryQuery) Unique(unique bool) *MaintenanceEntryQuery {
return meq return meq
} }
// Order adds an order step to the query. // Order specifies how the records should be ordered.
func (meq *MaintenanceEntryQuery) Order(o ...OrderFunc) *MaintenanceEntryQuery { func (meq *MaintenanceEntryQuery) Order(o ...OrderFunc) *MaintenanceEntryQuery {
meq.order = append(meq.order, o...) meq.order = append(meq.order, o...)
return meq return meq
@ -64,7 +65,7 @@ func (meq *MaintenanceEntryQuery) Order(o ...OrderFunc) *MaintenanceEntryQuery {
// QueryItem chains the current query on the "item" edge. // QueryItem chains the current query on the "item" edge.
func (meq *MaintenanceEntryQuery) QueryItem() *ItemQuery { func (meq *MaintenanceEntryQuery) QueryItem() *ItemQuery {
query := &ItemQuery{config: meq.config} query := (&ItemClient{config: meq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := meq.prepareQuery(ctx); err != nil { if err := meq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -87,7 +88,7 @@ func (meq *MaintenanceEntryQuery) QueryItem() *ItemQuery {
// First returns the first MaintenanceEntry entity from the query. // First returns the first MaintenanceEntry entity from the query.
// Returns a *NotFoundError when no MaintenanceEntry was found. // Returns a *NotFoundError when no MaintenanceEntry was found.
func (meq *MaintenanceEntryQuery) First(ctx context.Context) (*MaintenanceEntry, error) { func (meq *MaintenanceEntryQuery) First(ctx context.Context) (*MaintenanceEntry, error) {
nodes, err := meq.Limit(1).All(ctx) nodes, err := meq.Limit(1).All(newQueryContext(ctx, TypeMaintenanceEntry, "First"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -110,7 +111,7 @@ func (meq *MaintenanceEntryQuery) FirstX(ctx context.Context) *MaintenanceEntry
// Returns a *NotFoundError when no MaintenanceEntry ID was found. // Returns a *NotFoundError when no MaintenanceEntry ID was found.
func (meq *MaintenanceEntryQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { func (meq *MaintenanceEntryQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = meq.Limit(1).IDs(ctx); err != nil { if ids, err = meq.Limit(1).IDs(newQueryContext(ctx, TypeMaintenanceEntry, "FirstID")); err != nil {
return return
} }
if len(ids) == 0 { if len(ids) == 0 {
@ -133,7 +134,7 @@ func (meq *MaintenanceEntryQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one MaintenanceEntry entity is found. // Returns a *NotSingularError when more than one MaintenanceEntry entity is found.
// Returns a *NotFoundError when no MaintenanceEntry entities are found. // Returns a *NotFoundError when no MaintenanceEntry entities are found.
func (meq *MaintenanceEntryQuery) Only(ctx context.Context) (*MaintenanceEntry, error) { func (meq *MaintenanceEntryQuery) Only(ctx context.Context) (*MaintenanceEntry, error) {
nodes, err := meq.Limit(2).All(ctx) nodes, err := meq.Limit(2).All(newQueryContext(ctx, TypeMaintenanceEntry, "Only"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -161,7 +162,7 @@ func (meq *MaintenanceEntryQuery) OnlyX(ctx context.Context) *MaintenanceEntry {
// Returns a *NotFoundError when no entities are found. // Returns a *NotFoundError when no entities are found.
func (meq *MaintenanceEntryQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { func (meq *MaintenanceEntryQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = meq.Limit(2).IDs(ctx); err != nil { if ids, err = meq.Limit(2).IDs(newQueryContext(ctx, TypeMaintenanceEntry, "OnlyID")); err != nil {
return return
} }
switch len(ids) { switch len(ids) {
@ -186,10 +187,12 @@ func (meq *MaintenanceEntryQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of MaintenanceEntries. // All executes the query and returns a list of MaintenanceEntries.
func (meq *MaintenanceEntryQuery) All(ctx context.Context) ([]*MaintenanceEntry, error) { func (meq *MaintenanceEntryQuery) All(ctx context.Context) ([]*MaintenanceEntry, error) {
ctx = newQueryContext(ctx, TypeMaintenanceEntry, "All")
if err := meq.prepareQuery(ctx); err != nil { if err := meq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return meq.sqlAll(ctx) qr := querierAll[[]*MaintenanceEntry, *MaintenanceEntryQuery]()
return withInterceptors[[]*MaintenanceEntry](ctx, meq, qr, meq.inters)
} }
// AllX is like All, but panics if an error occurs. // AllX is like All, but panics if an error occurs.
@ -204,6 +207,7 @@ func (meq *MaintenanceEntryQuery) AllX(ctx context.Context) []*MaintenanceEntry
// IDs executes the query and returns a list of MaintenanceEntry IDs. // IDs executes the query and returns a list of MaintenanceEntry IDs.
func (meq *MaintenanceEntryQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (meq *MaintenanceEntryQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID var ids []uuid.UUID
ctx = newQueryContext(ctx, TypeMaintenanceEntry, "IDs")
if err := meq.Select(maintenanceentry.FieldID).Scan(ctx, &ids); err != nil { if err := meq.Select(maintenanceentry.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
@ -221,10 +225,11 @@ func (meq *MaintenanceEntryQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query. // Count returns the count of the given query.
func (meq *MaintenanceEntryQuery) Count(ctx context.Context) (int, error) { func (meq *MaintenanceEntryQuery) Count(ctx context.Context) (int, error) {
ctx = newQueryContext(ctx, TypeMaintenanceEntry, "Count")
if err := meq.prepareQuery(ctx); err != nil { if err := meq.prepareQuery(ctx); err != nil {
return 0, err return 0, err
} }
return meq.sqlCount(ctx) return withInterceptors[int](ctx, meq, querierCount[*MaintenanceEntryQuery](), meq.inters)
} }
// CountX is like Count, but panics if an error occurs. // CountX is like Count, but panics if an error occurs.
@ -238,10 +243,15 @@ func (meq *MaintenanceEntryQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph. // Exist returns true if the query has elements in the graph.
func (meq *MaintenanceEntryQuery) Exist(ctx context.Context) (bool, error) { func (meq *MaintenanceEntryQuery) Exist(ctx context.Context) (bool, error) {
if err := meq.prepareQuery(ctx); err != nil { ctx = newQueryContext(ctx, TypeMaintenanceEntry, "Exist")
return false, err switch _, err := meq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
} }
return meq.sqlExist(ctx)
} }
// ExistX is like Exist, but panics if an error occurs. // ExistX is like Exist, but panics if an error occurs.
@ -264,6 +274,7 @@ func (meq *MaintenanceEntryQuery) Clone() *MaintenanceEntryQuery {
limit: meq.limit, limit: meq.limit,
offset: meq.offset, offset: meq.offset,
order: append([]OrderFunc{}, meq.order...), order: append([]OrderFunc{}, meq.order...),
inters: append([]Interceptor{}, meq.inters...),
predicates: append([]predicate.MaintenanceEntry{}, meq.predicates...), predicates: append([]predicate.MaintenanceEntry{}, meq.predicates...),
withItem: meq.withItem.Clone(), withItem: meq.withItem.Clone(),
// clone intermediate query. // clone intermediate query.
@ -276,7 +287,7 @@ func (meq *MaintenanceEntryQuery) Clone() *MaintenanceEntryQuery {
// WithItem tells the query-builder to eager-load the nodes that are connected to // WithItem tells the query-builder to eager-load the nodes that are connected to
// the "item" edge. The optional arguments are used to configure the query builder of the edge. // the "item" edge. The optional arguments are used to configure the query builder of the edge.
func (meq *MaintenanceEntryQuery) WithItem(opts ...func(*ItemQuery)) *MaintenanceEntryQuery { func (meq *MaintenanceEntryQuery) WithItem(opts ...func(*ItemQuery)) *MaintenanceEntryQuery {
query := &ItemQuery{config: meq.config} query := (&ItemClient{config: meq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -299,16 +310,11 @@ func (meq *MaintenanceEntryQuery) WithItem(opts ...func(*ItemQuery)) *Maintenanc
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (meq *MaintenanceEntryQuery) GroupBy(field string, fields ...string) *MaintenanceEntryGroupBy { func (meq *MaintenanceEntryQuery) GroupBy(field string, fields ...string) *MaintenanceEntryGroupBy {
grbuild := &MaintenanceEntryGroupBy{config: meq.config} meq.fields = append([]string{field}, fields...)
grbuild.fields = append([]string{field}, fields...) grbuild := &MaintenanceEntryGroupBy{build: meq}
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { grbuild.flds = &meq.fields
if err := meq.prepareQuery(ctx); err != nil {
return nil, err
}
return meq.sqlQuery(ctx), nil
}
grbuild.label = maintenanceentry.Label grbuild.label = maintenanceentry.Label
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan grbuild.scan = grbuild.Scan
return grbuild return grbuild
} }
@ -326,10 +332,10 @@ func (meq *MaintenanceEntryQuery) GroupBy(field string, fields ...string) *Maint
// Scan(ctx, &v) // Scan(ctx, &v)
func (meq *MaintenanceEntryQuery) Select(fields ...string) *MaintenanceEntrySelect { func (meq *MaintenanceEntryQuery) Select(fields ...string) *MaintenanceEntrySelect {
meq.fields = append(meq.fields, fields...) meq.fields = append(meq.fields, fields...)
selbuild := &MaintenanceEntrySelect{MaintenanceEntryQuery: meq} sbuild := &MaintenanceEntrySelect{MaintenanceEntryQuery: meq}
selbuild.label = maintenanceentry.Label sbuild.label = maintenanceentry.Label
selbuild.flds, selbuild.scan = &meq.fields, selbuild.Scan sbuild.flds, sbuild.scan = &meq.fields, sbuild.Scan
return selbuild return sbuild
} }
// Aggregate returns a MaintenanceEntrySelect configured with the given aggregations. // Aggregate returns a MaintenanceEntrySelect configured with the given aggregations.
@ -338,6 +344,16 @@ func (meq *MaintenanceEntryQuery) Aggregate(fns ...AggregateFunc) *MaintenanceEn
} }
func (meq *MaintenanceEntryQuery) prepareQuery(ctx context.Context) error { func (meq *MaintenanceEntryQuery) prepareQuery(ctx context.Context) error {
for _, inter := range meq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, meq); err != nil {
return err
}
}
}
for _, f := range meq.fields { for _, f := range meq.fields {
if !maintenanceentry.ValidColumn(f) { if !maintenanceentry.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
@ -424,17 +440,6 @@ func (meq *MaintenanceEntryQuery) sqlCount(ctx context.Context) (int, error) {
return sqlgraph.CountNodes(ctx, meq.driver, _spec) return sqlgraph.CountNodes(ctx, meq.driver, _spec)
} }
func (meq *MaintenanceEntryQuery) sqlExist(ctx context.Context) (bool, error) {
switch _, err := meq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
func (meq *MaintenanceEntryQuery) querySpec() *sqlgraph.QuerySpec { func (meq *MaintenanceEntryQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
@ -517,13 +522,8 @@ func (meq *MaintenanceEntryQuery) sqlQuery(ctx context.Context) *sql.Selector {
// MaintenanceEntryGroupBy is the group-by builder for MaintenanceEntry entities. // MaintenanceEntryGroupBy is the group-by builder for MaintenanceEntry entities.
type MaintenanceEntryGroupBy struct { type MaintenanceEntryGroupBy struct {
config
selector selector
fields []string build *MaintenanceEntryQuery
fns []AggregateFunc
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
} }
// Aggregate adds the given aggregation functions to the group-by query. // Aggregate adds the given aggregation functions to the group-by query.
@ -532,58 +532,46 @@ func (megb *MaintenanceEntryGroupBy) Aggregate(fns ...AggregateFunc) *Maintenanc
return megb return megb
} }
// Scan applies the group-by query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (megb *MaintenanceEntryGroupBy) Scan(ctx context.Context, v any) error { func (megb *MaintenanceEntryGroupBy) Scan(ctx context.Context, v any) error {
query, err := megb.path(ctx) ctx = newQueryContext(ctx, TypeMaintenanceEntry, "GroupBy")
if err != nil { if err := megb.build.prepareQuery(ctx); err != nil {
return err return err
} }
megb.sql = query return scanWithInterceptors[*MaintenanceEntryQuery, *MaintenanceEntryGroupBy](ctx, megb.build, megb, megb.build.inters, v)
return megb.sqlScan(ctx, v)
} }
func (megb *MaintenanceEntryGroupBy) sqlScan(ctx context.Context, v any) error { func (megb *MaintenanceEntryGroupBy) sqlScan(ctx context.Context, root *MaintenanceEntryQuery, v any) error {
for _, f := range megb.fields { selector := root.sqlQuery(ctx).Select()
if !maintenanceentry.ValidColumn(f) { aggregation := make([]string, 0, len(megb.fns))
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} for _, fn := range megb.fns {
} aggregation = append(aggregation, fn(selector))
} }
selector := megb.sqlQuery() if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*megb.flds)+len(megb.fns))
for _, f := range *megb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*megb.flds...)...)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return err return err
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() query, args := selector.Query()
if err := megb.driver.Query(ctx, query, args, rows); err != nil { if err := megb.build.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }
defer rows.Close() defer rows.Close()
return sql.ScanSlice(rows, v) return sql.ScanSlice(rows, v)
} }
func (megb *MaintenanceEntryGroupBy) sqlQuery() *sql.Selector {
selector := megb.sql.Select()
aggregation := make([]string, 0, len(megb.fns))
for _, fn := range megb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(megb.fields)+len(megb.fns))
for _, f := range megb.fields {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
return selector.GroupBy(selector.Columns(megb.fields...)...)
}
// MaintenanceEntrySelect is the builder for selecting fields of MaintenanceEntry entities. // MaintenanceEntrySelect is the builder for selecting fields of MaintenanceEntry entities.
type MaintenanceEntrySelect struct { type MaintenanceEntrySelect struct {
*MaintenanceEntryQuery *MaintenanceEntryQuery
selector selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
@ -594,26 +582,27 @@ func (mes *MaintenanceEntrySelect) Aggregate(fns ...AggregateFunc) *MaintenanceE
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (mes *MaintenanceEntrySelect) Scan(ctx context.Context, v any) error { func (mes *MaintenanceEntrySelect) Scan(ctx context.Context, v any) error {
ctx = newQueryContext(ctx, TypeMaintenanceEntry, "Select")
if err := mes.prepareQuery(ctx); err != nil { if err := mes.prepareQuery(ctx); err != nil {
return err return err
} }
mes.sql = mes.MaintenanceEntryQuery.sqlQuery(ctx) return scanWithInterceptors[*MaintenanceEntryQuery, *MaintenanceEntrySelect](ctx, mes.MaintenanceEntryQuery, mes, mes.inters, v)
return mes.sqlScan(ctx, v)
} }
func (mes *MaintenanceEntrySelect) sqlScan(ctx context.Context, v any) error { func (mes *MaintenanceEntrySelect) sqlScan(ctx context.Context, root *MaintenanceEntryQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(mes.fns)) aggregation := make([]string, 0, len(mes.fns))
for _, fn := range mes.fns { for _, fn := range mes.fns {
aggregation = append(aggregation, fn(mes.sql)) aggregation = append(aggregation, fn(selector))
} }
switch n := len(*mes.selector.flds); { switch n := len(*mes.selector.flds); {
case n == 0 && len(aggregation) > 0: case n == 0 && len(aggregation) > 0:
mes.sql.Select(aggregation...) selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0: case n != 0 && len(aggregation) > 0:
mes.sql.AppendSelect(aggregation...) selector.AppendSelect(aggregation...)
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := mes.sql.Query() query, args := selector.Query()
if err := mes.driver.Query(ctx, query, args, rows); err != nil { if err := mes.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }

View file

@ -121,41 +121,8 @@ func (meu *MaintenanceEntryUpdate) ClearItem() *MaintenanceEntryUpdate {
// Save executes the query and returns the number of nodes affected by the update operation. // Save executes the query and returns the number of nodes affected by the update operation.
func (meu *MaintenanceEntryUpdate) Save(ctx context.Context) (int, error) { func (meu *MaintenanceEntryUpdate) Save(ctx context.Context) (int, error) {
var (
err error
affected int
)
meu.defaults() meu.defaults()
if len(meu.hooks) == 0 { return withHooks[int, MaintenanceEntryMutation](ctx, meu.sqlSave, meu.mutation, meu.hooks)
if err = meu.check(); err != nil {
return 0, err
}
affected, err = meu.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*MaintenanceEntryMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = meu.check(); err != nil {
return 0, err
}
meu.mutation = mutation
affected, err = meu.sqlSave(ctx)
mutation.done = true
return affected, err
})
for i := len(meu.hooks) - 1; i >= 0; i-- {
if meu.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = meu.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, meu.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -207,6 +174,9 @@ func (meu *MaintenanceEntryUpdate) check() error {
} }
func (meu *MaintenanceEntryUpdate) sqlSave(ctx context.Context) (n int, err error) { func (meu *MaintenanceEntryUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := meu.check(); err != nil {
return n, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: maintenanceentry.Table, Table: maintenanceentry.Table,
@ -288,6 +258,7 @@ func (meu *MaintenanceEntryUpdate) sqlSave(ctx context.Context) (n int, err erro
} }
return 0, err return 0, err
} }
meu.mutation.done = true
return n, nil return n, nil
} }
@ -397,47 +368,8 @@ func (meuo *MaintenanceEntryUpdateOne) Select(field string, fields ...string) *M
// Save executes the query and returns the updated MaintenanceEntry entity. // Save executes the query and returns the updated MaintenanceEntry entity.
func (meuo *MaintenanceEntryUpdateOne) Save(ctx context.Context) (*MaintenanceEntry, error) { func (meuo *MaintenanceEntryUpdateOne) Save(ctx context.Context) (*MaintenanceEntry, error) {
var (
err error
node *MaintenanceEntry
)
meuo.defaults() meuo.defaults()
if len(meuo.hooks) == 0 { return withHooks[*MaintenanceEntry, MaintenanceEntryMutation](ctx, meuo.sqlSave, meuo.mutation, meuo.hooks)
if err = meuo.check(); err != nil {
return nil, err
}
node, err = meuo.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*MaintenanceEntryMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = meuo.check(); err != nil {
return nil, err
}
meuo.mutation = mutation
node, err = meuo.sqlSave(ctx)
mutation.done = true
return node, err
})
for i := len(meuo.hooks) - 1; i >= 0; i-- {
if meuo.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = meuo.hooks[i](mut)
}
v, err := mut.Mutate(ctx, meuo.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*MaintenanceEntry)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from MaintenanceEntryMutation", v)
}
node = nv
}
return node, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -489,6 +421,9 @@ func (meuo *MaintenanceEntryUpdateOne) check() error {
} }
func (meuo *MaintenanceEntryUpdateOne) sqlSave(ctx context.Context) (_node *MaintenanceEntry, err error) { func (meuo *MaintenanceEntryUpdateOne) sqlSave(ctx context.Context) (_node *MaintenanceEntry, err error) {
if err := meuo.check(); err != nil {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: maintenanceentry.Table, Table: maintenanceentry.Table,
@ -590,5 +525,6 @@ func (meuo *MaintenanceEntryUpdateOne) sqlSave(ctx context.Context) (_node *Main
} }
return nil, err return nil, err
} }
meuo.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -25,6 +25,7 @@ import (
"github.com/hay-kot/homebox/backend/internal/data/ent/user" "github.com/hay-kot/homebox/backend/internal/data/ent/user"
"entgo.io/ent" "entgo.io/ent"
"entgo.io/ent/dialect/sql"
) )
const ( const (
@ -364,11 +365,26 @@ func (m *AttachmentMutation) Where(ps ...predicate.Attachment) {
m.predicates = append(m.predicates, ps...) m.predicates = append(m.predicates, ps...)
} }
// WhereP appends storage-level predicates to the AttachmentMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *AttachmentMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Attachment, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name. // Op returns the operation name.
func (m *AttachmentMutation) Op() Op { func (m *AttachmentMutation) Op() Op {
return m.op return m.op
} }
// SetOp allows setting the mutation operation.
func (m *AttachmentMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Attachment). // Type returns the node type of this mutation (Attachment).
func (m *AttachmentMutation) Type() string { func (m *AttachmentMutation) Type() string {
return m.typ return m.typ
@ -794,11 +810,26 @@ func (m *AuthRolesMutation) Where(ps ...predicate.AuthRoles) {
m.predicates = append(m.predicates, ps...) m.predicates = append(m.predicates, ps...)
} }
// WhereP appends storage-level predicates to the AuthRolesMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *AuthRolesMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.AuthRoles, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name. // Op returns the operation name.
func (m *AuthRolesMutation) Op() Op { func (m *AuthRolesMutation) Op() Op {
return m.op return m.op
} }
// SetOp allows setting the mutation operation.
func (m *AuthRolesMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (AuthRoles). // Type returns the node type of this mutation (AuthRoles).
func (m *AuthRolesMutation) Type() string { func (m *AuthRolesMutation) Type() string {
return m.typ return m.typ
@ -1330,11 +1361,26 @@ func (m *AuthTokensMutation) Where(ps ...predicate.AuthTokens) {
m.predicates = append(m.predicates, ps...) m.predicates = append(m.predicates, ps...)
} }
// WhereP appends storage-level predicates to the AuthTokensMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *AuthTokensMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.AuthTokens, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name. // Op returns the operation name.
func (m *AuthTokensMutation) Op() Op { func (m *AuthTokensMutation) Op() Op {
return m.op return m.op
} }
// SetOp allows setting the mutation operation.
func (m *AuthTokensMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (AuthTokens). // Type returns the node type of this mutation (AuthTokens).
func (m *AuthTokensMutation) Type() string { func (m *AuthTokensMutation) Type() string {
return m.typ return m.typ
@ -1951,11 +1997,26 @@ func (m *DocumentMutation) Where(ps ...predicate.Document) {
m.predicates = append(m.predicates, ps...) m.predicates = append(m.predicates, ps...)
} }
// WhereP appends storage-level predicates to the DocumentMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *DocumentMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Document, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name. // Op returns the operation name.
func (m *DocumentMutation) Op() Op { func (m *DocumentMutation) Op() Op {
return m.op return m.op
} }
// SetOp allows setting the mutation operation.
func (m *DocumentMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Document). // Type returns the node type of this mutation (Document).
func (m *DocumentMutation) Type() string { func (m *DocumentMutation) Type() string {
return m.typ return m.typ
@ -2826,11 +2887,26 @@ func (m *GroupMutation) Where(ps ...predicate.Group) {
m.predicates = append(m.predicates, ps...) m.predicates = append(m.predicates, ps...)
} }
// WhereP appends storage-level predicates to the GroupMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *GroupMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Group, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name. // Op returns the operation name.
func (m *GroupMutation) Op() Op { func (m *GroupMutation) Op() Op {
return m.op return m.op
} }
// SetOp allows setting the mutation operation.
func (m *GroupMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Group). // Type returns the node type of this mutation (Group).
func (m *GroupMutation) Type() string { func (m *GroupMutation) Type() string {
return m.typ return m.typ
@ -3570,11 +3646,26 @@ func (m *GroupInvitationTokenMutation) Where(ps ...predicate.GroupInvitationToke
m.predicates = append(m.predicates, ps...) m.predicates = append(m.predicates, ps...)
} }
// WhereP appends storage-level predicates to the GroupInvitationTokenMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *GroupInvitationTokenMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.GroupInvitationToken, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name. // Op returns the operation name.
func (m *GroupInvitationTokenMutation) Op() Op { func (m *GroupInvitationTokenMutation) Op() Op {
return m.op return m.op
} }
// SetOp allows setting the mutation operation.
func (m *GroupInvitationTokenMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (GroupInvitationToken). // Type returns the node type of this mutation (GroupInvitationToken).
func (m *GroupInvitationTokenMutation) Type() string { func (m *GroupInvitationTokenMutation) Type() string {
return m.typ return m.typ
@ -5471,11 +5562,26 @@ func (m *ItemMutation) Where(ps ...predicate.Item) {
m.predicates = append(m.predicates, ps...) m.predicates = append(m.predicates, ps...)
} }
// WhereP appends storage-level predicates to the ItemMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *ItemMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Item, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name. // Op returns the operation name.
func (m *ItemMutation) Op() Op { func (m *ItemMutation) Op() Op {
return m.op return m.op
} }
// SetOp allows setting the mutation operation.
func (m *ItemMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Item). // Type returns the node type of this mutation (Item).
func (m *ItemMutation) Type() string { func (m *ItemMutation) Type() string {
return m.typ return m.typ
@ -6886,11 +6992,26 @@ func (m *ItemFieldMutation) Where(ps ...predicate.ItemField) {
m.predicates = append(m.predicates, ps...) m.predicates = append(m.predicates, ps...)
} }
// WhereP appends storage-level predicates to the ItemFieldMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *ItemFieldMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.ItemField, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name. // Op returns the operation name.
func (m *ItemFieldMutation) Op() Op { func (m *ItemFieldMutation) Op() Op {
return m.op return m.op
} }
// SetOp allows setting the mutation operation.
func (m *ItemFieldMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (ItemField). // Type returns the node type of this mutation (ItemField).
func (m *ItemFieldMutation) Type() string { func (m *ItemFieldMutation) Type() string {
return m.typ return m.typ
@ -7673,11 +7794,26 @@ func (m *LabelMutation) Where(ps ...predicate.Label) {
m.predicates = append(m.predicates, ps...) m.predicates = append(m.predicates, ps...)
} }
// WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Label, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name. // Op returns the operation name.
func (m *LabelMutation) Op() Op { func (m *LabelMutation) Op() Op {
return m.op return m.op
} }
// SetOp allows setting the mutation operation.
func (m *LabelMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Label). // Type returns the node type of this mutation (Label).
func (m *LabelMutation) Type() string { func (m *LabelMutation) Type() string {
return m.typ return m.typ
@ -8447,11 +8583,26 @@ func (m *LocationMutation) Where(ps ...predicate.Location) {
m.predicates = append(m.predicates, ps...) m.predicates = append(m.predicates, ps...)
} }
// WhereP appends storage-level predicates to the LocationMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *LocationMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Location, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name. // Op returns the operation name.
func (m *LocationMutation) Op() Op { func (m *LocationMutation) Op() Op {
return m.op return m.op
} }
// SetOp allows setting the mutation operation.
func (m *LocationMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Location). // Type returns the node type of this mutation (Location).
func (m *LocationMutation) Type() string { func (m *LocationMutation) Type() string {
return m.typ return m.typ
@ -9205,11 +9356,26 @@ func (m *MaintenanceEntryMutation) Where(ps ...predicate.MaintenanceEntry) {
m.predicates = append(m.predicates, ps...) m.predicates = append(m.predicates, ps...)
} }
// WhereP appends storage-level predicates to the MaintenanceEntryMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *MaintenanceEntryMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.MaintenanceEntry, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name. // Op returns the operation name.
func (m *MaintenanceEntryMutation) Op() Op { func (m *MaintenanceEntryMutation) Op() Op {
return m.op return m.op
} }
// SetOp allows setting the mutation operation.
func (m *MaintenanceEntryMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (MaintenanceEntry). // Type returns the node type of this mutation (MaintenanceEntry).
func (m *MaintenanceEntryMutation) Type() string { func (m *MaintenanceEntryMutation) Type() string {
return m.typ return m.typ
@ -10081,11 +10247,26 @@ func (m *UserMutation) Where(ps ...predicate.User) {
m.predicates = append(m.predicates, ps...) m.predicates = append(m.predicates, ps...)
} }
// WhereP appends storage-level predicates to the UserMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.User, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name. // Op returns the operation name.
func (m *UserMutation) Op() Op { func (m *UserMutation) Op() Op {
return m.op return m.op
} }
// SetOp allows setting the mutation operation.
func (m *UserMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (User). // Type returns the node type of this mutation (User).
func (m *UserMutation) Type() string { func (m *UserMutation) Type() string {
return m.typ return m.typ

View file

@ -5,6 +5,6 @@ package runtime
// The schema-stitching logic is generated in github.com/hay-kot/homebox/backend/internal/data/ent/runtime.go // The schema-stitching logic is generated in github.com/hay-kot/homebox/backend/internal/data/ent/runtime.go
const ( const (
Version = "v0.11.4" // Version of ent codegen. Version = "v0.11.5" // Version of ent codegen.
Sum = "h1:grwVY0fp31BZ6oEo3YrXenAuv8VJmEw7F/Bi6WqeH3Q=" // Sum of ent codegen. Sum = "h1:V2qhG91C4PMQTa82Q4StoESMQ4dzkMNeStCzszxi0jQ=" // Sum of ent codegen.
) )

View file

@ -13,696 +13,452 @@ import (
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.
func ID(id uuid.UUID) predicate.User { func ID(id uuid.UUID) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDEQ applies the EQ predicate on the ID field. // IDEQ applies the EQ predicate on the ID field.
func IDEQ(id uuid.UUID) predicate.User { func IDEQ(id uuid.UUID) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEQ(FieldID, id))
s.Where(sql.EQ(s.C(FieldID), id))
})
} }
// IDNEQ applies the NEQ predicate on the ID field. // IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id uuid.UUID) predicate.User { func IDNEQ(id uuid.UUID) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldNEQ(FieldID, id))
s.Where(sql.NEQ(s.C(FieldID), id))
})
} }
// IDIn applies the In predicate on the ID field. // IDIn applies the In predicate on the ID field.
func IDIn(ids ...uuid.UUID) predicate.User { func IDIn(ids ...uuid.UUID) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.In(s.C(FieldID), v...))
})
} }
// IDNotIn applies the NotIn predicate on the ID field. // IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...uuid.UUID) predicate.User { func IDNotIn(ids ...uuid.UUID) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldNotIn(FieldID, ids...))
v := make([]any, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.NotIn(s.C(FieldID), v...))
})
} }
// IDGT applies the GT predicate on the ID field. // IDGT applies the GT predicate on the ID field.
func IDGT(id uuid.UUID) predicate.User { func IDGT(id uuid.UUID) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldGT(FieldID, id))
s.Where(sql.GT(s.C(FieldID), id))
})
} }
// IDGTE applies the GTE predicate on the ID field. // IDGTE applies the GTE predicate on the ID field.
func IDGTE(id uuid.UUID) predicate.User { func IDGTE(id uuid.UUID) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldGTE(FieldID, id))
s.Where(sql.GTE(s.C(FieldID), id))
})
} }
// IDLT applies the LT predicate on the ID field. // IDLT applies the LT predicate on the ID field.
func IDLT(id uuid.UUID) predicate.User { func IDLT(id uuid.UUID) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldLT(FieldID, id))
s.Where(sql.LT(s.C(FieldID), id))
})
} }
// IDLTE applies the LTE predicate on the ID field. // IDLTE applies the LTE predicate on the ID field.
func IDLTE(id uuid.UUID) predicate.User { func IDLTE(id uuid.UUID) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldLTE(FieldID, id))
s.Where(sql.LTE(s.C(FieldID), id))
})
} }
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. // CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.User { func CreatedAt(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. // UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.User { func UpdatedAt(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// Name applies equality check predicate on the "name" field. It's identical to NameEQ. // Name applies equality check predicate on the "name" field. It's identical to NameEQ.
func Name(v string) predicate.User { func Name(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEQ(FieldName, v))
s.Where(sql.EQ(s.C(FieldName), v))
})
} }
// Email applies equality check predicate on the "email" field. It's identical to EmailEQ. // Email applies equality check predicate on the "email" field. It's identical to EmailEQ.
func Email(v string) predicate.User { func Email(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEQ(FieldEmail, v))
s.Where(sql.EQ(s.C(FieldEmail), v))
})
} }
// Password applies equality check predicate on the "password" field. It's identical to PasswordEQ. // Password applies equality check predicate on the "password" field. It's identical to PasswordEQ.
func Password(v string) predicate.User { func Password(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEQ(FieldPassword, v))
s.Where(sql.EQ(s.C(FieldPassword), v))
})
} }
// IsSuperuser applies equality check predicate on the "is_superuser" field. It's identical to IsSuperuserEQ. // IsSuperuser applies equality check predicate on the "is_superuser" field. It's identical to IsSuperuserEQ.
func IsSuperuser(v bool) predicate.User { func IsSuperuser(v bool) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEQ(FieldIsSuperuser, v))
s.Where(sql.EQ(s.C(FieldIsSuperuser), v))
})
} }
// Superuser applies equality check predicate on the "superuser" field. It's identical to SuperuserEQ. // Superuser applies equality check predicate on the "superuser" field. It's identical to SuperuserEQ.
func Superuser(v bool) predicate.User { func Superuser(v bool) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEQ(FieldSuperuser, v))
s.Where(sql.EQ(s.C(FieldSuperuser), v))
})
} }
// ActivatedOn applies equality check predicate on the "activated_on" field. It's identical to ActivatedOnEQ. // ActivatedOn applies equality check predicate on the "activated_on" field. It's identical to ActivatedOnEQ.
func ActivatedOn(v time.Time) predicate.User { func ActivatedOn(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEQ(FieldActivatedOn, v))
s.Where(sql.EQ(s.C(FieldActivatedOn), v))
})
} }
// CreatedAtEQ applies the EQ predicate on the "created_at" field. // CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.User { func CreatedAtEQ(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEQ(FieldCreatedAt, v))
s.Where(sql.EQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. // CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.User { func CreatedAtNEQ(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldNEQ(FieldCreatedAt, v))
s.Where(sql.NEQ(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtIn applies the In predicate on the "created_at" field. // CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.User { func CreatedAtIn(vs ...time.Time) predicate.User {
v := make([]any, len(vs)) return predicate.User(sql.FieldIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.User(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. // CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.User { func CreatedAtNotIn(vs ...time.Time) predicate.User {
v := make([]any, len(vs)) return predicate.User(sql.FieldNotIn(FieldCreatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.User(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
})
} }
// CreatedAtGT applies the GT predicate on the "created_at" field. // CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.User { func CreatedAtGT(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldGT(FieldCreatedAt, v))
s.Where(sql.GT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtGTE applies the GTE predicate on the "created_at" field. // CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.User { func CreatedAtGTE(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldGTE(FieldCreatedAt, v))
s.Where(sql.GTE(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLT applies the LT predicate on the "created_at" field. // CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.User { func CreatedAtLT(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldLT(FieldCreatedAt, v))
s.Where(sql.LT(s.C(FieldCreatedAt), v))
})
} }
// CreatedAtLTE applies the LTE predicate on the "created_at" field. // CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.User { func CreatedAtLTE(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldLTE(FieldCreatedAt, v))
s.Where(sql.LTE(s.C(FieldCreatedAt), v))
})
} }
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. // UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.User { func UpdatedAtEQ(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEQ(FieldUpdatedAt, v))
s.Where(sql.EQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. // UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.User { func UpdatedAtNEQ(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldNEQ(FieldUpdatedAt, v))
s.Where(sql.NEQ(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtIn applies the In predicate on the "updated_at" field. // UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.User { func UpdatedAtIn(vs ...time.Time) predicate.User {
v := make([]any, len(vs)) return predicate.User(sql.FieldIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.User(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. // UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.User { func UpdatedAtNotIn(vs ...time.Time) predicate.User {
v := make([]any, len(vs)) return predicate.User(sql.FieldNotIn(FieldUpdatedAt, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.User(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
})
} }
// UpdatedAtGT applies the GT predicate on the "updated_at" field. // UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.User { func UpdatedAtGT(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldGT(FieldUpdatedAt, v))
s.Where(sql.GT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. // UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.User { func UpdatedAtGTE(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldGTE(FieldUpdatedAt, v))
s.Where(sql.GTE(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLT applies the LT predicate on the "updated_at" field. // UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.User { func UpdatedAtLT(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldLT(FieldUpdatedAt, v))
s.Where(sql.LT(s.C(FieldUpdatedAt), v))
})
} }
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. // UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.User { func UpdatedAtLTE(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldLTE(FieldUpdatedAt, v))
s.Where(sql.LTE(s.C(FieldUpdatedAt), v))
})
} }
// NameEQ applies the EQ predicate on the "name" field. // NameEQ applies the EQ predicate on the "name" field.
func NameEQ(v string) predicate.User { func NameEQ(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEQ(FieldName, v))
s.Where(sql.EQ(s.C(FieldName), v))
})
} }
// NameNEQ applies the NEQ predicate on the "name" field. // NameNEQ applies the NEQ predicate on the "name" field.
func NameNEQ(v string) predicate.User { func NameNEQ(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldNEQ(FieldName, v))
s.Where(sql.NEQ(s.C(FieldName), v))
})
} }
// NameIn applies the In predicate on the "name" field. // NameIn applies the In predicate on the "name" field.
func NameIn(vs ...string) predicate.User { func NameIn(vs ...string) predicate.User {
v := make([]any, len(vs)) return predicate.User(sql.FieldIn(FieldName, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.User(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldName), v...))
})
} }
// NameNotIn applies the NotIn predicate on the "name" field. // NameNotIn applies the NotIn predicate on the "name" field.
func NameNotIn(vs ...string) predicate.User { func NameNotIn(vs ...string) predicate.User {
v := make([]any, len(vs)) return predicate.User(sql.FieldNotIn(FieldName, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.User(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldName), v...))
})
} }
// NameGT applies the GT predicate on the "name" field. // NameGT applies the GT predicate on the "name" field.
func NameGT(v string) predicate.User { func NameGT(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldGT(FieldName, v))
s.Where(sql.GT(s.C(FieldName), v))
})
} }
// NameGTE applies the GTE predicate on the "name" field. // NameGTE applies the GTE predicate on the "name" field.
func NameGTE(v string) predicate.User { func NameGTE(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldGTE(FieldName, v))
s.Where(sql.GTE(s.C(FieldName), v))
})
} }
// NameLT applies the LT predicate on the "name" field. // NameLT applies the LT predicate on the "name" field.
func NameLT(v string) predicate.User { func NameLT(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldLT(FieldName, v))
s.Where(sql.LT(s.C(FieldName), v))
})
} }
// NameLTE applies the LTE predicate on the "name" field. // NameLTE applies the LTE predicate on the "name" field.
func NameLTE(v string) predicate.User { func NameLTE(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldLTE(FieldName, v))
s.Where(sql.LTE(s.C(FieldName), v))
})
} }
// NameContains applies the Contains predicate on the "name" field. // NameContains applies the Contains predicate on the "name" field.
func NameContains(v string) predicate.User { func NameContains(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldContains(FieldName, v))
s.Where(sql.Contains(s.C(FieldName), v))
})
} }
// NameHasPrefix applies the HasPrefix predicate on the "name" field. // NameHasPrefix applies the HasPrefix predicate on the "name" field.
func NameHasPrefix(v string) predicate.User { func NameHasPrefix(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldHasPrefix(FieldName, v))
s.Where(sql.HasPrefix(s.C(FieldName), v))
})
} }
// NameHasSuffix applies the HasSuffix predicate on the "name" field. // NameHasSuffix applies the HasSuffix predicate on the "name" field.
func NameHasSuffix(v string) predicate.User { func NameHasSuffix(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldHasSuffix(FieldName, v))
s.Where(sql.HasSuffix(s.C(FieldName), v))
})
} }
// NameEqualFold applies the EqualFold predicate on the "name" field. // NameEqualFold applies the EqualFold predicate on the "name" field.
func NameEqualFold(v string) predicate.User { func NameEqualFold(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEqualFold(FieldName, v))
s.Where(sql.EqualFold(s.C(FieldName), v))
})
} }
// NameContainsFold applies the ContainsFold predicate on the "name" field. // NameContainsFold applies the ContainsFold predicate on the "name" field.
func NameContainsFold(v string) predicate.User { func NameContainsFold(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldContainsFold(FieldName, v))
s.Where(sql.ContainsFold(s.C(FieldName), v))
})
} }
// EmailEQ applies the EQ predicate on the "email" field. // EmailEQ applies the EQ predicate on the "email" field.
func EmailEQ(v string) predicate.User { func EmailEQ(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEQ(FieldEmail, v))
s.Where(sql.EQ(s.C(FieldEmail), v))
})
} }
// EmailNEQ applies the NEQ predicate on the "email" field. // EmailNEQ applies the NEQ predicate on the "email" field.
func EmailNEQ(v string) predicate.User { func EmailNEQ(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldNEQ(FieldEmail, v))
s.Where(sql.NEQ(s.C(FieldEmail), v))
})
} }
// EmailIn applies the In predicate on the "email" field. // EmailIn applies the In predicate on the "email" field.
func EmailIn(vs ...string) predicate.User { func EmailIn(vs ...string) predicate.User {
v := make([]any, len(vs)) return predicate.User(sql.FieldIn(FieldEmail, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.User(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldEmail), v...))
})
} }
// EmailNotIn applies the NotIn predicate on the "email" field. // EmailNotIn applies the NotIn predicate on the "email" field.
func EmailNotIn(vs ...string) predicate.User { func EmailNotIn(vs ...string) predicate.User {
v := make([]any, len(vs)) return predicate.User(sql.FieldNotIn(FieldEmail, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.User(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldEmail), v...))
})
} }
// EmailGT applies the GT predicate on the "email" field. // EmailGT applies the GT predicate on the "email" field.
func EmailGT(v string) predicate.User { func EmailGT(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldGT(FieldEmail, v))
s.Where(sql.GT(s.C(FieldEmail), v))
})
} }
// EmailGTE applies the GTE predicate on the "email" field. // EmailGTE applies the GTE predicate on the "email" field.
func EmailGTE(v string) predicate.User { func EmailGTE(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldGTE(FieldEmail, v))
s.Where(sql.GTE(s.C(FieldEmail), v))
})
} }
// EmailLT applies the LT predicate on the "email" field. // EmailLT applies the LT predicate on the "email" field.
func EmailLT(v string) predicate.User { func EmailLT(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldLT(FieldEmail, v))
s.Where(sql.LT(s.C(FieldEmail), v))
})
} }
// EmailLTE applies the LTE predicate on the "email" field. // EmailLTE applies the LTE predicate on the "email" field.
func EmailLTE(v string) predicate.User { func EmailLTE(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldLTE(FieldEmail, v))
s.Where(sql.LTE(s.C(FieldEmail), v))
})
} }
// EmailContains applies the Contains predicate on the "email" field. // EmailContains applies the Contains predicate on the "email" field.
func EmailContains(v string) predicate.User { func EmailContains(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldContains(FieldEmail, v))
s.Where(sql.Contains(s.C(FieldEmail), v))
})
} }
// EmailHasPrefix applies the HasPrefix predicate on the "email" field. // EmailHasPrefix applies the HasPrefix predicate on the "email" field.
func EmailHasPrefix(v string) predicate.User { func EmailHasPrefix(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldHasPrefix(FieldEmail, v))
s.Where(sql.HasPrefix(s.C(FieldEmail), v))
})
} }
// EmailHasSuffix applies the HasSuffix predicate on the "email" field. // EmailHasSuffix applies the HasSuffix predicate on the "email" field.
func EmailHasSuffix(v string) predicate.User { func EmailHasSuffix(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldHasSuffix(FieldEmail, v))
s.Where(sql.HasSuffix(s.C(FieldEmail), v))
})
} }
// EmailEqualFold applies the EqualFold predicate on the "email" field. // EmailEqualFold applies the EqualFold predicate on the "email" field.
func EmailEqualFold(v string) predicate.User { func EmailEqualFold(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEqualFold(FieldEmail, v))
s.Where(sql.EqualFold(s.C(FieldEmail), v))
})
} }
// EmailContainsFold applies the ContainsFold predicate on the "email" field. // EmailContainsFold applies the ContainsFold predicate on the "email" field.
func EmailContainsFold(v string) predicate.User { func EmailContainsFold(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldContainsFold(FieldEmail, v))
s.Where(sql.ContainsFold(s.C(FieldEmail), v))
})
} }
// PasswordEQ applies the EQ predicate on the "password" field. // PasswordEQ applies the EQ predicate on the "password" field.
func PasswordEQ(v string) predicate.User { func PasswordEQ(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEQ(FieldPassword, v))
s.Where(sql.EQ(s.C(FieldPassword), v))
})
} }
// PasswordNEQ applies the NEQ predicate on the "password" field. // PasswordNEQ applies the NEQ predicate on the "password" field.
func PasswordNEQ(v string) predicate.User { func PasswordNEQ(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldNEQ(FieldPassword, v))
s.Where(sql.NEQ(s.C(FieldPassword), v))
})
} }
// PasswordIn applies the In predicate on the "password" field. // PasswordIn applies the In predicate on the "password" field.
func PasswordIn(vs ...string) predicate.User { func PasswordIn(vs ...string) predicate.User {
v := make([]any, len(vs)) return predicate.User(sql.FieldIn(FieldPassword, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.User(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldPassword), v...))
})
} }
// PasswordNotIn applies the NotIn predicate on the "password" field. // PasswordNotIn applies the NotIn predicate on the "password" field.
func PasswordNotIn(vs ...string) predicate.User { func PasswordNotIn(vs ...string) predicate.User {
v := make([]any, len(vs)) return predicate.User(sql.FieldNotIn(FieldPassword, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.User(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldPassword), v...))
})
} }
// PasswordGT applies the GT predicate on the "password" field. // PasswordGT applies the GT predicate on the "password" field.
func PasswordGT(v string) predicate.User { func PasswordGT(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldGT(FieldPassword, v))
s.Where(sql.GT(s.C(FieldPassword), v))
})
} }
// PasswordGTE applies the GTE predicate on the "password" field. // PasswordGTE applies the GTE predicate on the "password" field.
func PasswordGTE(v string) predicate.User { func PasswordGTE(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldGTE(FieldPassword, v))
s.Where(sql.GTE(s.C(FieldPassword), v))
})
} }
// PasswordLT applies the LT predicate on the "password" field. // PasswordLT applies the LT predicate on the "password" field.
func PasswordLT(v string) predicate.User { func PasswordLT(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldLT(FieldPassword, v))
s.Where(sql.LT(s.C(FieldPassword), v))
})
} }
// PasswordLTE applies the LTE predicate on the "password" field. // PasswordLTE applies the LTE predicate on the "password" field.
func PasswordLTE(v string) predicate.User { func PasswordLTE(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldLTE(FieldPassword, v))
s.Where(sql.LTE(s.C(FieldPassword), v))
})
} }
// PasswordContains applies the Contains predicate on the "password" field. // PasswordContains applies the Contains predicate on the "password" field.
func PasswordContains(v string) predicate.User { func PasswordContains(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldContains(FieldPassword, v))
s.Where(sql.Contains(s.C(FieldPassword), v))
})
} }
// PasswordHasPrefix applies the HasPrefix predicate on the "password" field. // PasswordHasPrefix applies the HasPrefix predicate on the "password" field.
func PasswordHasPrefix(v string) predicate.User { func PasswordHasPrefix(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldHasPrefix(FieldPassword, v))
s.Where(sql.HasPrefix(s.C(FieldPassword), v))
})
} }
// PasswordHasSuffix applies the HasSuffix predicate on the "password" field. // PasswordHasSuffix applies the HasSuffix predicate on the "password" field.
func PasswordHasSuffix(v string) predicate.User { func PasswordHasSuffix(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldHasSuffix(FieldPassword, v))
s.Where(sql.HasSuffix(s.C(FieldPassword), v))
})
} }
// PasswordEqualFold applies the EqualFold predicate on the "password" field. // PasswordEqualFold applies the EqualFold predicate on the "password" field.
func PasswordEqualFold(v string) predicate.User { func PasswordEqualFold(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEqualFold(FieldPassword, v))
s.Where(sql.EqualFold(s.C(FieldPassword), v))
})
} }
// PasswordContainsFold applies the ContainsFold predicate on the "password" field. // PasswordContainsFold applies the ContainsFold predicate on the "password" field.
func PasswordContainsFold(v string) predicate.User { func PasswordContainsFold(v string) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldContainsFold(FieldPassword, v))
s.Where(sql.ContainsFold(s.C(FieldPassword), v))
})
} }
// IsSuperuserEQ applies the EQ predicate on the "is_superuser" field. // IsSuperuserEQ applies the EQ predicate on the "is_superuser" field.
func IsSuperuserEQ(v bool) predicate.User { func IsSuperuserEQ(v bool) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEQ(FieldIsSuperuser, v))
s.Where(sql.EQ(s.C(FieldIsSuperuser), v))
})
} }
// IsSuperuserNEQ applies the NEQ predicate on the "is_superuser" field. // IsSuperuserNEQ applies the NEQ predicate on the "is_superuser" field.
func IsSuperuserNEQ(v bool) predicate.User { func IsSuperuserNEQ(v bool) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldNEQ(FieldIsSuperuser, v))
s.Where(sql.NEQ(s.C(FieldIsSuperuser), v))
})
} }
// RoleEQ applies the EQ predicate on the "role" field. // RoleEQ applies the EQ predicate on the "role" field.
func RoleEQ(v Role) predicate.User { func RoleEQ(v Role) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEQ(FieldRole, v))
s.Where(sql.EQ(s.C(FieldRole), v))
})
} }
// RoleNEQ applies the NEQ predicate on the "role" field. // RoleNEQ applies the NEQ predicate on the "role" field.
func RoleNEQ(v Role) predicate.User { func RoleNEQ(v Role) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldNEQ(FieldRole, v))
s.Where(sql.NEQ(s.C(FieldRole), v))
})
} }
// RoleIn applies the In predicate on the "role" field. // RoleIn applies the In predicate on the "role" field.
func RoleIn(vs ...Role) predicate.User { func RoleIn(vs ...Role) predicate.User {
v := make([]any, len(vs)) return predicate.User(sql.FieldIn(FieldRole, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.User(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldRole), v...))
})
} }
// RoleNotIn applies the NotIn predicate on the "role" field. // RoleNotIn applies the NotIn predicate on the "role" field.
func RoleNotIn(vs ...Role) predicate.User { func RoleNotIn(vs ...Role) predicate.User {
v := make([]any, len(vs)) return predicate.User(sql.FieldNotIn(FieldRole, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.User(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldRole), v...))
})
} }
// SuperuserEQ applies the EQ predicate on the "superuser" field. // SuperuserEQ applies the EQ predicate on the "superuser" field.
func SuperuserEQ(v bool) predicate.User { func SuperuserEQ(v bool) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEQ(FieldSuperuser, v))
s.Where(sql.EQ(s.C(FieldSuperuser), v))
})
} }
// SuperuserNEQ applies the NEQ predicate on the "superuser" field. // SuperuserNEQ applies the NEQ predicate on the "superuser" field.
func SuperuserNEQ(v bool) predicate.User { func SuperuserNEQ(v bool) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldNEQ(FieldSuperuser, v))
s.Where(sql.NEQ(s.C(FieldSuperuser), v))
})
} }
// ActivatedOnEQ applies the EQ predicate on the "activated_on" field. // ActivatedOnEQ applies the EQ predicate on the "activated_on" field.
func ActivatedOnEQ(v time.Time) predicate.User { func ActivatedOnEQ(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldEQ(FieldActivatedOn, v))
s.Where(sql.EQ(s.C(FieldActivatedOn), v))
})
} }
// ActivatedOnNEQ applies the NEQ predicate on the "activated_on" field. // ActivatedOnNEQ applies the NEQ predicate on the "activated_on" field.
func ActivatedOnNEQ(v time.Time) predicate.User { func ActivatedOnNEQ(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldNEQ(FieldActivatedOn, v))
s.Where(sql.NEQ(s.C(FieldActivatedOn), v))
})
} }
// ActivatedOnIn applies the In predicate on the "activated_on" field. // ActivatedOnIn applies the In predicate on the "activated_on" field.
func ActivatedOnIn(vs ...time.Time) predicate.User { func ActivatedOnIn(vs ...time.Time) predicate.User {
v := make([]any, len(vs)) return predicate.User(sql.FieldIn(FieldActivatedOn, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.User(func(s *sql.Selector) {
s.Where(sql.In(s.C(FieldActivatedOn), v...))
})
} }
// ActivatedOnNotIn applies the NotIn predicate on the "activated_on" field. // ActivatedOnNotIn applies the NotIn predicate on the "activated_on" field.
func ActivatedOnNotIn(vs ...time.Time) predicate.User { func ActivatedOnNotIn(vs ...time.Time) predicate.User {
v := make([]any, len(vs)) return predicate.User(sql.FieldNotIn(FieldActivatedOn, vs...))
for i := range v {
v[i] = vs[i]
}
return predicate.User(func(s *sql.Selector) {
s.Where(sql.NotIn(s.C(FieldActivatedOn), v...))
})
} }
// ActivatedOnGT applies the GT predicate on the "activated_on" field. // ActivatedOnGT applies the GT predicate on the "activated_on" field.
func ActivatedOnGT(v time.Time) predicate.User { func ActivatedOnGT(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldGT(FieldActivatedOn, v))
s.Where(sql.GT(s.C(FieldActivatedOn), v))
})
} }
// ActivatedOnGTE applies the GTE predicate on the "activated_on" field. // ActivatedOnGTE applies the GTE predicate on the "activated_on" field.
func ActivatedOnGTE(v time.Time) predicate.User { func ActivatedOnGTE(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldGTE(FieldActivatedOn, v))
s.Where(sql.GTE(s.C(FieldActivatedOn), v))
})
} }
// ActivatedOnLT applies the LT predicate on the "activated_on" field. // ActivatedOnLT applies the LT predicate on the "activated_on" field.
func ActivatedOnLT(v time.Time) predicate.User { func ActivatedOnLT(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldLT(FieldActivatedOn, v))
s.Where(sql.LT(s.C(FieldActivatedOn), v))
})
} }
// ActivatedOnLTE applies the LTE predicate on the "activated_on" field. // ActivatedOnLTE applies the LTE predicate on the "activated_on" field.
func ActivatedOnLTE(v time.Time) predicate.User { func ActivatedOnLTE(v time.Time) predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldLTE(FieldActivatedOn, v))
s.Where(sql.LTE(s.C(FieldActivatedOn), v))
})
} }
// ActivatedOnIsNil applies the IsNil predicate on the "activated_on" field. // ActivatedOnIsNil applies the IsNil predicate on the "activated_on" field.
func ActivatedOnIsNil() predicate.User { func ActivatedOnIsNil() predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldIsNull(FieldActivatedOn))
s.Where(sql.IsNull(s.C(FieldActivatedOn)))
})
} }
// ActivatedOnNotNil applies the NotNil predicate on the "activated_on" field. // ActivatedOnNotNil applies the NotNil predicate on the "activated_on" field.
func ActivatedOnNotNil() predicate.User { func ActivatedOnNotNil() predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(sql.FieldNotNull(FieldActivatedOn))
s.Where(sql.NotNull(s.C(FieldActivatedOn)))
})
} }
// HasGroup applies the HasEdge predicate on the "group" edge. // HasGroup applies the HasEdge predicate on the "group" edge.
@ -710,7 +466,6 @@ func HasGroup() predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(GroupTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn), sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)
@ -738,7 +493,6 @@ func HasAuthTokens() predicate.User {
return predicate.User(func(s *sql.Selector) { return predicate.User(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.To(AuthTokensTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, AuthTokensTable, AuthTokensColumn), sqlgraph.Edge(sqlgraph.O2M, false, AuthTokensTable, AuthTokensColumn),
) )
sqlgraph.HasNeighbors(s, step) sqlgraph.HasNeighbors(s, step)

View file

@ -172,50 +172,8 @@ func (uc *UserCreate) Mutation() *UserMutation {
// Save creates the User in the database. // Save creates the User in the database.
func (uc *UserCreate) Save(ctx context.Context) (*User, error) { func (uc *UserCreate) Save(ctx context.Context) (*User, error) {
var (
err error
node *User
)
uc.defaults() uc.defaults()
if len(uc.hooks) == 0 { return withHooks[*User, UserMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks)
if err = uc.check(); err != nil {
return nil, err
}
node, err = uc.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*UserMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = uc.check(); err != nil {
return nil, err
}
uc.mutation = mutation
if node, err = uc.sqlSave(ctx); err != nil {
return nil, err
}
mutation.id = &node.ID
mutation.done = true
return node, err
})
for i := len(uc.hooks) - 1; i >= 0; i-- {
if uc.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = uc.hooks[i](mut)
}
v, err := mut.Mutate(ctx, uc.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*User)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from UserMutation", v)
}
node = nv
}
return node, err
} }
// SaveX calls Save and panics if Save returns an error. // SaveX calls Save and panics if Save returns an error.
@ -321,6 +279,9 @@ func (uc *UserCreate) check() error {
} }
func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) {
if err := uc.check(); err != nil {
return nil, err
}
_node, _spec := uc.createSpec() _node, _spec := uc.createSpec()
if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) { if sqlgraph.IsConstraintError(err) {
@ -335,6 +296,8 @@ func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) {
return nil, err return nil, err
} }
} }
uc.mutation.id = &_node.ID
uc.mutation.done = true
return _node, nil return _node, nil
} }

View file

@ -4,7 +4,6 @@ package ent
import ( import (
"context" "context"
"fmt"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
@ -28,34 +27,7 @@ func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete {
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (ud *UserDelete) Exec(ctx context.Context) (int, error) { func (ud *UserDelete) Exec(ctx context.Context) (int, error) {
var ( return withHooks[int, UserMutation](ctx, ud.sqlExec, ud.mutation, ud.hooks)
err error
affected int
)
if len(ud.hooks) == 0 {
affected, err = ud.sqlExec(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*UserMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
ud.mutation = mutation
affected, err = ud.sqlExec(ctx)
mutation.done = true
return affected, err
})
for i := len(ud.hooks) - 1; i >= 0; i-- {
if ud.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = ud.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, ud.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
@ -88,6 +60,7 @@ func (ud *UserDelete) sqlExec(ctx context.Context) (int, error) {
if err != nil && sqlgraph.IsConstraintError(err) { if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
ud.mutation.done = true
return affected, err return affected, err
} }

View file

@ -26,6 +26,7 @@ type UserQuery struct {
unique *bool unique *bool
order []OrderFunc order []OrderFunc
fields []string fields []string
inters []Interceptor
predicates []predicate.User predicates []predicate.User
withGroup *GroupQuery withGroup *GroupQuery
withAuthTokens *AuthTokensQuery withAuthTokens *AuthTokensQuery
@ -41,13 +42,13 @@ func (uq *UserQuery) Where(ps ...predicate.User) *UserQuery {
return uq return uq
} }
// Limit adds a limit step to the query. // Limit the number of records to be returned by this query.
func (uq *UserQuery) Limit(limit int) *UserQuery { func (uq *UserQuery) Limit(limit int) *UserQuery {
uq.limit = &limit uq.limit = &limit
return uq return uq
} }
// Offset adds an offset step to the query. // Offset to start from.
func (uq *UserQuery) Offset(offset int) *UserQuery { func (uq *UserQuery) Offset(offset int) *UserQuery {
uq.offset = &offset uq.offset = &offset
return uq return uq
@ -60,7 +61,7 @@ func (uq *UserQuery) Unique(unique bool) *UserQuery {
return uq return uq
} }
// Order adds an order step to the query. // Order specifies how the records should be ordered.
func (uq *UserQuery) Order(o ...OrderFunc) *UserQuery { func (uq *UserQuery) Order(o ...OrderFunc) *UserQuery {
uq.order = append(uq.order, o...) uq.order = append(uq.order, o...)
return uq return uq
@ -68,7 +69,7 @@ func (uq *UserQuery) Order(o ...OrderFunc) *UserQuery {
// QueryGroup chains the current query on the "group" edge. // QueryGroup chains the current query on the "group" edge.
func (uq *UserQuery) QueryGroup() *GroupQuery { func (uq *UserQuery) QueryGroup() *GroupQuery {
query := &GroupQuery{config: uq.config} query := (&GroupClient{config: uq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := uq.prepareQuery(ctx); err != nil { if err := uq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -90,7 +91,7 @@ func (uq *UserQuery) QueryGroup() *GroupQuery {
// QueryAuthTokens chains the current query on the "auth_tokens" edge. // QueryAuthTokens chains the current query on the "auth_tokens" edge.
func (uq *UserQuery) QueryAuthTokens() *AuthTokensQuery { func (uq *UserQuery) QueryAuthTokens() *AuthTokensQuery {
query := &AuthTokensQuery{config: uq.config} query := (&AuthTokensClient{config: uq.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := uq.prepareQuery(ctx); err != nil { if err := uq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
@ -113,7 +114,7 @@ func (uq *UserQuery) QueryAuthTokens() *AuthTokensQuery {
// First returns the first User entity from the query. // First returns the first User entity from the query.
// Returns a *NotFoundError when no User was found. // Returns a *NotFoundError when no User was found.
func (uq *UserQuery) First(ctx context.Context) (*User, error) { func (uq *UserQuery) First(ctx context.Context) (*User, error) {
nodes, err := uq.Limit(1).All(ctx) nodes, err := uq.Limit(1).All(newQueryContext(ctx, TypeUser, "First"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -136,7 +137,7 @@ func (uq *UserQuery) FirstX(ctx context.Context) *User {
// Returns a *NotFoundError when no User ID was found. // Returns a *NotFoundError when no User ID was found.
func (uq *UserQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { func (uq *UserQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = uq.Limit(1).IDs(ctx); err != nil { if ids, err = uq.Limit(1).IDs(newQueryContext(ctx, TypeUser, "FirstID")); err != nil {
return return
} }
if len(ids) == 0 { if len(ids) == 0 {
@ -159,7 +160,7 @@ func (uq *UserQuery) FirstIDX(ctx context.Context) uuid.UUID {
// Returns a *NotSingularError when more than one User entity is found. // Returns a *NotSingularError when more than one User entity is found.
// Returns a *NotFoundError when no User entities are found. // Returns a *NotFoundError when no User entities are found.
func (uq *UserQuery) Only(ctx context.Context) (*User, error) { func (uq *UserQuery) Only(ctx context.Context) (*User, error) {
nodes, err := uq.Limit(2).All(ctx) nodes, err := uq.Limit(2).All(newQueryContext(ctx, TypeUser, "Only"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -187,7 +188,7 @@ func (uq *UserQuery) OnlyX(ctx context.Context) *User {
// Returns a *NotFoundError when no entities are found. // Returns a *NotFoundError when no entities are found.
func (uq *UserQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { func (uq *UserQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID var ids []uuid.UUID
if ids, err = uq.Limit(2).IDs(ctx); err != nil { if ids, err = uq.Limit(2).IDs(newQueryContext(ctx, TypeUser, "OnlyID")); err != nil {
return return
} }
switch len(ids) { switch len(ids) {
@ -212,10 +213,12 @@ func (uq *UserQuery) OnlyIDX(ctx context.Context) uuid.UUID {
// All executes the query and returns a list of Users. // All executes the query and returns a list of Users.
func (uq *UserQuery) All(ctx context.Context) ([]*User, error) { func (uq *UserQuery) All(ctx context.Context) ([]*User, error) {
ctx = newQueryContext(ctx, TypeUser, "All")
if err := uq.prepareQuery(ctx); err != nil { if err := uq.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
return uq.sqlAll(ctx) qr := querierAll[[]*User, *UserQuery]()
return withInterceptors[[]*User](ctx, uq, qr, uq.inters)
} }
// AllX is like All, but panics if an error occurs. // AllX is like All, but panics if an error occurs.
@ -230,6 +233,7 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User {
// IDs executes the query and returns a list of User IDs. // IDs executes the query and returns a list of User IDs.
func (uq *UserQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (uq *UserQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID var ids []uuid.UUID
ctx = newQueryContext(ctx, TypeUser, "IDs")
if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
@ -247,10 +251,11 @@ func (uq *UserQuery) IDsX(ctx context.Context) []uuid.UUID {
// Count returns the count of the given query. // Count returns the count of the given query.
func (uq *UserQuery) Count(ctx context.Context) (int, error) { func (uq *UserQuery) Count(ctx context.Context) (int, error) {
ctx = newQueryContext(ctx, TypeUser, "Count")
if err := uq.prepareQuery(ctx); err != nil { if err := uq.prepareQuery(ctx); err != nil {
return 0, err return 0, err
} }
return uq.sqlCount(ctx) return withInterceptors[int](ctx, uq, querierCount[*UserQuery](), uq.inters)
} }
// CountX is like Count, but panics if an error occurs. // CountX is like Count, but panics if an error occurs.
@ -264,10 +269,15 @@ func (uq *UserQuery) CountX(ctx context.Context) int {
// Exist returns true if the query has elements in the graph. // Exist returns true if the query has elements in the graph.
func (uq *UserQuery) Exist(ctx context.Context) (bool, error) { func (uq *UserQuery) Exist(ctx context.Context) (bool, error) {
if err := uq.prepareQuery(ctx); err != nil { ctx = newQueryContext(ctx, TypeUser, "Exist")
return false, err switch _, err := uq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
} }
return uq.sqlExist(ctx)
} }
// ExistX is like Exist, but panics if an error occurs. // ExistX is like Exist, but panics if an error occurs.
@ -290,6 +300,7 @@ func (uq *UserQuery) Clone() *UserQuery {
limit: uq.limit, limit: uq.limit,
offset: uq.offset, offset: uq.offset,
order: append([]OrderFunc{}, uq.order...), order: append([]OrderFunc{}, uq.order...),
inters: append([]Interceptor{}, uq.inters...),
predicates: append([]predicate.User{}, uq.predicates...), predicates: append([]predicate.User{}, uq.predicates...),
withGroup: uq.withGroup.Clone(), withGroup: uq.withGroup.Clone(),
withAuthTokens: uq.withAuthTokens.Clone(), withAuthTokens: uq.withAuthTokens.Clone(),
@ -303,7 +314,7 @@ func (uq *UserQuery) Clone() *UserQuery {
// WithGroup tells the query-builder to eager-load the nodes that are connected to // WithGroup tells the query-builder to eager-load the nodes that are connected to
// the "group" edge. The optional arguments are used to configure the query builder of the edge. // the "group" edge. The optional arguments are used to configure the query builder of the edge.
func (uq *UserQuery) WithGroup(opts ...func(*GroupQuery)) *UserQuery { func (uq *UserQuery) WithGroup(opts ...func(*GroupQuery)) *UserQuery {
query := &GroupQuery{config: uq.config} query := (&GroupClient{config: uq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -314,7 +325,7 @@ func (uq *UserQuery) WithGroup(opts ...func(*GroupQuery)) *UserQuery {
// WithAuthTokens tells the query-builder to eager-load the nodes that are connected to // WithAuthTokens tells the query-builder to eager-load the nodes that are connected to
// the "auth_tokens" edge. The optional arguments are used to configure the query builder of the edge. // the "auth_tokens" edge. The optional arguments are used to configure the query builder of the edge.
func (uq *UserQuery) WithAuthTokens(opts ...func(*AuthTokensQuery)) *UserQuery { func (uq *UserQuery) WithAuthTokens(opts ...func(*AuthTokensQuery)) *UserQuery {
query := &AuthTokensQuery{config: uq.config} query := (&AuthTokensClient{config: uq.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
@ -337,16 +348,11 @@ func (uq *UserQuery) WithAuthTokens(opts ...func(*AuthTokensQuery)) *UserQuery {
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy { func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy {
grbuild := &UserGroupBy{config: uq.config} uq.fields = append([]string{field}, fields...)
grbuild.fields = append([]string{field}, fields...) grbuild := &UserGroupBy{build: uq}
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { grbuild.flds = &uq.fields
if err := uq.prepareQuery(ctx); err != nil {
return nil, err
}
return uq.sqlQuery(ctx), nil
}
grbuild.label = user.Label grbuild.label = user.Label
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan grbuild.scan = grbuild.Scan
return grbuild return grbuild
} }
@ -364,10 +370,10 @@ func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy {
// Scan(ctx, &v) // Scan(ctx, &v)
func (uq *UserQuery) Select(fields ...string) *UserSelect { func (uq *UserQuery) Select(fields ...string) *UserSelect {
uq.fields = append(uq.fields, fields...) uq.fields = append(uq.fields, fields...)
selbuild := &UserSelect{UserQuery: uq} sbuild := &UserSelect{UserQuery: uq}
selbuild.label = user.Label sbuild.label = user.Label
selbuild.flds, selbuild.scan = &uq.fields, selbuild.Scan sbuild.flds, sbuild.scan = &uq.fields, sbuild.Scan
return selbuild return sbuild
} }
// Aggregate returns a UserSelect configured with the given aggregations. // Aggregate returns a UserSelect configured with the given aggregations.
@ -376,6 +382,16 @@ func (uq *UserQuery) Aggregate(fns ...AggregateFunc) *UserSelect {
} }
func (uq *UserQuery) prepareQuery(ctx context.Context) error { func (uq *UserQuery) prepareQuery(ctx context.Context) error {
for _, inter := range uq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, uq); err != nil {
return err
}
}
}
for _, f := range uq.fields { for _, f := range uq.fields {
if !user.ValidColumn(f) { if !user.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
@ -511,17 +527,6 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) {
return sqlgraph.CountNodes(ctx, uq.driver, _spec) return sqlgraph.CountNodes(ctx, uq.driver, _spec)
} }
func (uq *UserQuery) sqlExist(ctx context.Context) (bool, error) {
switch _, err := uq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
@ -604,13 +609,8 @@ func (uq *UserQuery) sqlQuery(ctx context.Context) *sql.Selector {
// UserGroupBy is the group-by builder for User entities. // UserGroupBy is the group-by builder for User entities.
type UserGroupBy struct { type UserGroupBy struct {
config
selector selector
fields []string build *UserQuery
fns []AggregateFunc
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
} }
// Aggregate adds the given aggregation functions to the group-by query. // Aggregate adds the given aggregation functions to the group-by query.
@ -619,58 +619,46 @@ func (ugb *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy {
return ugb return ugb
} }
// Scan applies the group-by query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (ugb *UserGroupBy) Scan(ctx context.Context, v any) error { func (ugb *UserGroupBy) Scan(ctx context.Context, v any) error {
query, err := ugb.path(ctx) ctx = newQueryContext(ctx, TypeUser, "GroupBy")
if err != nil { if err := ugb.build.prepareQuery(ctx); err != nil {
return err return err
} }
ugb.sql = query return scanWithInterceptors[*UserQuery, *UserGroupBy](ctx, ugb.build, ugb, ugb.build.inters, v)
return ugb.sqlScan(ctx, v)
} }
func (ugb *UserGroupBy) sqlScan(ctx context.Context, v any) error { func (ugb *UserGroupBy) sqlScan(ctx context.Context, root *UserQuery, v any) error {
for _, f := range ugb.fields { selector := root.sqlQuery(ctx).Select()
if !user.ValidColumn(f) { aggregation := make([]string, 0, len(ugb.fns))
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} for _, fn := range ugb.fns {
} aggregation = append(aggregation, fn(selector))
} }
selector := ugb.sqlQuery() if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*ugb.flds)+len(ugb.fns))
for _, f := range *ugb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*ugb.flds...)...)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return err return err
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() query, args := selector.Query()
if err := ugb.driver.Query(ctx, query, args, rows); err != nil { if err := ugb.build.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }
defer rows.Close() defer rows.Close()
return sql.ScanSlice(rows, v) return sql.ScanSlice(rows, v)
} }
func (ugb *UserGroupBy) sqlQuery() *sql.Selector {
selector := ugb.sql.Select()
aggregation := make([]string, 0, len(ugb.fns))
for _, fn := range ugb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(ugb.fields)+len(ugb.fns))
for _, f := range ugb.fields {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
return selector.GroupBy(selector.Columns(ugb.fields...)...)
}
// UserSelect is the builder for selecting fields of User entities. // UserSelect is the builder for selecting fields of User entities.
type UserSelect struct { type UserSelect struct {
*UserQuery *UserQuery
selector selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
@ -681,26 +669,27 @@ func (us *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect {
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (us *UserSelect) Scan(ctx context.Context, v any) error { func (us *UserSelect) Scan(ctx context.Context, v any) error {
ctx = newQueryContext(ctx, TypeUser, "Select")
if err := us.prepareQuery(ctx); err != nil { if err := us.prepareQuery(ctx); err != nil {
return err return err
} }
us.sql = us.UserQuery.sqlQuery(ctx) return scanWithInterceptors[*UserQuery, *UserSelect](ctx, us.UserQuery, us, us.inters, v)
return us.sqlScan(ctx, v)
} }
func (us *UserSelect) sqlScan(ctx context.Context, v any) error { func (us *UserSelect) sqlScan(ctx context.Context, root *UserQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(us.fns)) aggregation := make([]string, 0, len(us.fns))
for _, fn := range us.fns { for _, fn := range us.fns {
aggregation = append(aggregation, fn(us.sql)) aggregation = append(aggregation, fn(selector))
} }
switch n := len(*us.selector.flds); { switch n := len(*us.selector.flds); {
case n == 0 && len(aggregation) > 0: case n == 0 && len(aggregation) > 0:
us.sql.Select(aggregation...) selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0: case n != 0 && len(aggregation) > 0:
us.sql.AppendSelect(aggregation...) selector.AppendSelect(aggregation...)
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := us.sql.Query() query, args := selector.Query()
if err := us.driver.Query(ctx, query, args, rows); err != nil { if err := us.driver.Query(ctx, query, args, rows); err != nil {
return err return err
} }

View file

@ -177,41 +177,8 @@ func (uu *UserUpdate) RemoveAuthTokens(a ...*AuthTokens) *UserUpdate {
// Save executes the query and returns the number of nodes affected by the update operation. // Save executes the query and returns the number of nodes affected by the update operation.
func (uu *UserUpdate) Save(ctx context.Context) (int, error) { func (uu *UserUpdate) Save(ctx context.Context) (int, error) {
var (
err error
affected int
)
uu.defaults() uu.defaults()
if len(uu.hooks) == 0 { return withHooks[int, UserMutation](ctx, uu.sqlSave, uu.mutation, uu.hooks)
if err = uu.check(); err != nil {
return 0, err
}
affected, err = uu.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*UserMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = uu.check(); err != nil {
return 0, err
}
uu.mutation = mutation
affected, err = uu.sqlSave(ctx)
mutation.done = true
return affected, err
})
for i := len(uu.hooks) - 1; i >= 0; i-- {
if uu.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = uu.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, uu.mutation); err != nil {
return 0, err
}
}
return affected, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -273,6 +240,9 @@ func (uu *UserUpdate) check() error {
} }
func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := uu.check(); err != nil {
return n, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: user.Table, Table: user.Table,
@ -414,6 +384,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) {
} }
return 0, err return 0, err
} }
uu.mutation.done = true
return n, nil return n, nil
} }
@ -578,47 +549,8 @@ func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne
// Save executes the query and returns the updated User entity. // Save executes the query and returns the updated User entity.
func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) {
var (
err error
node *User
)
uuo.defaults() uuo.defaults()
if len(uuo.hooks) == 0 { return withHooks[*User, UserMutation](ctx, uuo.sqlSave, uuo.mutation, uuo.hooks)
if err = uuo.check(); err != nil {
return nil, err
}
node, err = uuo.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*UserMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err = uuo.check(); err != nil {
return nil, err
}
uuo.mutation = mutation
node, err = uuo.sqlSave(ctx)
mutation.done = true
return node, err
})
for i := len(uuo.hooks) - 1; i >= 0; i-- {
if uuo.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = uuo.hooks[i](mut)
}
v, err := mut.Mutate(ctx, uuo.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*User)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from UserMutation", v)
}
node = nv
}
return node, err
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
@ -680,6 +612,9 @@ func (uuo *UserUpdateOne) check() error {
} }
func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) {
if err := uuo.check(); err != nil {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{ _spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{ Node: &sqlgraph.NodeSpec{
Table: user.Table, Table: user.Table,
@ -841,5 +776,6 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error)
} }
return nil, err return nil, err
} }
uuo.mutation.done = true
return _node, nil return _node, nil
} }