manager/ent/mailbox_update.go

986 lines
25 KiB
Go
Raw Permalink Normal View History

2022-04-08 21:26:25 +02:00
// Code generated by entc, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"time"
"code.icod.de/postfix/manager/ent/domain"
"code.icod.de/postfix/manager/ent/mailbox"
"code.icod.de/postfix/manager/ent/predicate"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// MailboxUpdate is the builder for updating Mailbox entities.
type MailboxUpdate struct {
config
hooks []Hook
mutation *MailboxMutation
}
// Where appends a list predicates to the MailboxUpdate builder.
func (mu *MailboxUpdate) Where(ps ...predicate.Mailbox) *MailboxUpdate {
mu.mutation.Where(ps...)
return mu
}
// SetActive sets the "active" field.
func (mu *MailboxUpdate) SetActive(b bool) *MailboxUpdate {
mu.mutation.SetActive(b)
return mu
}
// SetModified sets the "modified" field.
func (mu *MailboxUpdate) SetModified(t time.Time) *MailboxUpdate {
mu.mutation.SetModified(t)
return mu
}
// ClearModified clears the value of the "modified" field.
func (mu *MailboxUpdate) ClearModified() *MailboxUpdate {
mu.mutation.ClearModified()
return mu
}
// SetDomainID sets the "domain_id" field.
func (mu *MailboxUpdate) SetDomainID(i int64) *MailboxUpdate {
mu.mutation.SetDomainID(i)
return mu
}
// SetNillableDomainID sets the "domain_id" field if the given value is not nil.
func (mu *MailboxUpdate) SetNillableDomainID(i *int64) *MailboxUpdate {
if i != nil {
mu.SetDomainID(*i)
}
return mu
}
// ClearDomainID clears the value of the "domain_id" field.
func (mu *MailboxUpdate) ClearDomainID() *MailboxUpdate {
mu.mutation.ClearDomainID()
return mu
}
// SetUsername sets the "username" field.
func (mu *MailboxUpdate) SetUsername(s string) *MailboxUpdate {
mu.mutation.SetUsername(s)
return mu
}
// SetPassword sets the "password" field.
func (mu *MailboxUpdate) SetPassword(b []byte) *MailboxUpdate {
mu.mutation.SetPassword(b)
return mu
}
// SetName sets the "name" field.
func (mu *MailboxUpdate) SetName(s string) *MailboxUpdate {
mu.mutation.SetName(s)
return mu
}
// SetNillableName sets the "name" field if the given value is not nil.
func (mu *MailboxUpdate) SetNillableName(s *string) *MailboxUpdate {
if s != nil {
mu.SetName(*s)
}
return mu
}
// ClearName clears the value of the "name" field.
func (mu *MailboxUpdate) ClearName() *MailboxUpdate {
mu.mutation.ClearName()
return mu
}
// SetQuota sets the "quota" field.
func (mu *MailboxUpdate) SetQuota(i int64) *MailboxUpdate {
mu.mutation.ResetQuota()
mu.mutation.SetQuota(i)
return mu
}
// AddQuota adds i to the "quota" field.
func (mu *MailboxUpdate) AddQuota(i int64) *MailboxUpdate {
mu.mutation.AddQuota(i)
return mu
}
// SetLocalPart sets the "local_part" field.
func (mu *MailboxUpdate) SetLocalPart(s string) *MailboxUpdate {
mu.mutation.SetLocalPart(s)
return mu
}
// SetHomedir sets the "homedir" field.
func (mu *MailboxUpdate) SetHomedir(s string) *MailboxUpdate {
mu.mutation.SetHomedir(s)
return mu
}
// SetNillableHomedir sets the "homedir" field if the given value is not nil.
func (mu *MailboxUpdate) SetNillableHomedir(s *string) *MailboxUpdate {
if s != nil {
mu.SetHomedir(*s)
}
return mu
}
// ClearHomedir clears the value of the "homedir" field.
func (mu *MailboxUpdate) ClearHomedir() *MailboxUpdate {
mu.mutation.ClearHomedir()
return mu
}
// SetMaildir sets the "maildir" field.
func (mu *MailboxUpdate) SetMaildir(s string) *MailboxUpdate {
mu.mutation.SetMaildir(s)
return mu
}
// SetNillableMaildir sets the "maildir" field if the given value is not nil.
func (mu *MailboxUpdate) SetNillableMaildir(s *string) *MailboxUpdate {
if s != nil {
mu.SetMaildir(*s)
}
return mu
}
// ClearMaildir clears the value of the "maildir" field.
func (mu *MailboxUpdate) ClearMaildir() *MailboxUpdate {
mu.mutation.ClearMaildir()
return mu
}
// SetUID sets the "uid" field.
func (mu *MailboxUpdate) SetUID(i int32) *MailboxUpdate {
mu.mutation.ResetUID()
mu.mutation.SetUID(i)
return mu
}
// SetNillableUID sets the "uid" field if the given value is not nil.
func (mu *MailboxUpdate) SetNillableUID(i *int32) *MailboxUpdate {
if i != nil {
mu.SetUID(*i)
}
return mu
}
// AddUID adds i to the "uid" field.
func (mu *MailboxUpdate) AddUID(i int32) *MailboxUpdate {
mu.mutation.AddUID(i)
return mu
}
// ClearUID clears the value of the "uid" field.
func (mu *MailboxUpdate) ClearUID() *MailboxUpdate {
mu.mutation.ClearUID()
return mu
}
// SetGid sets the "gid" field.
func (mu *MailboxUpdate) SetGid(i int32) *MailboxUpdate {
mu.mutation.ResetGid()
mu.mutation.SetGid(i)
return mu
}
// SetNillableGid sets the "gid" field if the given value is not nil.
func (mu *MailboxUpdate) SetNillableGid(i *int32) *MailboxUpdate {
if i != nil {
mu.SetGid(*i)
}
return mu
}
// AddGid adds i to the "gid" field.
func (mu *MailboxUpdate) AddGid(i int32) *MailboxUpdate {
mu.mutation.AddGid(i)
return mu
}
// ClearGid clears the value of the "gid" field.
func (mu *MailboxUpdate) ClearGid() *MailboxUpdate {
mu.mutation.ClearGid()
return mu
}
// SetDomain sets the "domain" edge to the Domain entity.
func (mu *MailboxUpdate) SetDomain(d *Domain) *MailboxUpdate {
return mu.SetDomainID(d.ID)
}
// Mutation returns the MailboxMutation object of the builder.
func (mu *MailboxUpdate) Mutation() *MailboxMutation {
return mu.mutation
}
// ClearDomain clears the "domain" edge to the Domain entity.
func (mu *MailboxUpdate) ClearDomain() *MailboxUpdate {
mu.mutation.ClearDomain()
return mu
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (mu *MailboxUpdate) Save(ctx context.Context) (int, error) {
var (
err error
affected int
)
mu.defaults()
if len(mu.hooks) == 0 {
affected, err = mu.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*MailboxMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
mu.mutation = mutation
affected, err = mu.sqlSave(ctx)
mutation.done = true
return affected, err
})
for i := len(mu.hooks) - 1; i >= 0; i-- {
if mu.hooks[i] == nil {
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = mu.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, mu.mutation); err != nil {
return 0, err
}
}
return affected, err
}
// SaveX is like Save, but panics if an error occurs.
func (mu *MailboxUpdate) SaveX(ctx context.Context) int {
affected, err := mu.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (mu *MailboxUpdate) Exec(ctx context.Context) error {
_, err := mu.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (mu *MailboxUpdate) ExecX(ctx context.Context) {
if err := mu.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (mu *MailboxUpdate) defaults() {
if _, ok := mu.mutation.Modified(); !ok && !mu.mutation.ModifiedCleared() {
v := mailbox.UpdateDefaultModified()
mu.mutation.SetModified(v)
}
}
func (mu *MailboxUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: mailbox.Table,
Columns: mailbox.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt64,
Column: mailbox.FieldID,
},
},
}
if ps := mu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := mu.mutation.Active(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeBool,
Value: value,
Column: mailbox.FieldActive,
})
}
if value, ok := mu.mutation.Modified(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: mailbox.FieldModified,
})
}
if mu.mutation.ModifiedCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Column: mailbox.FieldModified,
})
}
if value, ok := mu.mutation.Username(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: mailbox.FieldUsername,
})
}
if value, ok := mu.mutation.Password(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeBytes,
Value: value,
Column: mailbox.FieldPassword,
})
}
if value, ok := mu.mutation.Name(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: mailbox.FieldName,
})
}
if mu.mutation.NameCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: mailbox.FieldName,
})
}
if value, ok := mu.mutation.Quota(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt64,
Value: value,
Column: mailbox.FieldQuota,
})
}
if value, ok := mu.mutation.AddedQuota(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt64,
Value: value,
Column: mailbox.FieldQuota,
})
}
if value, ok := mu.mutation.LocalPart(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: mailbox.FieldLocalPart,
})
}
if value, ok := mu.mutation.Homedir(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: mailbox.FieldHomedir,
})
}
if mu.mutation.HomedirCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: mailbox.FieldHomedir,
})
}
if value, ok := mu.mutation.Maildir(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: mailbox.FieldMaildir,
})
}
if mu.mutation.MaildirCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: mailbox.FieldMaildir,
})
}
if value, ok := mu.mutation.UID(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt32,
Value: value,
Column: mailbox.FieldUID,
})
}
if value, ok := mu.mutation.AddedUID(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt32,
Value: value,
Column: mailbox.FieldUID,
})
}
if mu.mutation.UIDCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeInt32,
Column: mailbox.FieldUID,
})
}
if value, ok := mu.mutation.Gid(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt32,
Value: value,
Column: mailbox.FieldGid,
})
}
if value, ok := mu.mutation.AddedGid(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt32,
Value: value,
Column: mailbox.FieldGid,
})
}
if mu.mutation.GidCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeInt32,
Column: mailbox.FieldGid,
})
}
if mu.mutation.DomainCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: mailbox.DomainTable,
Columns: []string{mailbox.DomainColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt64,
Column: domain.FieldID,
},
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := mu.mutation.DomainIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: mailbox.DomainTable,
Columns: []string{mailbox.DomainColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt64,
Column: domain.FieldID,
},
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if n, err = sqlgraph.UpdateNodes(ctx, mu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{mailbox.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
return 0, err
}
return n, nil
}
// MailboxUpdateOne is the builder for updating a single Mailbox entity.
type MailboxUpdateOne struct {
config
fields []string
hooks []Hook
mutation *MailboxMutation
}
// SetActive sets the "active" field.
func (muo *MailboxUpdateOne) SetActive(b bool) *MailboxUpdateOne {
muo.mutation.SetActive(b)
return muo
}
// SetModified sets the "modified" field.
func (muo *MailboxUpdateOne) SetModified(t time.Time) *MailboxUpdateOne {
muo.mutation.SetModified(t)
return muo
}
// ClearModified clears the value of the "modified" field.
func (muo *MailboxUpdateOne) ClearModified() *MailboxUpdateOne {
muo.mutation.ClearModified()
return muo
}
// SetDomainID sets the "domain_id" field.
func (muo *MailboxUpdateOne) SetDomainID(i int64) *MailboxUpdateOne {
muo.mutation.SetDomainID(i)
return muo
}
// SetNillableDomainID sets the "domain_id" field if the given value is not nil.
func (muo *MailboxUpdateOne) SetNillableDomainID(i *int64) *MailboxUpdateOne {
if i != nil {
muo.SetDomainID(*i)
}
return muo
}
// ClearDomainID clears the value of the "domain_id" field.
func (muo *MailboxUpdateOne) ClearDomainID() *MailboxUpdateOne {
muo.mutation.ClearDomainID()
return muo
}
// SetUsername sets the "username" field.
func (muo *MailboxUpdateOne) SetUsername(s string) *MailboxUpdateOne {
muo.mutation.SetUsername(s)
return muo
}
// SetPassword sets the "password" field.
func (muo *MailboxUpdateOne) SetPassword(b []byte) *MailboxUpdateOne {
muo.mutation.SetPassword(b)
return muo
}
// SetName sets the "name" field.
func (muo *MailboxUpdateOne) SetName(s string) *MailboxUpdateOne {
muo.mutation.SetName(s)
return muo
}
// SetNillableName sets the "name" field if the given value is not nil.
func (muo *MailboxUpdateOne) SetNillableName(s *string) *MailboxUpdateOne {
if s != nil {
muo.SetName(*s)
}
return muo
}
// ClearName clears the value of the "name" field.
func (muo *MailboxUpdateOne) ClearName() *MailboxUpdateOne {
muo.mutation.ClearName()
return muo
}
// SetQuota sets the "quota" field.
func (muo *MailboxUpdateOne) SetQuota(i int64) *MailboxUpdateOne {
muo.mutation.ResetQuota()
muo.mutation.SetQuota(i)
return muo
}
// AddQuota adds i to the "quota" field.
func (muo *MailboxUpdateOne) AddQuota(i int64) *MailboxUpdateOne {
muo.mutation.AddQuota(i)
return muo
}
// SetLocalPart sets the "local_part" field.
func (muo *MailboxUpdateOne) SetLocalPart(s string) *MailboxUpdateOne {
muo.mutation.SetLocalPart(s)
return muo
}
// SetHomedir sets the "homedir" field.
func (muo *MailboxUpdateOne) SetHomedir(s string) *MailboxUpdateOne {
muo.mutation.SetHomedir(s)
return muo
}
// SetNillableHomedir sets the "homedir" field if the given value is not nil.
func (muo *MailboxUpdateOne) SetNillableHomedir(s *string) *MailboxUpdateOne {
if s != nil {
muo.SetHomedir(*s)
}
return muo
}
// ClearHomedir clears the value of the "homedir" field.
func (muo *MailboxUpdateOne) ClearHomedir() *MailboxUpdateOne {
muo.mutation.ClearHomedir()
return muo
}
// SetMaildir sets the "maildir" field.
func (muo *MailboxUpdateOne) SetMaildir(s string) *MailboxUpdateOne {
muo.mutation.SetMaildir(s)
return muo
}
// SetNillableMaildir sets the "maildir" field if the given value is not nil.
func (muo *MailboxUpdateOne) SetNillableMaildir(s *string) *MailboxUpdateOne {
if s != nil {
muo.SetMaildir(*s)
}
return muo
}
// ClearMaildir clears the value of the "maildir" field.
func (muo *MailboxUpdateOne) ClearMaildir() *MailboxUpdateOne {
muo.mutation.ClearMaildir()
return muo
}
// SetUID sets the "uid" field.
func (muo *MailboxUpdateOne) SetUID(i int32) *MailboxUpdateOne {
muo.mutation.ResetUID()
muo.mutation.SetUID(i)
return muo
}
// SetNillableUID sets the "uid" field if the given value is not nil.
func (muo *MailboxUpdateOne) SetNillableUID(i *int32) *MailboxUpdateOne {
if i != nil {
muo.SetUID(*i)
}
return muo
}
// AddUID adds i to the "uid" field.
func (muo *MailboxUpdateOne) AddUID(i int32) *MailboxUpdateOne {
muo.mutation.AddUID(i)
return muo
}
// ClearUID clears the value of the "uid" field.
func (muo *MailboxUpdateOne) ClearUID() *MailboxUpdateOne {
muo.mutation.ClearUID()
return muo
}
// SetGid sets the "gid" field.
func (muo *MailboxUpdateOne) SetGid(i int32) *MailboxUpdateOne {
muo.mutation.ResetGid()
muo.mutation.SetGid(i)
return muo
}
// SetNillableGid sets the "gid" field if the given value is not nil.
func (muo *MailboxUpdateOne) SetNillableGid(i *int32) *MailboxUpdateOne {
if i != nil {
muo.SetGid(*i)
}
return muo
}
// AddGid adds i to the "gid" field.
func (muo *MailboxUpdateOne) AddGid(i int32) *MailboxUpdateOne {
muo.mutation.AddGid(i)
return muo
}
// ClearGid clears the value of the "gid" field.
func (muo *MailboxUpdateOne) ClearGid() *MailboxUpdateOne {
muo.mutation.ClearGid()
return muo
}
// SetDomain sets the "domain" edge to the Domain entity.
func (muo *MailboxUpdateOne) SetDomain(d *Domain) *MailboxUpdateOne {
return muo.SetDomainID(d.ID)
}
// Mutation returns the MailboxMutation object of the builder.
func (muo *MailboxUpdateOne) Mutation() *MailboxMutation {
return muo.mutation
}
// ClearDomain clears the "domain" edge to the Domain entity.
func (muo *MailboxUpdateOne) ClearDomain() *MailboxUpdateOne {
muo.mutation.ClearDomain()
return muo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (muo *MailboxUpdateOne) Select(field string, fields ...string) *MailboxUpdateOne {
muo.fields = append([]string{field}, fields...)
return muo
}
// Save executes the query and returns the updated Mailbox entity.
func (muo *MailboxUpdateOne) Save(ctx context.Context) (*Mailbox, error) {
var (
err error
node *Mailbox
)
muo.defaults()
if len(muo.hooks) == 0 {
node, err = muo.sqlSave(ctx)
} else {
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*MailboxMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
muo.mutation = mutation
node, err = muo.sqlSave(ctx)
mutation.done = true
return node, err
})
for i := len(muo.hooks) - 1; i >= 0; i-- {
if muo.hooks[i] == nil {
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = muo.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, muo.mutation); err != nil {
return nil, err
}
}
return node, err
}
// SaveX is like Save, but panics if an error occurs.
func (muo *MailboxUpdateOne) SaveX(ctx context.Context) *Mailbox {
node, err := muo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (muo *MailboxUpdateOne) Exec(ctx context.Context) error {
_, err := muo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (muo *MailboxUpdateOne) ExecX(ctx context.Context) {
if err := muo.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (muo *MailboxUpdateOne) defaults() {
if _, ok := muo.mutation.Modified(); !ok && !muo.mutation.ModifiedCleared() {
v := mailbox.UpdateDefaultModified()
muo.mutation.SetModified(v)
}
}
func (muo *MailboxUpdateOne) sqlSave(ctx context.Context) (_node *Mailbox, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: mailbox.Table,
Columns: mailbox.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt64,
Column: mailbox.FieldID,
},
},
}
id, ok := muo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Mailbox.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := muo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, mailbox.FieldID)
for _, f := range fields {
if !mailbox.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != mailbox.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := muo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := muo.mutation.Active(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeBool,
Value: value,
Column: mailbox.FieldActive,
})
}
if value, ok := muo.mutation.Modified(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Value: value,
Column: mailbox.FieldModified,
})
}
if muo.mutation.ModifiedCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Column: mailbox.FieldModified,
})
}
if value, ok := muo.mutation.Username(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: mailbox.FieldUsername,
})
}
if value, ok := muo.mutation.Password(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeBytes,
Value: value,
Column: mailbox.FieldPassword,
})
}
if value, ok := muo.mutation.Name(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: mailbox.FieldName,
})
}
if muo.mutation.NameCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: mailbox.FieldName,
})
}
if value, ok := muo.mutation.Quota(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt64,
Value: value,
Column: mailbox.FieldQuota,
})
}
if value, ok := muo.mutation.AddedQuota(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt64,
Value: value,
Column: mailbox.FieldQuota,
})
}
if value, ok := muo.mutation.LocalPart(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: mailbox.FieldLocalPart,
})
}
if value, ok := muo.mutation.Homedir(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: mailbox.FieldHomedir,
})
}
if muo.mutation.HomedirCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: mailbox.FieldHomedir,
})
}
if value, ok := muo.mutation.Maildir(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
Value: value,
Column: mailbox.FieldMaildir,
})
}
if muo.mutation.MaildirCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeString,
Column: mailbox.FieldMaildir,
})
}
if value, ok := muo.mutation.UID(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt32,
Value: value,
Column: mailbox.FieldUID,
})
}
if value, ok := muo.mutation.AddedUID(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt32,
Value: value,
Column: mailbox.FieldUID,
})
}
if muo.mutation.UIDCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeInt32,
Column: mailbox.FieldUID,
})
}
if value, ok := muo.mutation.Gid(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeInt32,
Value: value,
Column: mailbox.FieldGid,
})
}
if value, ok := muo.mutation.AddedGid(); ok {
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
Type: field.TypeInt32,
Value: value,
Column: mailbox.FieldGid,
})
}
if muo.mutation.GidCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeInt32,
Column: mailbox.FieldGid,
})
}
if muo.mutation.DomainCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: mailbox.DomainTable,
Columns: []string{mailbox.DomainColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt64,
Column: domain.FieldID,
},
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := muo.mutation.DomainIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: mailbox.DomainTable,
Columns: []string{mailbox.DomainColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt64,
Column: domain.FieldID,
},
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_node = &Mailbox{config: muo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, muo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{mailbox.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
return nil, err
}
return _node, nil
}