github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/pkg/db/ent/fiat_update.go (about)

     1  // Code generated by ent, DO NOT EDIT.
     2  
     3  package ent
     4  
     5  import (
     6  	"context"
     7  	"errors"
     8  	"fmt"
     9  
    10  	"entgo.io/ent/dialect/sql"
    11  	"entgo.io/ent/dialect/sql/sqlgraph"
    12  	"entgo.io/ent/schema/field"
    13  	"github.com/NpoolPlatform/chain-middleware/pkg/db/ent/fiat"
    14  	"github.com/NpoolPlatform/chain-middleware/pkg/db/ent/predicate"
    15  	"github.com/google/uuid"
    16  )
    17  
    18  // FiatUpdate is the builder for updating Fiat entities.
    19  type FiatUpdate struct {
    20  	config
    21  	hooks     []Hook
    22  	mutation  *FiatMutation
    23  	modifiers []func(*sql.UpdateBuilder)
    24  }
    25  
    26  // Where appends a list predicates to the FiatUpdate builder.
    27  func (fu *FiatUpdate) Where(ps ...predicate.Fiat) *FiatUpdate {
    28  	fu.mutation.Where(ps...)
    29  	return fu
    30  }
    31  
    32  // SetCreatedAt sets the "created_at" field.
    33  func (fu *FiatUpdate) SetCreatedAt(u uint32) *FiatUpdate {
    34  	fu.mutation.ResetCreatedAt()
    35  	fu.mutation.SetCreatedAt(u)
    36  	return fu
    37  }
    38  
    39  // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
    40  func (fu *FiatUpdate) SetNillableCreatedAt(u *uint32) *FiatUpdate {
    41  	if u != nil {
    42  		fu.SetCreatedAt(*u)
    43  	}
    44  	return fu
    45  }
    46  
    47  // AddCreatedAt adds u to the "created_at" field.
    48  func (fu *FiatUpdate) AddCreatedAt(u int32) *FiatUpdate {
    49  	fu.mutation.AddCreatedAt(u)
    50  	return fu
    51  }
    52  
    53  // SetUpdatedAt sets the "updated_at" field.
    54  func (fu *FiatUpdate) SetUpdatedAt(u uint32) *FiatUpdate {
    55  	fu.mutation.ResetUpdatedAt()
    56  	fu.mutation.SetUpdatedAt(u)
    57  	return fu
    58  }
    59  
    60  // AddUpdatedAt adds u to the "updated_at" field.
    61  func (fu *FiatUpdate) AddUpdatedAt(u int32) *FiatUpdate {
    62  	fu.mutation.AddUpdatedAt(u)
    63  	return fu
    64  }
    65  
    66  // SetDeletedAt sets the "deleted_at" field.
    67  func (fu *FiatUpdate) SetDeletedAt(u uint32) *FiatUpdate {
    68  	fu.mutation.ResetDeletedAt()
    69  	fu.mutation.SetDeletedAt(u)
    70  	return fu
    71  }
    72  
    73  // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
    74  func (fu *FiatUpdate) SetNillableDeletedAt(u *uint32) *FiatUpdate {
    75  	if u != nil {
    76  		fu.SetDeletedAt(*u)
    77  	}
    78  	return fu
    79  }
    80  
    81  // AddDeletedAt adds u to the "deleted_at" field.
    82  func (fu *FiatUpdate) AddDeletedAt(u int32) *FiatUpdate {
    83  	fu.mutation.AddDeletedAt(u)
    84  	return fu
    85  }
    86  
    87  // SetEntID sets the "ent_id" field.
    88  func (fu *FiatUpdate) SetEntID(u uuid.UUID) *FiatUpdate {
    89  	fu.mutation.SetEntID(u)
    90  	return fu
    91  }
    92  
    93  // SetNillableEntID sets the "ent_id" field if the given value is not nil.
    94  func (fu *FiatUpdate) SetNillableEntID(u *uuid.UUID) *FiatUpdate {
    95  	if u != nil {
    96  		fu.SetEntID(*u)
    97  	}
    98  	return fu
    99  }
   100  
   101  // SetName sets the "name" field.
   102  func (fu *FiatUpdate) SetName(s string) *FiatUpdate {
   103  	fu.mutation.SetName(s)
   104  	return fu
   105  }
   106  
   107  // SetNillableName sets the "name" field if the given value is not nil.
   108  func (fu *FiatUpdate) SetNillableName(s *string) *FiatUpdate {
   109  	if s != nil {
   110  		fu.SetName(*s)
   111  	}
   112  	return fu
   113  }
   114  
   115  // ClearName clears the value of the "name" field.
   116  func (fu *FiatUpdate) ClearName() *FiatUpdate {
   117  	fu.mutation.ClearName()
   118  	return fu
   119  }
   120  
   121  // SetLogo sets the "logo" field.
   122  func (fu *FiatUpdate) SetLogo(s string) *FiatUpdate {
   123  	fu.mutation.SetLogo(s)
   124  	return fu
   125  }
   126  
   127  // SetNillableLogo sets the "logo" field if the given value is not nil.
   128  func (fu *FiatUpdate) SetNillableLogo(s *string) *FiatUpdate {
   129  	if s != nil {
   130  		fu.SetLogo(*s)
   131  	}
   132  	return fu
   133  }
   134  
   135  // ClearLogo clears the value of the "logo" field.
   136  func (fu *FiatUpdate) ClearLogo() *FiatUpdate {
   137  	fu.mutation.ClearLogo()
   138  	return fu
   139  }
   140  
   141  // SetUnit sets the "unit" field.
   142  func (fu *FiatUpdate) SetUnit(s string) *FiatUpdate {
   143  	fu.mutation.SetUnit(s)
   144  	return fu
   145  }
   146  
   147  // SetNillableUnit sets the "unit" field if the given value is not nil.
   148  func (fu *FiatUpdate) SetNillableUnit(s *string) *FiatUpdate {
   149  	if s != nil {
   150  		fu.SetUnit(*s)
   151  	}
   152  	return fu
   153  }
   154  
   155  // ClearUnit clears the value of the "unit" field.
   156  func (fu *FiatUpdate) ClearUnit() *FiatUpdate {
   157  	fu.mutation.ClearUnit()
   158  	return fu
   159  }
   160  
   161  // Mutation returns the FiatMutation object of the builder.
   162  func (fu *FiatUpdate) Mutation() *FiatMutation {
   163  	return fu.mutation
   164  }
   165  
   166  // Save executes the query and returns the number of nodes affected by the update operation.
   167  func (fu *FiatUpdate) Save(ctx context.Context) (int, error) {
   168  	var (
   169  		err      error
   170  		affected int
   171  	)
   172  	if err := fu.defaults(); err != nil {
   173  		return 0, err
   174  	}
   175  	if len(fu.hooks) == 0 {
   176  		affected, err = fu.sqlSave(ctx)
   177  	} else {
   178  		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
   179  			mutation, ok := m.(*FiatMutation)
   180  			if !ok {
   181  				return nil, fmt.Errorf("unexpected mutation type %T", m)
   182  			}
   183  			fu.mutation = mutation
   184  			affected, err = fu.sqlSave(ctx)
   185  			mutation.done = true
   186  			return affected, err
   187  		})
   188  		for i := len(fu.hooks) - 1; i >= 0; i-- {
   189  			if fu.hooks[i] == nil {
   190  				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
   191  			}
   192  			mut = fu.hooks[i](mut)
   193  		}
   194  		if _, err := mut.Mutate(ctx, fu.mutation); err != nil {
   195  			return 0, err
   196  		}
   197  	}
   198  	return affected, err
   199  }
   200  
   201  // SaveX is like Save, but panics if an error occurs.
   202  func (fu *FiatUpdate) SaveX(ctx context.Context) int {
   203  	affected, err := fu.Save(ctx)
   204  	if err != nil {
   205  		panic(err)
   206  	}
   207  	return affected
   208  }
   209  
   210  // Exec executes the query.
   211  func (fu *FiatUpdate) Exec(ctx context.Context) error {
   212  	_, err := fu.Save(ctx)
   213  	return err
   214  }
   215  
   216  // ExecX is like Exec, but panics if an error occurs.
   217  func (fu *FiatUpdate) ExecX(ctx context.Context) {
   218  	if err := fu.Exec(ctx); err != nil {
   219  		panic(err)
   220  	}
   221  }
   222  
   223  // defaults sets the default values of the builder before save.
   224  func (fu *FiatUpdate) defaults() error {
   225  	if _, ok := fu.mutation.UpdatedAt(); !ok {
   226  		if fiat.UpdateDefaultUpdatedAt == nil {
   227  			return fmt.Errorf("ent: uninitialized fiat.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
   228  		}
   229  		v := fiat.UpdateDefaultUpdatedAt()
   230  		fu.mutation.SetUpdatedAt(v)
   231  	}
   232  	return nil
   233  }
   234  
   235  // Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
   236  func (fu *FiatUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *FiatUpdate {
   237  	fu.modifiers = append(fu.modifiers, modifiers...)
   238  	return fu
   239  }
   240  
   241  func (fu *FiatUpdate) sqlSave(ctx context.Context) (n int, err error) {
   242  	_spec := &sqlgraph.UpdateSpec{
   243  		Node: &sqlgraph.NodeSpec{
   244  			Table:   fiat.Table,
   245  			Columns: fiat.Columns,
   246  			ID: &sqlgraph.FieldSpec{
   247  				Type:   field.TypeUint32,
   248  				Column: fiat.FieldID,
   249  			},
   250  		},
   251  	}
   252  	if ps := fu.mutation.predicates; len(ps) > 0 {
   253  		_spec.Predicate = func(selector *sql.Selector) {
   254  			for i := range ps {
   255  				ps[i](selector)
   256  			}
   257  		}
   258  	}
   259  	if value, ok := fu.mutation.CreatedAt(); ok {
   260  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   261  			Type:   field.TypeUint32,
   262  			Value:  value,
   263  			Column: fiat.FieldCreatedAt,
   264  		})
   265  	}
   266  	if value, ok := fu.mutation.AddedCreatedAt(); ok {
   267  		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
   268  			Type:   field.TypeUint32,
   269  			Value:  value,
   270  			Column: fiat.FieldCreatedAt,
   271  		})
   272  	}
   273  	if value, ok := fu.mutation.UpdatedAt(); ok {
   274  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   275  			Type:   field.TypeUint32,
   276  			Value:  value,
   277  			Column: fiat.FieldUpdatedAt,
   278  		})
   279  	}
   280  	if value, ok := fu.mutation.AddedUpdatedAt(); ok {
   281  		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
   282  			Type:   field.TypeUint32,
   283  			Value:  value,
   284  			Column: fiat.FieldUpdatedAt,
   285  		})
   286  	}
   287  	if value, ok := fu.mutation.DeletedAt(); ok {
   288  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   289  			Type:   field.TypeUint32,
   290  			Value:  value,
   291  			Column: fiat.FieldDeletedAt,
   292  		})
   293  	}
   294  	if value, ok := fu.mutation.AddedDeletedAt(); ok {
   295  		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
   296  			Type:   field.TypeUint32,
   297  			Value:  value,
   298  			Column: fiat.FieldDeletedAt,
   299  		})
   300  	}
   301  	if value, ok := fu.mutation.EntID(); ok {
   302  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   303  			Type:   field.TypeUUID,
   304  			Value:  value,
   305  			Column: fiat.FieldEntID,
   306  		})
   307  	}
   308  	if value, ok := fu.mutation.Name(); ok {
   309  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   310  			Type:   field.TypeString,
   311  			Value:  value,
   312  			Column: fiat.FieldName,
   313  		})
   314  	}
   315  	if fu.mutation.NameCleared() {
   316  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   317  			Type:   field.TypeString,
   318  			Column: fiat.FieldName,
   319  		})
   320  	}
   321  	if value, ok := fu.mutation.Logo(); ok {
   322  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   323  			Type:   field.TypeString,
   324  			Value:  value,
   325  			Column: fiat.FieldLogo,
   326  		})
   327  	}
   328  	if fu.mutation.LogoCleared() {
   329  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   330  			Type:   field.TypeString,
   331  			Column: fiat.FieldLogo,
   332  		})
   333  	}
   334  	if value, ok := fu.mutation.Unit(); ok {
   335  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   336  			Type:   field.TypeString,
   337  			Value:  value,
   338  			Column: fiat.FieldUnit,
   339  		})
   340  	}
   341  	if fu.mutation.UnitCleared() {
   342  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   343  			Type:   field.TypeString,
   344  			Column: fiat.FieldUnit,
   345  		})
   346  	}
   347  	_spec.Modifiers = fu.modifiers
   348  	if n, err = sqlgraph.UpdateNodes(ctx, fu.driver, _spec); err != nil {
   349  		if _, ok := err.(*sqlgraph.NotFoundError); ok {
   350  			err = &NotFoundError{fiat.Label}
   351  		} else if sqlgraph.IsConstraintError(err) {
   352  			err = &ConstraintError{msg: err.Error(), wrap: err}
   353  		}
   354  		return 0, err
   355  	}
   356  	return n, nil
   357  }
   358  
   359  // FiatUpdateOne is the builder for updating a single Fiat entity.
   360  type FiatUpdateOne struct {
   361  	config
   362  	fields    []string
   363  	hooks     []Hook
   364  	mutation  *FiatMutation
   365  	modifiers []func(*sql.UpdateBuilder)
   366  }
   367  
   368  // SetCreatedAt sets the "created_at" field.
   369  func (fuo *FiatUpdateOne) SetCreatedAt(u uint32) *FiatUpdateOne {
   370  	fuo.mutation.ResetCreatedAt()
   371  	fuo.mutation.SetCreatedAt(u)
   372  	return fuo
   373  }
   374  
   375  // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
   376  func (fuo *FiatUpdateOne) SetNillableCreatedAt(u *uint32) *FiatUpdateOne {
   377  	if u != nil {
   378  		fuo.SetCreatedAt(*u)
   379  	}
   380  	return fuo
   381  }
   382  
   383  // AddCreatedAt adds u to the "created_at" field.
   384  func (fuo *FiatUpdateOne) AddCreatedAt(u int32) *FiatUpdateOne {
   385  	fuo.mutation.AddCreatedAt(u)
   386  	return fuo
   387  }
   388  
   389  // SetUpdatedAt sets the "updated_at" field.
   390  func (fuo *FiatUpdateOne) SetUpdatedAt(u uint32) *FiatUpdateOne {
   391  	fuo.mutation.ResetUpdatedAt()
   392  	fuo.mutation.SetUpdatedAt(u)
   393  	return fuo
   394  }
   395  
   396  // AddUpdatedAt adds u to the "updated_at" field.
   397  func (fuo *FiatUpdateOne) AddUpdatedAt(u int32) *FiatUpdateOne {
   398  	fuo.mutation.AddUpdatedAt(u)
   399  	return fuo
   400  }
   401  
   402  // SetDeletedAt sets the "deleted_at" field.
   403  func (fuo *FiatUpdateOne) SetDeletedAt(u uint32) *FiatUpdateOne {
   404  	fuo.mutation.ResetDeletedAt()
   405  	fuo.mutation.SetDeletedAt(u)
   406  	return fuo
   407  }
   408  
   409  // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
   410  func (fuo *FiatUpdateOne) SetNillableDeletedAt(u *uint32) *FiatUpdateOne {
   411  	if u != nil {
   412  		fuo.SetDeletedAt(*u)
   413  	}
   414  	return fuo
   415  }
   416  
   417  // AddDeletedAt adds u to the "deleted_at" field.
   418  func (fuo *FiatUpdateOne) AddDeletedAt(u int32) *FiatUpdateOne {
   419  	fuo.mutation.AddDeletedAt(u)
   420  	return fuo
   421  }
   422  
   423  // SetEntID sets the "ent_id" field.
   424  func (fuo *FiatUpdateOne) SetEntID(u uuid.UUID) *FiatUpdateOne {
   425  	fuo.mutation.SetEntID(u)
   426  	return fuo
   427  }
   428  
   429  // SetNillableEntID sets the "ent_id" field if the given value is not nil.
   430  func (fuo *FiatUpdateOne) SetNillableEntID(u *uuid.UUID) *FiatUpdateOne {
   431  	if u != nil {
   432  		fuo.SetEntID(*u)
   433  	}
   434  	return fuo
   435  }
   436  
   437  // SetName sets the "name" field.
   438  func (fuo *FiatUpdateOne) SetName(s string) *FiatUpdateOne {
   439  	fuo.mutation.SetName(s)
   440  	return fuo
   441  }
   442  
   443  // SetNillableName sets the "name" field if the given value is not nil.
   444  func (fuo *FiatUpdateOne) SetNillableName(s *string) *FiatUpdateOne {
   445  	if s != nil {
   446  		fuo.SetName(*s)
   447  	}
   448  	return fuo
   449  }
   450  
   451  // ClearName clears the value of the "name" field.
   452  func (fuo *FiatUpdateOne) ClearName() *FiatUpdateOne {
   453  	fuo.mutation.ClearName()
   454  	return fuo
   455  }
   456  
   457  // SetLogo sets the "logo" field.
   458  func (fuo *FiatUpdateOne) SetLogo(s string) *FiatUpdateOne {
   459  	fuo.mutation.SetLogo(s)
   460  	return fuo
   461  }
   462  
   463  // SetNillableLogo sets the "logo" field if the given value is not nil.
   464  func (fuo *FiatUpdateOne) SetNillableLogo(s *string) *FiatUpdateOne {
   465  	if s != nil {
   466  		fuo.SetLogo(*s)
   467  	}
   468  	return fuo
   469  }
   470  
   471  // ClearLogo clears the value of the "logo" field.
   472  func (fuo *FiatUpdateOne) ClearLogo() *FiatUpdateOne {
   473  	fuo.mutation.ClearLogo()
   474  	return fuo
   475  }
   476  
   477  // SetUnit sets the "unit" field.
   478  func (fuo *FiatUpdateOne) SetUnit(s string) *FiatUpdateOne {
   479  	fuo.mutation.SetUnit(s)
   480  	return fuo
   481  }
   482  
   483  // SetNillableUnit sets the "unit" field if the given value is not nil.
   484  func (fuo *FiatUpdateOne) SetNillableUnit(s *string) *FiatUpdateOne {
   485  	if s != nil {
   486  		fuo.SetUnit(*s)
   487  	}
   488  	return fuo
   489  }
   490  
   491  // ClearUnit clears the value of the "unit" field.
   492  func (fuo *FiatUpdateOne) ClearUnit() *FiatUpdateOne {
   493  	fuo.mutation.ClearUnit()
   494  	return fuo
   495  }
   496  
   497  // Mutation returns the FiatMutation object of the builder.
   498  func (fuo *FiatUpdateOne) Mutation() *FiatMutation {
   499  	return fuo.mutation
   500  }
   501  
   502  // Select allows selecting one or more fields (columns) of the returned entity.
   503  // The default is selecting all fields defined in the entity schema.
   504  func (fuo *FiatUpdateOne) Select(field string, fields ...string) *FiatUpdateOne {
   505  	fuo.fields = append([]string{field}, fields...)
   506  	return fuo
   507  }
   508  
   509  // Save executes the query and returns the updated Fiat entity.
   510  func (fuo *FiatUpdateOne) Save(ctx context.Context) (*Fiat, error) {
   511  	var (
   512  		err  error
   513  		node *Fiat
   514  	)
   515  	if err := fuo.defaults(); err != nil {
   516  		return nil, err
   517  	}
   518  	if len(fuo.hooks) == 0 {
   519  		node, err = fuo.sqlSave(ctx)
   520  	} else {
   521  		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
   522  			mutation, ok := m.(*FiatMutation)
   523  			if !ok {
   524  				return nil, fmt.Errorf("unexpected mutation type %T", m)
   525  			}
   526  			fuo.mutation = mutation
   527  			node, err = fuo.sqlSave(ctx)
   528  			mutation.done = true
   529  			return node, err
   530  		})
   531  		for i := len(fuo.hooks) - 1; i >= 0; i-- {
   532  			if fuo.hooks[i] == nil {
   533  				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
   534  			}
   535  			mut = fuo.hooks[i](mut)
   536  		}
   537  		v, err := mut.Mutate(ctx, fuo.mutation)
   538  		if err != nil {
   539  			return nil, err
   540  		}
   541  		nv, ok := v.(*Fiat)
   542  		if !ok {
   543  			return nil, fmt.Errorf("unexpected node type %T returned from FiatMutation", v)
   544  		}
   545  		node = nv
   546  	}
   547  	return node, err
   548  }
   549  
   550  // SaveX is like Save, but panics if an error occurs.
   551  func (fuo *FiatUpdateOne) SaveX(ctx context.Context) *Fiat {
   552  	node, err := fuo.Save(ctx)
   553  	if err != nil {
   554  		panic(err)
   555  	}
   556  	return node
   557  }
   558  
   559  // Exec executes the query on the entity.
   560  func (fuo *FiatUpdateOne) Exec(ctx context.Context) error {
   561  	_, err := fuo.Save(ctx)
   562  	return err
   563  }
   564  
   565  // ExecX is like Exec, but panics if an error occurs.
   566  func (fuo *FiatUpdateOne) ExecX(ctx context.Context) {
   567  	if err := fuo.Exec(ctx); err != nil {
   568  		panic(err)
   569  	}
   570  }
   571  
   572  // defaults sets the default values of the builder before save.
   573  func (fuo *FiatUpdateOne) defaults() error {
   574  	if _, ok := fuo.mutation.UpdatedAt(); !ok {
   575  		if fiat.UpdateDefaultUpdatedAt == nil {
   576  			return fmt.Errorf("ent: uninitialized fiat.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
   577  		}
   578  		v := fiat.UpdateDefaultUpdatedAt()
   579  		fuo.mutation.SetUpdatedAt(v)
   580  	}
   581  	return nil
   582  }
   583  
   584  // Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
   585  func (fuo *FiatUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *FiatUpdateOne {
   586  	fuo.modifiers = append(fuo.modifiers, modifiers...)
   587  	return fuo
   588  }
   589  
   590  func (fuo *FiatUpdateOne) sqlSave(ctx context.Context) (_node *Fiat, err error) {
   591  	_spec := &sqlgraph.UpdateSpec{
   592  		Node: &sqlgraph.NodeSpec{
   593  			Table:   fiat.Table,
   594  			Columns: fiat.Columns,
   595  			ID: &sqlgraph.FieldSpec{
   596  				Type:   field.TypeUint32,
   597  				Column: fiat.FieldID,
   598  			},
   599  		},
   600  	}
   601  	id, ok := fuo.mutation.ID()
   602  	if !ok {
   603  		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Fiat.id" for update`)}
   604  	}
   605  	_spec.Node.ID.Value = id
   606  	if fields := fuo.fields; len(fields) > 0 {
   607  		_spec.Node.Columns = make([]string, 0, len(fields))
   608  		_spec.Node.Columns = append(_spec.Node.Columns, fiat.FieldID)
   609  		for _, f := range fields {
   610  			if !fiat.ValidColumn(f) {
   611  				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
   612  			}
   613  			if f != fiat.FieldID {
   614  				_spec.Node.Columns = append(_spec.Node.Columns, f)
   615  			}
   616  		}
   617  	}
   618  	if ps := fuo.mutation.predicates; len(ps) > 0 {
   619  		_spec.Predicate = func(selector *sql.Selector) {
   620  			for i := range ps {
   621  				ps[i](selector)
   622  			}
   623  		}
   624  	}
   625  	if value, ok := fuo.mutation.CreatedAt(); ok {
   626  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   627  			Type:   field.TypeUint32,
   628  			Value:  value,
   629  			Column: fiat.FieldCreatedAt,
   630  		})
   631  	}
   632  	if value, ok := fuo.mutation.AddedCreatedAt(); ok {
   633  		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
   634  			Type:   field.TypeUint32,
   635  			Value:  value,
   636  			Column: fiat.FieldCreatedAt,
   637  		})
   638  	}
   639  	if value, ok := fuo.mutation.UpdatedAt(); ok {
   640  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   641  			Type:   field.TypeUint32,
   642  			Value:  value,
   643  			Column: fiat.FieldUpdatedAt,
   644  		})
   645  	}
   646  	if value, ok := fuo.mutation.AddedUpdatedAt(); ok {
   647  		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
   648  			Type:   field.TypeUint32,
   649  			Value:  value,
   650  			Column: fiat.FieldUpdatedAt,
   651  		})
   652  	}
   653  	if value, ok := fuo.mutation.DeletedAt(); ok {
   654  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   655  			Type:   field.TypeUint32,
   656  			Value:  value,
   657  			Column: fiat.FieldDeletedAt,
   658  		})
   659  	}
   660  	if value, ok := fuo.mutation.AddedDeletedAt(); ok {
   661  		_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
   662  			Type:   field.TypeUint32,
   663  			Value:  value,
   664  			Column: fiat.FieldDeletedAt,
   665  		})
   666  	}
   667  	if value, ok := fuo.mutation.EntID(); ok {
   668  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   669  			Type:   field.TypeUUID,
   670  			Value:  value,
   671  			Column: fiat.FieldEntID,
   672  		})
   673  	}
   674  	if value, ok := fuo.mutation.Name(); ok {
   675  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   676  			Type:   field.TypeString,
   677  			Value:  value,
   678  			Column: fiat.FieldName,
   679  		})
   680  	}
   681  	if fuo.mutation.NameCleared() {
   682  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   683  			Type:   field.TypeString,
   684  			Column: fiat.FieldName,
   685  		})
   686  	}
   687  	if value, ok := fuo.mutation.Logo(); ok {
   688  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   689  			Type:   field.TypeString,
   690  			Value:  value,
   691  			Column: fiat.FieldLogo,
   692  		})
   693  	}
   694  	if fuo.mutation.LogoCleared() {
   695  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   696  			Type:   field.TypeString,
   697  			Column: fiat.FieldLogo,
   698  		})
   699  	}
   700  	if value, ok := fuo.mutation.Unit(); ok {
   701  		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
   702  			Type:   field.TypeString,
   703  			Value:  value,
   704  			Column: fiat.FieldUnit,
   705  		})
   706  	}
   707  	if fuo.mutation.UnitCleared() {
   708  		_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
   709  			Type:   field.TypeString,
   710  			Column: fiat.FieldUnit,
   711  		})
   712  	}
   713  	_spec.Modifiers = fuo.modifiers
   714  	_node = &Fiat{config: fuo.config}
   715  	_spec.Assign = _node.assignValues
   716  	_spec.ScanValues = _node.scanValues
   717  	if err = sqlgraph.UpdateNode(ctx, fuo.driver, _spec); err != nil {
   718  		if _, ok := err.(*sqlgraph.NotFoundError); ok {
   719  			err = &NotFoundError{fiat.Label}
   720  		} else if sqlgraph.IsConstraintError(err) {
   721  			err = &ConstraintError{msg: err.Error(), wrap: err}
   722  		}
   723  		return nil, err
   724  	}
   725  	return _node, nil
   726  }