diff --git a/backend/internal/data/ent/attachment/where.go b/backend/internal/data/ent/attachment/where.go index b911718..f6950f3 100644 --- a/backend/internal/data/ent/attachment/where.go +++ b/backend/internal/data/ent/attachment/where.go @@ -229,32 +229,15 @@ func HasDocumentWith(preds ...predicate.Document) predicate.Attachment { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Attachment) predicate.Attachment { - return predicate.Attachment(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Attachment(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Attachment) predicate.Attachment { - return predicate.Attachment(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Attachment(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Attachment) predicate.Attachment { - return predicate.Attachment(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Attachment(sql.NotPredicates(p)) } diff --git a/backend/internal/data/ent/attachment_create.go b/backend/internal/data/ent/attachment_create.go index fd89284..d1a0b5b 100644 --- a/backend/internal/data/ent/attachment_create.go +++ b/backend/internal/data/ent/attachment_create.go @@ -288,11 +288,15 @@ func (ac *AttachmentCreate) createSpec() (*Attachment, *sqlgraph.CreateSpec) { // AttachmentCreateBulk is the builder for creating many Attachment entities in bulk. type AttachmentCreateBulk struct { config + err error builders []*AttachmentCreate } // Save creates the Attachment entities in the database. func (acb *AttachmentCreateBulk) Save(ctx context.Context) ([]*Attachment, error) { + if acb.err != nil { + return nil, acb.err + } specs := make([]*sqlgraph.CreateSpec, len(acb.builders)) nodes := make([]*Attachment, len(acb.builders)) mutators := make([]Mutator, len(acb.builders)) diff --git a/backend/internal/data/ent/authroles/where.go b/backend/internal/data/ent/authroles/where.go index 218aa54..bb5b54a 100644 --- a/backend/internal/data/ent/authroles/where.go +++ b/backend/internal/data/ent/authroles/where.go @@ -98,32 +98,15 @@ func HasTokenWith(preds ...predicate.AuthTokens) predicate.AuthRoles { // And groups predicates with the AND operator between them. func And(predicates ...predicate.AuthRoles) predicate.AuthRoles { - return predicate.AuthRoles(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.AuthRoles(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.AuthRoles) predicate.AuthRoles { - return predicate.AuthRoles(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.AuthRoles(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.AuthRoles) predicate.AuthRoles { - return predicate.AuthRoles(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.AuthRoles(sql.NotPredicates(p)) } diff --git a/backend/internal/data/ent/authroles_create.go b/backend/internal/data/ent/authroles_create.go index 614e4fd..19e594f 100644 --- a/backend/internal/data/ent/authroles_create.go +++ b/backend/internal/data/ent/authroles_create.go @@ -158,11 +158,15 @@ func (arc *AuthRolesCreate) createSpec() (*AuthRoles, *sqlgraph.CreateSpec) { // AuthRolesCreateBulk is the builder for creating many AuthRoles entities in bulk. type AuthRolesCreateBulk struct { config + err error builders []*AuthRolesCreate } // Save creates the AuthRoles entities in the database. func (arcb *AuthRolesCreateBulk) Save(ctx context.Context) ([]*AuthRoles, error) { + if arcb.err != nil { + return nil, arcb.err + } specs := make([]*sqlgraph.CreateSpec, len(arcb.builders)) nodes := make([]*AuthRoles, len(arcb.builders)) mutators := make([]Mutator, len(arcb.builders)) diff --git a/backend/internal/data/ent/authtokens/where.go b/backend/internal/data/ent/authtokens/where.go index 6c6f960..d3642d8 100644 --- a/backend/internal/data/ent/authtokens/where.go +++ b/backend/internal/data/ent/authtokens/where.go @@ -284,32 +284,15 @@ func HasRolesWith(preds ...predicate.AuthRoles) predicate.AuthTokens { // And groups predicates with the AND operator between them. func And(predicates ...predicate.AuthTokens) predicate.AuthTokens { - return predicate.AuthTokens(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.AuthTokens(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.AuthTokens) predicate.AuthTokens { - return predicate.AuthTokens(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.AuthTokens(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.AuthTokens) predicate.AuthTokens { - return predicate.AuthTokens(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.AuthTokens(sql.NotPredicates(p)) } diff --git a/backend/internal/data/ent/authtokens_create.go b/backend/internal/data/ent/authtokens_create.go index 78b4909..afddb3b 100644 --- a/backend/internal/data/ent/authtokens_create.go +++ b/backend/internal/data/ent/authtokens_create.go @@ -280,11 +280,15 @@ func (atc *AuthTokensCreate) createSpec() (*AuthTokens, *sqlgraph.CreateSpec) { // AuthTokensCreateBulk is the builder for creating many AuthTokens entities in bulk. type AuthTokensCreateBulk struct { config + err error builders []*AuthTokensCreate } // Save creates the AuthTokens entities in the database. func (atcb *AuthTokensCreateBulk) Save(ctx context.Context) ([]*AuthTokens, error) { + if atcb.err != nil { + return nil, atcb.err + } specs := make([]*sqlgraph.CreateSpec, len(atcb.builders)) nodes := make([]*AuthTokens, len(atcb.builders)) mutators := make([]Mutator, len(atcb.builders)) diff --git a/backend/internal/data/ent/client.go b/backend/internal/data/ent/client.go index 6b4fbe3..2fb9b53 100644 --- a/backend/internal/data/ent/client.go +++ b/backend/internal/data/ent/client.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "log" + "reflect" "github.com/google/uuid" "github.com/hay-kot/homebox/backend/internal/data/ent/migrate" @@ -65,9 +66,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -107,6 +106,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { @@ -154,11 +160,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error) } } +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("ent: cannot start a transaction within a transaction") + return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { @@ -330,6 +339,21 @@ func (c *AttachmentClient) CreateBulk(builders ...*AttachmentCreate) *Attachment return &AttachmentCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *AttachmentClient) MapCreateBulk(slice any, setFunc func(*AttachmentCreate, int)) *AttachmentCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &AttachmentCreateBulk{err: fmt.Errorf("calling to AttachmentClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*AttachmentCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &AttachmentCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Attachment. func (c *AttachmentClient) Update() *AttachmentUpdate { mutation := newAttachmentMutation(c.config, OpUpdate) @@ -480,6 +504,21 @@ func (c *AuthRolesClient) CreateBulk(builders ...*AuthRolesCreate) *AuthRolesCre return &AuthRolesCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *AuthRolesClient) MapCreateBulk(slice any, setFunc func(*AuthRolesCreate, int)) *AuthRolesCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &AuthRolesCreateBulk{err: fmt.Errorf("calling to AuthRolesClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*AuthRolesCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &AuthRolesCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for AuthRoles. func (c *AuthRolesClient) Update() *AuthRolesUpdate { mutation := newAuthRolesMutation(c.config, OpUpdate) @@ -614,6 +653,21 @@ func (c *AuthTokensClient) CreateBulk(builders ...*AuthTokensCreate) *AuthTokens return &AuthTokensCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *AuthTokensClient) MapCreateBulk(slice any, setFunc func(*AuthTokensCreate, int)) *AuthTokensCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &AuthTokensCreateBulk{err: fmt.Errorf("calling to AuthTokensClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*AuthTokensCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &AuthTokensCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for AuthTokens. func (c *AuthTokensClient) Update() *AuthTokensUpdate { mutation := newAuthTokensMutation(c.config, OpUpdate) @@ -764,6 +818,21 @@ func (c *DocumentClient) CreateBulk(builders ...*DocumentCreate) *DocumentCreate return &DocumentCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *DocumentClient) MapCreateBulk(slice any, setFunc func(*DocumentCreate, int)) *DocumentCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &DocumentCreateBulk{err: fmt.Errorf("calling to DocumentClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*DocumentCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &DocumentCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Document. func (c *DocumentClient) Update() *DocumentUpdate { mutation := newDocumentMutation(c.config, OpUpdate) @@ -914,6 +983,21 @@ func (c *GroupClient) CreateBulk(builders ...*GroupCreate) *GroupCreateBulk { return &GroupCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *GroupClient) MapCreateBulk(slice any, setFunc func(*GroupCreate, int)) *GroupCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &GroupCreateBulk{err: fmt.Errorf("calling to GroupClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*GroupCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &GroupCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Group. func (c *GroupClient) Update() *GroupUpdate { mutation := newGroupMutation(c.config, OpUpdate) @@ -1144,6 +1228,21 @@ func (c *GroupInvitationTokenClient) CreateBulk(builders ...*GroupInvitationToke return &GroupInvitationTokenCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *GroupInvitationTokenClient) MapCreateBulk(slice any, setFunc func(*GroupInvitationTokenCreate, int)) *GroupInvitationTokenCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &GroupInvitationTokenCreateBulk{err: fmt.Errorf("calling to GroupInvitationTokenClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*GroupInvitationTokenCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &GroupInvitationTokenCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for GroupInvitationToken. func (c *GroupInvitationTokenClient) Update() *GroupInvitationTokenUpdate { mutation := newGroupInvitationTokenMutation(c.config, OpUpdate) @@ -1278,6 +1377,21 @@ func (c *ItemClient) CreateBulk(builders ...*ItemCreate) *ItemCreateBulk { return &ItemCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ItemClient) MapCreateBulk(slice any, setFunc func(*ItemCreate, int)) *ItemCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ItemCreateBulk{err: fmt.Errorf("calling to ItemClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ItemCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ItemCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Item. func (c *ItemClient) Update() *ItemUpdate { mutation := newItemMutation(c.config, OpUpdate) @@ -1524,6 +1638,21 @@ func (c *ItemFieldClient) CreateBulk(builders ...*ItemFieldCreate) *ItemFieldCre return &ItemFieldCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ItemFieldClient) MapCreateBulk(slice any, setFunc func(*ItemFieldCreate, int)) *ItemFieldCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ItemFieldCreateBulk{err: fmt.Errorf("calling to ItemFieldClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ItemFieldCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ItemFieldCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for ItemField. func (c *ItemFieldClient) Update() *ItemFieldUpdate { mutation := newItemFieldMutation(c.config, OpUpdate) @@ -1658,6 +1787,21 @@ func (c *LabelClient) CreateBulk(builders ...*LabelCreate) *LabelCreateBulk { return &LabelCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *LabelClient) MapCreateBulk(slice any, setFunc func(*LabelCreate, int)) *LabelCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &LabelCreateBulk{err: fmt.Errorf("calling to LabelClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*LabelCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &LabelCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Label. func (c *LabelClient) Update() *LabelUpdate { mutation := newLabelMutation(c.config, OpUpdate) @@ -1808,6 +1952,21 @@ func (c *LocationClient) CreateBulk(builders ...*LocationCreate) *LocationCreate return &LocationCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *LocationClient) MapCreateBulk(slice any, setFunc func(*LocationCreate, int)) *LocationCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &LocationCreateBulk{err: fmt.Errorf("calling to LocationClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*LocationCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &LocationCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Location. func (c *LocationClient) Update() *LocationUpdate { mutation := newLocationMutation(c.config, OpUpdate) @@ -1990,6 +2149,21 @@ func (c *MaintenanceEntryClient) CreateBulk(builders ...*MaintenanceEntryCreate) return &MaintenanceEntryCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *MaintenanceEntryClient) MapCreateBulk(slice any, setFunc func(*MaintenanceEntryCreate, int)) *MaintenanceEntryCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &MaintenanceEntryCreateBulk{err: fmt.Errorf("calling to MaintenanceEntryClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*MaintenanceEntryCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &MaintenanceEntryCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for MaintenanceEntry. func (c *MaintenanceEntryClient) Update() *MaintenanceEntryUpdate { mutation := newMaintenanceEntryMutation(c.config, OpUpdate) @@ -2124,6 +2298,21 @@ func (c *NotifierClient) CreateBulk(builders ...*NotifierCreate) *NotifierCreate return &NotifierCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *NotifierClient) MapCreateBulk(slice any, setFunc func(*NotifierCreate, int)) *NotifierCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &NotifierCreateBulk{err: fmt.Errorf("calling to NotifierClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*NotifierCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &NotifierCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Notifier. func (c *NotifierClient) Update() *NotifierUpdate { mutation := newNotifierMutation(c.config, OpUpdate) @@ -2274,6 +2463,21 @@ func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { return &UserCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for User. func (c *UserClient) Update() *UserUpdate { mutation := newUserMutation(c.config, OpUpdate) diff --git a/backend/internal/data/ent/document/where.go b/backend/internal/data/ent/document/where.go index 315e2d8..3e491ad 100644 --- a/backend/internal/data/ent/document/where.go +++ b/backend/internal/data/ent/document/where.go @@ -334,32 +334,15 @@ func HasAttachmentsWith(preds ...predicate.Attachment) predicate.Document { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Document) predicate.Document { - return predicate.Document(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Document(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Document) predicate.Document { - return predicate.Document(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Document(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Document) predicate.Document { - return predicate.Document(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Document(sql.NotPredicates(p)) } diff --git a/backend/internal/data/ent/document_create.go b/backend/internal/data/ent/document_create.go index f304560..fe61e98 100644 --- a/backend/internal/data/ent/document_create.go +++ b/backend/internal/data/ent/document_create.go @@ -269,11 +269,15 @@ func (dc *DocumentCreate) createSpec() (*Document, *sqlgraph.CreateSpec) { // DocumentCreateBulk is the builder for creating many Document entities in bulk. type DocumentCreateBulk struct { config + err error builders []*DocumentCreate } // Save creates the Document entities in the database. func (dcb *DocumentCreateBulk) Save(ctx context.Context) ([]*Document, error) { + if dcb.err != nil { + return nil, dcb.err + } specs := make([]*sqlgraph.CreateSpec, len(dcb.builders)) nodes := make([]*Document, len(dcb.builders)) mutators := make([]Mutator, len(dcb.builders)) diff --git a/backend/internal/data/ent/document_update.go b/backend/internal/data/ent/document_update.go index 96a2f04..23e6d9c 100644 --- a/backend/internal/data/ent/document_update.go +++ b/backend/internal/data/ent/document_update.go @@ -43,12 +43,28 @@ func (du *DocumentUpdate) SetTitle(s string) *DocumentUpdate { return du } +// SetNillableTitle sets the "title" field if the given value is not nil. +func (du *DocumentUpdate) SetNillableTitle(s *string) *DocumentUpdate { + if s != nil { + du.SetTitle(*s) + } + return du +} + // SetPath sets the "path" field. func (du *DocumentUpdate) SetPath(s string) *DocumentUpdate { du.mutation.SetPath(s) return du } +// SetNillablePath sets the "path" field if the given value is not nil. +func (du *DocumentUpdate) SetNillablePath(s *string) *DocumentUpdate { + if s != nil { + du.SetPath(*s) + } + return du +} + // SetGroupID sets the "group" edge to the Group entity by ID. func (du *DocumentUpdate) SetGroupID(id uuid.UUID) *DocumentUpdate { du.mutation.SetGroupID(id) @@ -288,12 +304,28 @@ func (duo *DocumentUpdateOne) SetTitle(s string) *DocumentUpdateOne { return duo } +// SetNillableTitle sets the "title" field if the given value is not nil. +func (duo *DocumentUpdateOne) SetNillableTitle(s *string) *DocumentUpdateOne { + if s != nil { + duo.SetTitle(*s) + } + return duo +} + // SetPath sets the "path" field. func (duo *DocumentUpdateOne) SetPath(s string) *DocumentUpdateOne { duo.mutation.SetPath(s) return duo } +// SetNillablePath sets the "path" field if the given value is not nil. +func (duo *DocumentUpdateOne) SetNillablePath(s *string) *DocumentUpdateOne { + if s != nil { + duo.SetPath(*s) + } + return duo +} + // SetGroupID sets the "group" edge to the Group entity by ID. func (duo *DocumentUpdateOne) SetGroupID(id uuid.UUID) *DocumentUpdateOne { duo.mutation.SetGroupID(id) diff --git a/backend/internal/data/ent/group/where.go b/backend/internal/data/ent/group/where.go index f4a10b6..5f1bc06 100644 --- a/backend/internal/data/ent/group/where.go +++ b/backend/internal/data/ent/group/where.go @@ -399,32 +399,15 @@ func HasNotifiersWith(preds ...predicate.Notifier) predicate.Group { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Group) predicate.Group { - return predicate.Group(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Group(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Group) predicate.Group { - return predicate.Group(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Group(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Group) predicate.Group { - return predicate.Group(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Group(sql.NotPredicates(p)) } diff --git a/backend/internal/data/ent/group_create.go b/backend/internal/data/ent/group_create.go index 047d41d..8ccd05b 100644 --- a/backend/internal/data/ent/group_create.go +++ b/backend/internal/data/ent/group_create.go @@ -441,11 +441,15 @@ func (gc *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) { // GroupCreateBulk is the builder for creating many Group entities in bulk. type GroupCreateBulk struct { config + err error builders []*GroupCreate } // Save creates the Group entities in the database. func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) { + if gcb.err != nil { + return nil, gcb.err + } specs := make([]*sqlgraph.CreateSpec, len(gcb.builders)) nodes := make([]*Group, len(gcb.builders)) mutators := make([]Mutator, len(gcb.builders)) diff --git a/backend/internal/data/ent/group_update.go b/backend/internal/data/ent/group_update.go index 68864b6..872ee08 100644 --- a/backend/internal/data/ent/group_update.go +++ b/backend/internal/data/ent/group_update.go @@ -48,6 +48,14 @@ func (gu *GroupUpdate) SetName(s string) *GroupUpdate { return gu } +// SetNillableName sets the "name" field if the given value is not nil. +func (gu *GroupUpdate) SetNillableName(s *string) *GroupUpdate { + if s != nil { + gu.SetName(*s) + } + return gu +} + // SetCurrency sets the "currency" field. func (gu *GroupUpdate) SetCurrency(gr group.Currency) *GroupUpdate { gu.mutation.SetCurrency(gr) @@ -738,6 +746,14 @@ func (guo *GroupUpdateOne) SetName(s string) *GroupUpdateOne { return guo } +// SetNillableName sets the "name" field if the given value is not nil. +func (guo *GroupUpdateOne) SetNillableName(s *string) *GroupUpdateOne { + if s != nil { + guo.SetName(*s) + } + return guo +} + // SetCurrency sets the "currency" field. func (guo *GroupUpdateOne) SetCurrency(gr group.Currency) *GroupUpdateOne { guo.mutation.SetCurrency(gr) diff --git a/backend/internal/data/ent/groupinvitationtoken/where.go b/backend/internal/data/ent/groupinvitationtoken/where.go index 046392a..d462df0 100644 --- a/backend/internal/data/ent/groupinvitationtoken/where.go +++ b/backend/internal/data/ent/groupinvitationtoken/where.go @@ -306,32 +306,15 @@ func HasGroupWith(preds ...predicate.Group) predicate.GroupInvitationToken { // And groups predicates with the AND operator between them. func And(predicates ...predicate.GroupInvitationToken) predicate.GroupInvitationToken { - return predicate.GroupInvitationToken(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.GroupInvitationToken(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.GroupInvitationToken) predicate.GroupInvitationToken { - return predicate.GroupInvitationToken(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.GroupInvitationToken(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.GroupInvitationToken) predicate.GroupInvitationToken { - return predicate.GroupInvitationToken(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.GroupInvitationToken(sql.NotPredicates(p)) } diff --git a/backend/internal/data/ent/groupinvitationtoken_create.go b/backend/internal/data/ent/groupinvitationtoken_create.go index 03a8dd5..1d5859f 100644 --- a/backend/internal/data/ent/groupinvitationtoken_create.go +++ b/backend/internal/data/ent/groupinvitationtoken_create.go @@ -269,11 +269,15 @@ func (gitc *GroupInvitationTokenCreate) createSpec() (*GroupInvitationToken, *sq // GroupInvitationTokenCreateBulk is the builder for creating many GroupInvitationToken entities in bulk. type GroupInvitationTokenCreateBulk struct { config + err error builders []*GroupInvitationTokenCreate } // Save creates the GroupInvitationToken entities in the database. func (gitcb *GroupInvitationTokenCreateBulk) Save(ctx context.Context) ([]*GroupInvitationToken, error) { + if gitcb.err != nil { + return nil, gitcb.err + } specs := make([]*sqlgraph.CreateSpec, len(gitcb.builders)) nodes := make([]*GroupInvitationToken, len(gitcb.builders)) mutators := make([]Mutator, len(gitcb.builders)) diff --git a/backend/internal/data/ent/item/where.go b/backend/internal/data/ent/item/where.go index df83cb7..7504e6a 100644 --- a/backend/internal/data/ent/item/where.go +++ b/backend/internal/data/ent/item/where.go @@ -1592,32 +1592,15 @@ func HasAttachmentsWith(preds ...predicate.Attachment) predicate.Item { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Item) predicate.Item { - return predicate.Item(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Item(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Item) predicate.Item { - return predicate.Item(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Item(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Item) predicate.Item { - return predicate.Item(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Item(sql.NotPredicates(p)) } diff --git a/backend/internal/data/ent/item_create.go b/backend/internal/data/ent/item_create.go index 203f8df..9eb1cb6 100644 --- a/backend/internal/data/ent/item_create.go +++ b/backend/internal/data/ent/item_create.go @@ -900,11 +900,15 @@ func (ic *ItemCreate) createSpec() (*Item, *sqlgraph.CreateSpec) { // ItemCreateBulk is the builder for creating many Item entities in bulk. type ItemCreateBulk struct { config + err error builders []*ItemCreate } // Save creates the Item entities in the database. func (icb *ItemCreateBulk) Save(ctx context.Context) ([]*Item, error) { + if icb.err != nil { + return nil, icb.err + } specs := make([]*sqlgraph.CreateSpec, len(icb.builders)) nodes := make([]*Item, len(icb.builders)) mutators := make([]Mutator, len(icb.builders)) diff --git a/backend/internal/data/ent/item_update.go b/backend/internal/data/ent/item_update.go index cfe27a8..8cd4722 100644 --- a/backend/internal/data/ent/item_update.go +++ b/backend/internal/data/ent/item_update.go @@ -47,6 +47,14 @@ func (iu *ItemUpdate) SetName(s string) *ItemUpdate { return iu } +// SetNillableName sets the "name" field if the given value is not nil. +func (iu *ItemUpdate) SetNillableName(s *string) *ItemUpdate { + if s != nil { + iu.SetName(*s) + } + return iu +} + // SetDescription sets the "description" field. func (iu *ItemUpdate) SetDescription(s string) *ItemUpdate { iu.mutation.SetDescription(s) @@ -1247,6 +1255,14 @@ func (iuo *ItemUpdateOne) SetName(s string) *ItemUpdateOne { return iuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (iuo *ItemUpdateOne) SetNillableName(s *string) *ItemUpdateOne { + if s != nil { + iuo.SetName(*s) + } + return iuo +} + // SetDescription sets the "description" field. func (iuo *ItemUpdateOne) SetDescription(s string) *ItemUpdateOne { iuo.mutation.SetDescription(s) diff --git a/backend/internal/data/ent/itemfield/where.go b/backend/internal/data/ent/itemfield/where.go index 6c786bb..8a2d4aa 100644 --- a/backend/internal/data/ent/itemfield/where.go +++ b/backend/internal/data/ent/itemfield/where.go @@ -536,32 +536,15 @@ func HasItemWith(preds ...predicate.Item) predicate.ItemField { // And groups predicates with the AND operator between them. func And(predicates ...predicate.ItemField) predicate.ItemField { - return predicate.ItemField(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.ItemField(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.ItemField) predicate.ItemField { - return predicate.ItemField(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.ItemField(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.ItemField) predicate.ItemField { - return predicate.ItemField(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.ItemField(sql.NotPredicates(p)) } diff --git a/backend/internal/data/ent/itemfield_create.go b/backend/internal/data/ent/itemfield_create.go index ff40846..65a22fb 100644 --- a/backend/internal/data/ent/itemfield_create.go +++ b/backend/internal/data/ent/itemfield_create.go @@ -356,11 +356,15 @@ func (ifc *ItemFieldCreate) createSpec() (*ItemField, *sqlgraph.CreateSpec) { // ItemFieldCreateBulk is the builder for creating many ItemField entities in bulk. type ItemFieldCreateBulk struct { config + err error builders []*ItemFieldCreate } // Save creates the ItemField entities in the database. func (ifcb *ItemFieldCreateBulk) Save(ctx context.Context) ([]*ItemField, error) { + if ifcb.err != nil { + return nil, ifcb.err + } specs := make([]*sqlgraph.CreateSpec, len(ifcb.builders)) nodes := make([]*ItemField, len(ifcb.builders)) mutators := make([]Mutator, len(ifcb.builders)) diff --git a/backend/internal/data/ent/itemfield_update.go b/backend/internal/data/ent/itemfield_update.go index 4d1d818..3f44dc1 100644 --- a/backend/internal/data/ent/itemfield_update.go +++ b/backend/internal/data/ent/itemfield_update.go @@ -42,6 +42,14 @@ func (ifu *ItemFieldUpdate) SetName(s string) *ItemFieldUpdate { return ifu } +// SetNillableName sets the "name" field if the given value is not nil. +func (ifu *ItemFieldUpdate) SetNillableName(s *string) *ItemFieldUpdate { + if s != nil { + ifu.SetName(*s) + } + return ifu +} + // SetDescription sets the "description" field. func (ifu *ItemFieldUpdate) SetDescription(s string) *ItemFieldUpdate { ifu.mutation.SetDescription(s) @@ -68,6 +76,14 @@ func (ifu *ItemFieldUpdate) SetType(i itemfield.Type) *ItemFieldUpdate { return ifu } +// SetNillableType sets the "type" field if the given value is not nil. +func (ifu *ItemFieldUpdate) SetNillableType(i *itemfield.Type) *ItemFieldUpdate { + if i != nil { + ifu.SetType(*i) + } + return ifu +} + // SetTextValue sets the "text_value" field. func (ifu *ItemFieldUpdate) SetTextValue(s string) *ItemFieldUpdate { ifu.mutation.SetTextValue(s) @@ -343,6 +359,14 @@ func (ifuo *ItemFieldUpdateOne) SetName(s string) *ItemFieldUpdateOne { return ifuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (ifuo *ItemFieldUpdateOne) SetNillableName(s *string) *ItemFieldUpdateOne { + if s != nil { + ifuo.SetName(*s) + } + return ifuo +} + // SetDescription sets the "description" field. func (ifuo *ItemFieldUpdateOne) SetDescription(s string) *ItemFieldUpdateOne { ifuo.mutation.SetDescription(s) @@ -369,6 +393,14 @@ func (ifuo *ItemFieldUpdateOne) SetType(i itemfield.Type) *ItemFieldUpdateOne { return ifuo } +// SetNillableType sets the "type" field if the given value is not nil. +func (ifuo *ItemFieldUpdateOne) SetNillableType(i *itemfield.Type) *ItemFieldUpdateOne { + if i != nil { + ifuo.SetType(*i) + } + return ifuo +} + // SetTextValue sets the "text_value" field. func (ifuo *ItemFieldUpdateOne) SetTextValue(s string) *ItemFieldUpdateOne { ifuo.mutation.SetTextValue(s) diff --git a/backend/internal/data/ent/label/where.go b/backend/internal/data/ent/label/where.go index 29a0846..3754ac7 100644 --- a/backend/internal/data/ent/label/where.go +++ b/backend/internal/data/ent/label/where.go @@ -424,32 +424,15 @@ func HasItemsWith(preds ...predicate.Item) predicate.Label { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Label) predicate.Label { - return predicate.Label(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Label(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Label) predicate.Label { - return predicate.Label(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Label(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Label) predicate.Label { - return predicate.Label(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Label(sql.NotPredicates(p)) } diff --git a/backend/internal/data/ent/label_create.go b/backend/internal/data/ent/label_create.go index ca6c019..0ad6469 100644 --- a/backend/internal/data/ent/label_create.go +++ b/backend/internal/data/ent/label_create.go @@ -297,11 +297,15 @@ func (lc *LabelCreate) createSpec() (*Label, *sqlgraph.CreateSpec) { // LabelCreateBulk is the builder for creating many Label entities in bulk. type LabelCreateBulk struct { config + err error builders []*LabelCreate } // Save creates the Label entities in the database. func (lcb *LabelCreateBulk) Save(ctx context.Context) ([]*Label, error) { + if lcb.err != nil { + return nil, lcb.err + } specs := make([]*sqlgraph.CreateSpec, len(lcb.builders)) nodes := make([]*Label, len(lcb.builders)) mutators := make([]Mutator, len(lcb.builders)) diff --git a/backend/internal/data/ent/label_update.go b/backend/internal/data/ent/label_update.go index 906cb6a..0862d22 100644 --- a/backend/internal/data/ent/label_update.go +++ b/backend/internal/data/ent/label_update.go @@ -43,6 +43,14 @@ func (lu *LabelUpdate) SetName(s string) *LabelUpdate { return lu } +// SetNillableName sets the "name" field if the given value is not nil. +func (lu *LabelUpdate) SetNillableName(s *string) *LabelUpdate { + if s != nil { + lu.SetName(*s) + } + return lu +} + // SetDescription sets the "description" field. func (lu *LabelUpdate) SetDescription(s string) *LabelUpdate { lu.mutation.SetDescription(s) @@ -336,6 +344,14 @@ func (luo *LabelUpdateOne) SetName(s string) *LabelUpdateOne { return luo } +// SetNillableName sets the "name" field if the given value is not nil. +func (luo *LabelUpdateOne) SetNillableName(s *string) *LabelUpdateOne { + if s != nil { + luo.SetName(*s) + } + return luo +} + // SetDescription sets the "description" field. func (luo *LabelUpdateOne) SetDescription(s string) *LabelUpdateOne { luo.mutation.SetDescription(s) diff --git a/backend/internal/data/ent/location/where.go b/backend/internal/data/ent/location/where.go index de5e8cf..a89ef4d 100644 --- a/backend/internal/data/ent/location/where.go +++ b/backend/internal/data/ent/location/where.go @@ -390,32 +390,15 @@ func HasItemsWith(preds ...predicate.Item) predicate.Location { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Location) predicate.Location { - return predicate.Location(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Location(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Location) predicate.Location { - return predicate.Location(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Location(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Location) predicate.Location { - return predicate.Location(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Location(sql.NotPredicates(p)) } diff --git a/backend/internal/data/ent/location_create.go b/backend/internal/data/ent/location_create.go index 416ffe1..98f0f7a 100644 --- a/backend/internal/data/ent/location_create.go +++ b/backend/internal/data/ent/location_create.go @@ -341,11 +341,15 @@ func (lc *LocationCreate) createSpec() (*Location, *sqlgraph.CreateSpec) { // LocationCreateBulk is the builder for creating many Location entities in bulk. type LocationCreateBulk struct { config + err error builders []*LocationCreate } // Save creates the Location entities in the database. func (lcb *LocationCreateBulk) Save(ctx context.Context) ([]*Location, error) { + if lcb.err != nil { + return nil, lcb.err + } specs := make([]*sqlgraph.CreateSpec, len(lcb.builders)) nodes := make([]*Location, len(lcb.builders)) mutators := make([]Mutator, len(lcb.builders)) diff --git a/backend/internal/data/ent/location_update.go b/backend/internal/data/ent/location_update.go index 986dbc4..d569b21 100644 --- a/backend/internal/data/ent/location_update.go +++ b/backend/internal/data/ent/location_update.go @@ -43,6 +43,14 @@ func (lu *LocationUpdate) SetName(s string) *LocationUpdate { return lu } +// SetNillableName sets the "name" field if the given value is not nil. +func (lu *LocationUpdate) SetNillableName(s *string) *LocationUpdate { + if s != nil { + lu.SetName(*s) + } + return lu +} + // SetDescription sets the "description" field. func (lu *LocationUpdate) SetDescription(s string) *LocationUpdate { lu.mutation.SetDescription(s) @@ -440,6 +448,14 @@ func (luo *LocationUpdateOne) SetName(s string) *LocationUpdateOne { return luo } +// SetNillableName sets the "name" field if the given value is not nil. +func (luo *LocationUpdateOne) SetNillableName(s *string) *LocationUpdateOne { + if s != nil { + luo.SetName(*s) + } + return luo +} + // SetDescription sets the "description" field. func (luo *LocationUpdateOne) SetDescription(s string) *LocationUpdateOne { luo.mutation.SetDescription(s) diff --git a/backend/internal/data/ent/maintenanceentry/where.go b/backend/internal/data/ent/maintenanceentry/where.go index 6e92c77..85e736d 100644 --- a/backend/internal/data/ent/maintenanceentry/where.go +++ b/backend/internal/data/ent/maintenanceentry/where.go @@ -501,32 +501,15 @@ func HasItemWith(preds ...predicate.Item) predicate.MaintenanceEntry { // And groups predicates with the AND operator between them. func And(predicates ...predicate.MaintenanceEntry) predicate.MaintenanceEntry { - return predicate.MaintenanceEntry(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.MaintenanceEntry(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.MaintenanceEntry) predicate.MaintenanceEntry { - return predicate.MaintenanceEntry(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.MaintenanceEntry(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.MaintenanceEntry) predicate.MaintenanceEntry { - return predicate.MaintenanceEntry(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.MaintenanceEntry(sql.NotPredicates(p)) } diff --git a/backend/internal/data/ent/maintenanceentry_create.go b/backend/internal/data/ent/maintenanceentry_create.go index 0e6144b..ea71a4d 100644 --- a/backend/internal/data/ent/maintenanceentry_create.go +++ b/backend/internal/data/ent/maintenanceentry_create.go @@ -306,11 +306,15 @@ func (mec *MaintenanceEntryCreate) createSpec() (*MaintenanceEntry, *sqlgraph.Cr // MaintenanceEntryCreateBulk is the builder for creating many MaintenanceEntry entities in bulk. type MaintenanceEntryCreateBulk struct { config + err error builders []*MaintenanceEntryCreate } // Save creates the MaintenanceEntry entities in the database. func (mecb *MaintenanceEntryCreateBulk) Save(ctx context.Context) ([]*MaintenanceEntry, error) { + if mecb.err != nil { + return nil, mecb.err + } specs := make([]*sqlgraph.CreateSpec, len(mecb.builders)) nodes := make([]*MaintenanceEntry, len(mecb.builders)) mutators := make([]Mutator, len(mecb.builders)) diff --git a/backend/internal/data/ent/maintenanceentry_update.go b/backend/internal/data/ent/maintenanceentry_update.go index 18447d1..3616d32 100644 --- a/backend/internal/data/ent/maintenanceentry_update.go +++ b/backend/internal/data/ent/maintenanceentry_update.go @@ -42,6 +42,14 @@ func (meu *MaintenanceEntryUpdate) SetItemID(u uuid.UUID) *MaintenanceEntryUpdat return meu } +// SetNillableItemID sets the "item_id" field if the given value is not nil. +func (meu *MaintenanceEntryUpdate) SetNillableItemID(u *uuid.UUID) *MaintenanceEntryUpdate { + if u != nil { + meu.SetItemID(*u) + } + return meu +} + // SetDate sets the "date" field. func (meu *MaintenanceEntryUpdate) SetDate(t time.Time) *MaintenanceEntryUpdate { meu.mutation.SetDate(t) @@ -88,6 +96,14 @@ func (meu *MaintenanceEntryUpdate) SetName(s string) *MaintenanceEntryUpdate { return meu } +// SetNillableName sets the "name" field if the given value is not nil. +func (meu *MaintenanceEntryUpdate) SetNillableName(s *string) *MaintenanceEntryUpdate { + if s != nil { + meu.SetName(*s) + } + return meu +} + // SetDescription sets the "description" field. func (meu *MaintenanceEntryUpdate) SetDescription(s string) *MaintenanceEntryUpdate { meu.mutation.SetDescription(s) @@ -302,6 +318,14 @@ func (meuo *MaintenanceEntryUpdateOne) SetItemID(u uuid.UUID) *MaintenanceEntryU return meuo } +// SetNillableItemID sets the "item_id" field if the given value is not nil. +func (meuo *MaintenanceEntryUpdateOne) SetNillableItemID(u *uuid.UUID) *MaintenanceEntryUpdateOne { + if u != nil { + meuo.SetItemID(*u) + } + return meuo +} + // SetDate sets the "date" field. func (meuo *MaintenanceEntryUpdateOne) SetDate(t time.Time) *MaintenanceEntryUpdateOne { meuo.mutation.SetDate(t) @@ -348,6 +372,14 @@ func (meuo *MaintenanceEntryUpdateOne) SetName(s string) *MaintenanceEntryUpdate return meuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (meuo *MaintenanceEntryUpdateOne) SetNillableName(s *string) *MaintenanceEntryUpdateOne { + if s != nil { + meuo.SetName(*s) + } + return meuo +} + // SetDescription sets the "description" field. func (meuo *MaintenanceEntryUpdateOne) SetDescription(s string) *MaintenanceEntryUpdateOne { meuo.mutation.SetDescription(s) diff --git a/backend/internal/data/ent/mutation.go b/backend/internal/data/ent/mutation.go index 496437d..5873a3c 100644 --- a/backend/internal/data/ent/mutation.go +++ b/backend/internal/data/ent/mutation.go @@ -9529,6 +9529,7 @@ func (m *MaintenanceEntryMutation) ResetCost() { // ClearItem clears the "item" edge to the Item entity. func (m *MaintenanceEntryMutation) ClearItem() { m.cleareditem = true + m.clearedFields[maintenanceentry.FieldItemID] = struct{}{} } // ItemCleared reports if the "item" edge to the Item entity was cleared. @@ -10292,6 +10293,7 @@ func (m *NotifierMutation) ResetIsActive() { // ClearGroup clears the "group" edge to the Group entity. func (m *NotifierMutation) ClearGroup() { m.clearedgroup = true + m.clearedFields[notifier.FieldGroupID] = struct{}{} } // GroupCleared reports if the "group" edge to the Group entity was cleared. @@ -10318,6 +10320,7 @@ func (m *NotifierMutation) ResetGroup() { // ClearUser clears the "user" edge to the User entity. func (m *NotifierMutation) ClearUser() { m.cleareduser = true + m.clearedFields[notifier.FieldUserID] = struct{}{} } // UserCleared reports if the "user" edge to the User entity was cleared. diff --git a/backend/internal/data/ent/notifier/where.go b/backend/internal/data/ent/notifier/where.go index f38192d..fa9b3bc 100644 --- a/backend/internal/data/ent/notifier/where.go +++ b/backend/internal/data/ent/notifier/where.go @@ -399,32 +399,15 @@ func HasUserWith(preds ...predicate.User) predicate.Notifier { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Notifier) predicate.Notifier { - return predicate.Notifier(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Notifier(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Notifier) predicate.Notifier { - return predicate.Notifier(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Notifier(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Notifier) predicate.Notifier { - return predicate.Notifier(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Notifier(sql.NotPredicates(p)) } diff --git a/backend/internal/data/ent/notifier_create.go b/backend/internal/data/ent/notifier_create.go index 89d8b5f..42265e2 100644 --- a/backend/internal/data/ent/notifier_create.go +++ b/backend/internal/data/ent/notifier_create.go @@ -300,11 +300,15 @@ func (nc *NotifierCreate) createSpec() (*Notifier, *sqlgraph.CreateSpec) { // NotifierCreateBulk is the builder for creating many Notifier entities in bulk. type NotifierCreateBulk struct { config + err error builders []*NotifierCreate } // Save creates the Notifier entities in the database. func (ncb *NotifierCreateBulk) Save(ctx context.Context) ([]*Notifier, error) { + if ncb.err != nil { + return nil, ncb.err + } specs := make([]*sqlgraph.CreateSpec, len(ncb.builders)) nodes := make([]*Notifier, len(ncb.builders)) mutators := make([]Mutator, len(ncb.builders)) diff --git a/backend/internal/data/ent/notifier_update.go b/backend/internal/data/ent/notifier_update.go index a7712bf..ea28f32 100644 --- a/backend/internal/data/ent/notifier_update.go +++ b/backend/internal/data/ent/notifier_update.go @@ -43,24 +43,56 @@ func (nu *NotifierUpdate) SetGroupID(u uuid.UUID) *NotifierUpdate { return nu } +// SetNillableGroupID sets the "group_id" field if the given value is not nil. +func (nu *NotifierUpdate) SetNillableGroupID(u *uuid.UUID) *NotifierUpdate { + if u != nil { + nu.SetGroupID(*u) + } + return nu +} + // SetUserID sets the "user_id" field. func (nu *NotifierUpdate) SetUserID(u uuid.UUID) *NotifierUpdate { nu.mutation.SetUserID(u) return nu } +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (nu *NotifierUpdate) SetNillableUserID(u *uuid.UUID) *NotifierUpdate { + if u != nil { + nu.SetUserID(*u) + } + return nu +} + // SetName sets the "name" field. func (nu *NotifierUpdate) SetName(s string) *NotifierUpdate { nu.mutation.SetName(s) return nu } +// SetNillableName sets the "name" field if the given value is not nil. +func (nu *NotifierUpdate) SetNillableName(s *string) *NotifierUpdate { + if s != nil { + nu.SetName(*s) + } + return nu +} + // SetURL sets the "url" field. func (nu *NotifierUpdate) SetURL(s string) *NotifierUpdate { nu.mutation.SetURL(s) return nu } +// SetNillableURL sets the "url" field if the given value is not nil. +func (nu *NotifierUpdate) SetNillableURL(s *string) *NotifierUpdate { + if s != nil { + nu.SetURL(*s) + } + return nu +} + // SetIsActive sets the "is_active" field. func (nu *NotifierUpdate) SetIsActive(b bool) *NotifierUpdate { nu.mutation.SetIsActive(b) @@ -273,24 +305,56 @@ func (nuo *NotifierUpdateOne) SetGroupID(u uuid.UUID) *NotifierUpdateOne { return nuo } +// SetNillableGroupID sets the "group_id" field if the given value is not nil. +func (nuo *NotifierUpdateOne) SetNillableGroupID(u *uuid.UUID) *NotifierUpdateOne { + if u != nil { + nuo.SetGroupID(*u) + } + return nuo +} + // SetUserID sets the "user_id" field. func (nuo *NotifierUpdateOne) SetUserID(u uuid.UUID) *NotifierUpdateOne { nuo.mutation.SetUserID(u) return nuo } +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (nuo *NotifierUpdateOne) SetNillableUserID(u *uuid.UUID) *NotifierUpdateOne { + if u != nil { + nuo.SetUserID(*u) + } + return nuo +} + // SetName sets the "name" field. func (nuo *NotifierUpdateOne) SetName(s string) *NotifierUpdateOne { nuo.mutation.SetName(s) return nuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (nuo *NotifierUpdateOne) SetNillableName(s *string) *NotifierUpdateOne { + if s != nil { + nuo.SetName(*s) + } + return nuo +} + // SetURL sets the "url" field. func (nuo *NotifierUpdateOne) SetURL(s string) *NotifierUpdateOne { nuo.mutation.SetURL(s) return nuo } +// SetNillableURL sets the "url" field if the given value is not nil. +func (nuo *NotifierUpdateOne) SetNillableURL(s *string) *NotifierUpdateOne { + if s != nil { + nuo.SetURL(*s) + } + return nuo +} + // SetIsActive sets the "is_active" field. func (nuo *NotifierUpdateOne) SetIsActive(b bool) *NotifierUpdateOne { nuo.mutation.SetIsActive(b) diff --git a/backend/internal/data/ent/runtime/runtime.go b/backend/internal/data/ent/runtime/runtime.go index 154cfdb..b5773b1 100644 --- a/backend/internal/data/ent/runtime/runtime.go +++ b/backend/internal/data/ent/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in github.com/hay-kot/homebox/backend/internal/data/ent/runtime.go const ( - Version = "v0.12.3" // Version of ent codegen. - Sum = "h1:N5lO2EOrHpCH5HYfiMOCHYbo+oh5M8GjT0/cx5x6xkk=" // Sum of ent codegen. + Version = "v0.12.5" // Version of ent codegen. + Sum = "h1:KREM5E4CSoej4zeGa88Ou/gfturAnpUv0mzAjch1sj4=" // Sum of ent codegen. ) diff --git a/backend/internal/data/ent/user/where.go b/backend/internal/data/ent/user/where.go index f56d400..8686e73 100644 --- a/backend/internal/data/ent/user/where.go +++ b/backend/internal/data/ent/user/where.go @@ -532,32 +532,15 @@ func HasNotifiersWith(preds ...predicate.Notifier) predicate.User { // And groups predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.User(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.User(sql.NotPredicates(p)) } diff --git a/backend/internal/data/ent/user_create.go b/backend/internal/data/ent/user_create.go index 97077f5..2cfe2d1 100644 --- a/backend/internal/data/ent/user_create.go +++ b/backend/internal/data/ent/user_create.go @@ -417,11 +417,15 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { // UserCreateBulk is the builder for creating many User entities in bulk. type UserCreateBulk struct { config + err error builders []*UserCreate } // Save creates the User entities in the database. func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if ucb.err != nil { + return nil, ucb.err + } specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) nodes := make([]*User, len(ucb.builders)) mutators := make([]Mutator, len(ucb.builders)) diff --git a/backend/internal/data/ent/user_update.go b/backend/internal/data/ent/user_update.go index 0fa13b7..0e4c01a 100644 --- a/backend/internal/data/ent/user_update.go +++ b/backend/internal/data/ent/user_update.go @@ -44,18 +44,42 @@ func (uu *UserUpdate) SetName(s string) *UserUpdate { return uu } +// SetNillableName sets the "name" field if the given value is not nil. +func (uu *UserUpdate) SetNillableName(s *string) *UserUpdate { + if s != nil { + uu.SetName(*s) + } + return uu +} + // SetEmail sets the "email" field. func (uu *UserUpdate) SetEmail(s string) *UserUpdate { uu.mutation.SetEmail(s) return uu } +// SetNillableEmail sets the "email" field if the given value is not nil. +func (uu *UserUpdate) SetNillableEmail(s *string) *UserUpdate { + if s != nil { + uu.SetEmail(*s) + } + return uu +} + // SetPassword sets the "password" field. func (uu *UserUpdate) SetPassword(s string) *UserUpdate { uu.mutation.SetPassword(s) return uu } +// SetNillablePassword sets the "password" field if the given value is not nil. +func (uu *UserUpdate) SetNillablePassword(s *string) *UserUpdate { + if s != nil { + uu.SetPassword(*s) + } + return uu +} + // SetIsSuperuser sets the "is_superuser" field. func (uu *UserUpdate) SetIsSuperuser(b bool) *UserUpdate { uu.mutation.SetIsSuperuser(b) @@ -466,18 +490,42 @@ func (uuo *UserUpdateOne) SetName(s string) *UserUpdateOne { return uuo } +// SetNillableName sets the "name" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableName(s *string) *UserUpdateOne { + if s != nil { + uuo.SetName(*s) + } + return uuo +} + // SetEmail sets the "email" field. func (uuo *UserUpdateOne) SetEmail(s string) *UserUpdateOne { uuo.mutation.SetEmail(s) return uuo } +// SetNillableEmail sets the "email" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableEmail(s *string) *UserUpdateOne { + if s != nil { + uuo.SetEmail(*s) + } + return uuo +} + // SetPassword sets the "password" field. func (uuo *UserUpdateOne) SetPassword(s string) *UserUpdateOne { uuo.mutation.SetPassword(s) return uuo } +// SetNillablePassword sets the "password" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillablePassword(s *string) *UserUpdateOne { + if s != nil { + uuo.SetPassword(*s) + } + return uuo +} + // SetIsSuperuser sets the "is_superuser" field. func (uuo *UserUpdateOne) SetIsSuperuser(b bool) *UserUpdateOne { uuo.mutation.SetIsSuperuser(b)