// Code generated by ent, DO NOT EDIT. package ent import ( "context" "epic-ent/internal/ent/epicartifactinfo" "epic-ent/internal/ent/predicate" "errors" "fmt" "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // EpicArtifactInfoUpdate is the builder for updating EpicArtifactInfo entities. type EpicArtifactInfoUpdate struct { config hooks []Hook mutation *EpicArtifactInfoMutation } // Where appends a list predicates to the EpicArtifactInfoUpdate builder. func (_u *EpicArtifactInfoUpdate) Where(ps ...predicate.EpicArtifactInfo) *EpicArtifactInfoUpdate { _u.mutation.Where(ps...) return _u } // SetArtifactName sets the "artifact_name" field. func (_u *EpicArtifactInfoUpdate) SetArtifactName(v string) *EpicArtifactInfoUpdate { _u.mutation.SetArtifactName(v) return _u } // SetNillableArtifactName sets the "artifact_name" field if the given value is not nil. func (_u *EpicArtifactInfoUpdate) SetNillableArtifactName(v *string) *EpicArtifactInfoUpdate { if v != nil { _u.SetArtifactName(*v) } return _u } // SetArtifactCode sets the "artifact_code" field. func (_u *EpicArtifactInfoUpdate) SetArtifactCode(v string) *EpicArtifactInfoUpdate { _u.mutation.SetArtifactCode(v) return _u } // SetNillableArtifactCode sets the "artifact_code" field if the given value is not nil. func (_u *EpicArtifactInfoUpdate) SetNillableArtifactCode(v *string) *EpicArtifactInfoUpdate { if v != nil { _u.SetArtifactCode(*v) } return _u } // SetCreator sets the "creator" field. func (_u *EpicArtifactInfoUpdate) SetCreator(v string) *EpicArtifactInfoUpdate { _u.mutation.SetCreator(v) return _u } // SetNillableCreator sets the "creator" field if the given value is not nil. func (_u *EpicArtifactInfoUpdate) SetNillableCreator(v *string) *EpicArtifactInfoUpdate { if v != nil { _u.SetCreator(*v) } return _u } // SetCreateTime sets the "create_time" field. func (_u *EpicArtifactInfoUpdate) SetCreateTime(v time.Time) *EpicArtifactInfoUpdate { _u.mutation.SetCreateTime(v) return _u } // SetNillableCreateTime sets the "create_time" field if the given value is not nil. func (_u *EpicArtifactInfoUpdate) SetNillableCreateTime(v *time.Time) *EpicArtifactInfoUpdate { if v != nil { _u.SetCreateTime(*v) } return _u } // ClearCreateTime clears the value of the "create_time" field. func (_u *EpicArtifactInfoUpdate) ClearCreateTime() *EpicArtifactInfoUpdate { _u.mutation.ClearCreateTime() return _u } // SetUpdater sets the "updater" field. func (_u *EpicArtifactInfoUpdate) SetUpdater(v string) *EpicArtifactInfoUpdate { _u.mutation.SetUpdater(v) return _u } // SetNillableUpdater sets the "updater" field if the given value is not nil. func (_u *EpicArtifactInfoUpdate) SetNillableUpdater(v *string) *EpicArtifactInfoUpdate { if v != nil { _u.SetUpdater(*v) } return _u } // SetUpdateTime sets the "update_time" field. func (_u *EpicArtifactInfoUpdate) SetUpdateTime(v time.Time) *EpicArtifactInfoUpdate { _u.mutation.SetUpdateTime(v) return _u } // SetNillableUpdateTime sets the "update_time" field if the given value is not nil. func (_u *EpicArtifactInfoUpdate) SetNillableUpdateTime(v *time.Time) *EpicArtifactInfoUpdate { if v != nil { _u.SetUpdateTime(*v) } return _u } // ClearUpdateTime clears the value of the "update_time" field. func (_u *EpicArtifactInfoUpdate) ClearUpdateTime() *EpicArtifactInfoUpdate { _u.mutation.ClearUpdateTime() return _u } // SetDeleted sets the "deleted" field. func (_u *EpicArtifactInfoUpdate) SetDeleted(v bool) *EpicArtifactInfoUpdate { _u.mutation.SetDeleted(v) return _u } // SetNillableDeleted sets the "deleted" field if the given value is not nil. func (_u *EpicArtifactInfoUpdate) SetNillableDeleted(v *bool) *EpicArtifactInfoUpdate { if v != nil { _u.SetDeleted(*v) } return _u } // SetStatsHealth sets the "stats_health" field. func (_u *EpicArtifactInfoUpdate) SetStatsHealth(v int) *EpicArtifactInfoUpdate { _u.mutation.ResetStatsHealth() _u.mutation.SetStatsHealth(v) return _u } // SetNillableStatsHealth sets the "stats_health" field if the given value is not nil. func (_u *EpicArtifactInfoUpdate) SetNillableStatsHealth(v *int) *EpicArtifactInfoUpdate { if v != nil { _u.SetStatsHealth(*v) } return _u } // AddStatsHealth adds value to the "stats_health" field. func (_u *EpicArtifactInfoUpdate) AddStatsHealth(v int) *EpicArtifactInfoUpdate { _u.mutation.AddStatsHealth(v) return _u } // SetStatsAttack sets the "stats_attack" field. func (_u *EpicArtifactInfoUpdate) SetStatsAttack(v int) *EpicArtifactInfoUpdate { _u.mutation.ResetStatsAttack() _u.mutation.SetStatsAttack(v) return _u } // SetNillableStatsAttack sets the "stats_attack" field if the given value is not nil. func (_u *EpicArtifactInfoUpdate) SetNillableStatsAttack(v *int) *EpicArtifactInfoUpdate { if v != nil { _u.SetStatsAttack(*v) } return _u } // AddStatsAttack adds value to the "stats_attack" field. func (_u *EpicArtifactInfoUpdate) AddStatsAttack(v int) *EpicArtifactInfoUpdate { _u.mutation.AddStatsAttack(v) return _u } // SetStatsDefense sets the "stats_defense" field. func (_u *EpicArtifactInfoUpdate) SetStatsDefense(v int) *EpicArtifactInfoUpdate { _u.mutation.ResetStatsDefense() _u.mutation.SetStatsDefense(v) return _u } // SetNillableStatsDefense sets the "stats_defense" field if the given value is not nil. func (_u *EpicArtifactInfoUpdate) SetNillableStatsDefense(v *int) *EpicArtifactInfoUpdate { if v != nil { _u.SetStatsDefense(*v) } return _u } // AddStatsDefense adds value to the "stats_defense" field. func (_u *EpicArtifactInfoUpdate) AddStatsDefense(v int) *EpicArtifactInfoUpdate { _u.mutation.AddStatsDefense(v) return _u } // SetRarity sets the "rarity" field. func (_u *EpicArtifactInfoUpdate) SetRarity(v string) *EpicArtifactInfoUpdate { _u.mutation.SetRarity(v) return _u } // SetNillableRarity sets the "rarity" field if the given value is not nil. func (_u *EpicArtifactInfoUpdate) SetNillableRarity(v *string) *EpicArtifactInfoUpdate { if v != nil { _u.SetRarity(*v) } return _u } // SetRole sets the "role" field. func (_u *EpicArtifactInfoUpdate) SetRole(v string) *EpicArtifactInfoUpdate { _u.mutation.SetRole(v) return _u } // SetNillableRole sets the "role" field if the given value is not nil. func (_u *EpicArtifactInfoUpdate) SetNillableRole(v *string) *EpicArtifactInfoUpdate { if v != nil { _u.SetRole(*v) } return _u } // SetArtifactNameEn sets the "artifact_name_en" field. func (_u *EpicArtifactInfoUpdate) SetArtifactNameEn(v string) *EpicArtifactInfoUpdate { _u.mutation.SetArtifactNameEn(v) return _u } // SetNillableArtifactNameEn sets the "artifact_name_en" field if the given value is not nil. func (_u *EpicArtifactInfoUpdate) SetNillableArtifactNameEn(v *string) *EpicArtifactInfoUpdate { if v != nil { _u.SetArtifactNameEn(*v) } return _u } // SetImageURL sets the "image_url" field. func (_u *EpicArtifactInfoUpdate) SetImageURL(v string) *EpicArtifactInfoUpdate { _u.mutation.SetImageURL(v) return _u } // SetNillableImageURL sets the "image_url" field if the given value is not nil. func (_u *EpicArtifactInfoUpdate) SetNillableImageURL(v *string) *EpicArtifactInfoUpdate { if v != nil { _u.SetImageURL(*v) } return _u } // Mutation returns the EpicArtifactInfoMutation object of the builder. func (_u *EpicArtifactInfoUpdate) Mutation() *EpicArtifactInfoMutation { return _u.mutation } // Save executes the query and returns the number of nodes affected by the update operation. func (_u *EpicArtifactInfoUpdate) Save(ctx context.Context) (int, error) { return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. func (_u *EpicArtifactInfoUpdate) SaveX(ctx context.Context) int { affected, err := _u.Save(ctx) if err != nil { panic(err) } return affected } // Exec executes the query. func (_u *EpicArtifactInfoUpdate) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_u *EpicArtifactInfoUpdate) ExecX(ctx context.Context) { if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. func (_u *EpicArtifactInfoUpdate) check() error { if v, ok := _u.mutation.ArtifactName(); ok { if err := epicartifactinfo.ArtifactNameValidator(v); err != nil { return &ValidationError{Name: "artifact_name", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.artifact_name": %w`, err)} } } if v, ok := _u.mutation.ArtifactCode(); ok { if err := epicartifactinfo.ArtifactCodeValidator(v); err != nil { return &ValidationError{Name: "artifact_code", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.artifact_code": %w`, err)} } } if v, ok := _u.mutation.Creator(); ok { if err := epicartifactinfo.CreatorValidator(v); err != nil { return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.creator": %w`, err)} } } if v, ok := _u.mutation.Updater(); ok { if err := epicartifactinfo.UpdaterValidator(v); err != nil { return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.updater": %w`, err)} } } if v, ok := _u.mutation.Rarity(); ok { if err := epicartifactinfo.RarityValidator(v); err != nil { return &ValidationError{Name: "rarity", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.rarity": %w`, err)} } } if v, ok := _u.mutation.Role(); ok { if err := epicartifactinfo.RoleValidator(v); err != nil { return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.role": %w`, err)} } } if v, ok := _u.mutation.ArtifactNameEn(); ok { if err := epicartifactinfo.ArtifactNameEnValidator(v); err != nil { return &ValidationError{Name: "artifact_name_en", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.artifact_name_en": %w`, err)} } } if v, ok := _u.mutation.ImageURL(); ok { if err := epicartifactinfo.ImageURLValidator(v); err != nil { return &ValidationError{Name: "image_url", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.image_url": %w`, err)} } } return nil } func (_u *EpicArtifactInfoUpdate) sqlSave(ctx context.Context) (_node int, err error) { if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(epicartifactinfo.Table, epicartifactinfo.Columns, sqlgraph.NewFieldSpec(epicartifactinfo.FieldID, field.TypeInt64)) if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if value, ok := _u.mutation.ArtifactName(); ok { _spec.SetField(epicartifactinfo.FieldArtifactName, field.TypeString, value) } if value, ok := _u.mutation.ArtifactCode(); ok { _spec.SetField(epicartifactinfo.FieldArtifactCode, field.TypeString, value) } if value, ok := _u.mutation.Creator(); ok { _spec.SetField(epicartifactinfo.FieldCreator, field.TypeString, value) } if value, ok := _u.mutation.CreateTime(); ok { _spec.SetField(epicartifactinfo.FieldCreateTime, field.TypeTime, value) } if _u.mutation.CreateTimeCleared() { _spec.ClearField(epicartifactinfo.FieldCreateTime, field.TypeTime) } if value, ok := _u.mutation.Updater(); ok { _spec.SetField(epicartifactinfo.FieldUpdater, field.TypeString, value) } if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(epicartifactinfo.FieldUpdateTime, field.TypeTime, value) } if _u.mutation.UpdateTimeCleared() { _spec.ClearField(epicartifactinfo.FieldUpdateTime, field.TypeTime) } if value, ok := _u.mutation.Deleted(); ok { _spec.SetField(epicartifactinfo.FieldDeleted, field.TypeBool, value) } if value, ok := _u.mutation.StatsHealth(); ok { _spec.SetField(epicartifactinfo.FieldStatsHealth, field.TypeInt, value) } if value, ok := _u.mutation.AddedStatsHealth(); ok { _spec.AddField(epicartifactinfo.FieldStatsHealth, field.TypeInt, value) } if value, ok := _u.mutation.StatsAttack(); ok { _spec.SetField(epicartifactinfo.FieldStatsAttack, field.TypeInt, value) } if value, ok := _u.mutation.AddedStatsAttack(); ok { _spec.AddField(epicartifactinfo.FieldStatsAttack, field.TypeInt, value) } if value, ok := _u.mutation.StatsDefense(); ok { _spec.SetField(epicartifactinfo.FieldStatsDefense, field.TypeInt, value) } if value, ok := _u.mutation.AddedStatsDefense(); ok { _spec.AddField(epicartifactinfo.FieldStatsDefense, field.TypeInt, value) } if value, ok := _u.mutation.Rarity(); ok { _spec.SetField(epicartifactinfo.FieldRarity, field.TypeString, value) } if value, ok := _u.mutation.Role(); ok { _spec.SetField(epicartifactinfo.FieldRole, field.TypeString, value) } if value, ok := _u.mutation.ArtifactNameEn(); ok { _spec.SetField(epicartifactinfo.FieldArtifactNameEn, field.TypeString, value) } if value, ok := _u.mutation.ImageURL(); ok { _spec.SetField(epicartifactinfo.FieldImageURL, field.TypeString, value) } if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{epicartifactinfo.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return 0, err } _u.mutation.done = true return _node, nil } // EpicArtifactInfoUpdateOne is the builder for updating a single EpicArtifactInfo entity. type EpicArtifactInfoUpdateOne struct { config fields []string hooks []Hook mutation *EpicArtifactInfoMutation } // SetArtifactName sets the "artifact_name" field. func (_u *EpicArtifactInfoUpdateOne) SetArtifactName(v string) *EpicArtifactInfoUpdateOne { _u.mutation.SetArtifactName(v) return _u } // SetNillableArtifactName sets the "artifact_name" field if the given value is not nil. func (_u *EpicArtifactInfoUpdateOne) SetNillableArtifactName(v *string) *EpicArtifactInfoUpdateOne { if v != nil { _u.SetArtifactName(*v) } return _u } // SetArtifactCode sets the "artifact_code" field. func (_u *EpicArtifactInfoUpdateOne) SetArtifactCode(v string) *EpicArtifactInfoUpdateOne { _u.mutation.SetArtifactCode(v) return _u } // SetNillableArtifactCode sets the "artifact_code" field if the given value is not nil. func (_u *EpicArtifactInfoUpdateOne) SetNillableArtifactCode(v *string) *EpicArtifactInfoUpdateOne { if v != nil { _u.SetArtifactCode(*v) } return _u } // SetCreator sets the "creator" field. func (_u *EpicArtifactInfoUpdateOne) SetCreator(v string) *EpicArtifactInfoUpdateOne { _u.mutation.SetCreator(v) return _u } // SetNillableCreator sets the "creator" field if the given value is not nil. func (_u *EpicArtifactInfoUpdateOne) SetNillableCreator(v *string) *EpicArtifactInfoUpdateOne { if v != nil { _u.SetCreator(*v) } return _u } // SetCreateTime sets the "create_time" field. func (_u *EpicArtifactInfoUpdateOne) SetCreateTime(v time.Time) *EpicArtifactInfoUpdateOne { _u.mutation.SetCreateTime(v) return _u } // SetNillableCreateTime sets the "create_time" field if the given value is not nil. func (_u *EpicArtifactInfoUpdateOne) SetNillableCreateTime(v *time.Time) *EpicArtifactInfoUpdateOne { if v != nil { _u.SetCreateTime(*v) } return _u } // ClearCreateTime clears the value of the "create_time" field. func (_u *EpicArtifactInfoUpdateOne) ClearCreateTime() *EpicArtifactInfoUpdateOne { _u.mutation.ClearCreateTime() return _u } // SetUpdater sets the "updater" field. func (_u *EpicArtifactInfoUpdateOne) SetUpdater(v string) *EpicArtifactInfoUpdateOne { _u.mutation.SetUpdater(v) return _u } // SetNillableUpdater sets the "updater" field if the given value is not nil. func (_u *EpicArtifactInfoUpdateOne) SetNillableUpdater(v *string) *EpicArtifactInfoUpdateOne { if v != nil { _u.SetUpdater(*v) } return _u } // SetUpdateTime sets the "update_time" field. func (_u *EpicArtifactInfoUpdateOne) SetUpdateTime(v time.Time) *EpicArtifactInfoUpdateOne { _u.mutation.SetUpdateTime(v) return _u } // SetNillableUpdateTime sets the "update_time" field if the given value is not nil. func (_u *EpicArtifactInfoUpdateOne) SetNillableUpdateTime(v *time.Time) *EpicArtifactInfoUpdateOne { if v != nil { _u.SetUpdateTime(*v) } return _u } // ClearUpdateTime clears the value of the "update_time" field. func (_u *EpicArtifactInfoUpdateOne) ClearUpdateTime() *EpicArtifactInfoUpdateOne { _u.mutation.ClearUpdateTime() return _u } // SetDeleted sets the "deleted" field. func (_u *EpicArtifactInfoUpdateOne) SetDeleted(v bool) *EpicArtifactInfoUpdateOne { _u.mutation.SetDeleted(v) return _u } // SetNillableDeleted sets the "deleted" field if the given value is not nil. func (_u *EpicArtifactInfoUpdateOne) SetNillableDeleted(v *bool) *EpicArtifactInfoUpdateOne { if v != nil { _u.SetDeleted(*v) } return _u } // SetStatsHealth sets the "stats_health" field. func (_u *EpicArtifactInfoUpdateOne) SetStatsHealth(v int) *EpicArtifactInfoUpdateOne { _u.mutation.ResetStatsHealth() _u.mutation.SetStatsHealth(v) return _u } // SetNillableStatsHealth sets the "stats_health" field if the given value is not nil. func (_u *EpicArtifactInfoUpdateOne) SetNillableStatsHealth(v *int) *EpicArtifactInfoUpdateOne { if v != nil { _u.SetStatsHealth(*v) } return _u } // AddStatsHealth adds value to the "stats_health" field. func (_u *EpicArtifactInfoUpdateOne) AddStatsHealth(v int) *EpicArtifactInfoUpdateOne { _u.mutation.AddStatsHealth(v) return _u } // SetStatsAttack sets the "stats_attack" field. func (_u *EpicArtifactInfoUpdateOne) SetStatsAttack(v int) *EpicArtifactInfoUpdateOne { _u.mutation.ResetStatsAttack() _u.mutation.SetStatsAttack(v) return _u } // SetNillableStatsAttack sets the "stats_attack" field if the given value is not nil. func (_u *EpicArtifactInfoUpdateOne) SetNillableStatsAttack(v *int) *EpicArtifactInfoUpdateOne { if v != nil { _u.SetStatsAttack(*v) } return _u } // AddStatsAttack adds value to the "stats_attack" field. func (_u *EpicArtifactInfoUpdateOne) AddStatsAttack(v int) *EpicArtifactInfoUpdateOne { _u.mutation.AddStatsAttack(v) return _u } // SetStatsDefense sets the "stats_defense" field. func (_u *EpicArtifactInfoUpdateOne) SetStatsDefense(v int) *EpicArtifactInfoUpdateOne { _u.mutation.ResetStatsDefense() _u.mutation.SetStatsDefense(v) return _u } // SetNillableStatsDefense sets the "stats_defense" field if the given value is not nil. func (_u *EpicArtifactInfoUpdateOne) SetNillableStatsDefense(v *int) *EpicArtifactInfoUpdateOne { if v != nil { _u.SetStatsDefense(*v) } return _u } // AddStatsDefense adds value to the "stats_defense" field. func (_u *EpicArtifactInfoUpdateOne) AddStatsDefense(v int) *EpicArtifactInfoUpdateOne { _u.mutation.AddStatsDefense(v) return _u } // SetRarity sets the "rarity" field. func (_u *EpicArtifactInfoUpdateOne) SetRarity(v string) *EpicArtifactInfoUpdateOne { _u.mutation.SetRarity(v) return _u } // SetNillableRarity sets the "rarity" field if the given value is not nil. func (_u *EpicArtifactInfoUpdateOne) SetNillableRarity(v *string) *EpicArtifactInfoUpdateOne { if v != nil { _u.SetRarity(*v) } return _u } // SetRole sets the "role" field. func (_u *EpicArtifactInfoUpdateOne) SetRole(v string) *EpicArtifactInfoUpdateOne { _u.mutation.SetRole(v) return _u } // SetNillableRole sets the "role" field if the given value is not nil. func (_u *EpicArtifactInfoUpdateOne) SetNillableRole(v *string) *EpicArtifactInfoUpdateOne { if v != nil { _u.SetRole(*v) } return _u } // SetArtifactNameEn sets the "artifact_name_en" field. func (_u *EpicArtifactInfoUpdateOne) SetArtifactNameEn(v string) *EpicArtifactInfoUpdateOne { _u.mutation.SetArtifactNameEn(v) return _u } // SetNillableArtifactNameEn sets the "artifact_name_en" field if the given value is not nil. func (_u *EpicArtifactInfoUpdateOne) SetNillableArtifactNameEn(v *string) *EpicArtifactInfoUpdateOne { if v != nil { _u.SetArtifactNameEn(*v) } return _u } // SetImageURL sets the "image_url" field. func (_u *EpicArtifactInfoUpdateOne) SetImageURL(v string) *EpicArtifactInfoUpdateOne { _u.mutation.SetImageURL(v) return _u } // SetNillableImageURL sets the "image_url" field if the given value is not nil. func (_u *EpicArtifactInfoUpdateOne) SetNillableImageURL(v *string) *EpicArtifactInfoUpdateOne { if v != nil { _u.SetImageURL(*v) } return _u } // Mutation returns the EpicArtifactInfoMutation object of the builder. func (_u *EpicArtifactInfoUpdateOne) Mutation() *EpicArtifactInfoMutation { return _u.mutation } // Where appends a list predicates to the EpicArtifactInfoUpdate builder. func (_u *EpicArtifactInfoUpdateOne) Where(ps ...predicate.EpicArtifactInfo) *EpicArtifactInfoUpdateOne { _u.mutation.Where(ps...) return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. func (_u *EpicArtifactInfoUpdateOne) Select(field string, fields ...string) *EpicArtifactInfoUpdateOne { _u.fields = append([]string{field}, fields...) return _u } // Save executes the query and returns the updated EpicArtifactInfo entity. func (_u *EpicArtifactInfoUpdateOne) Save(ctx context.Context) (*EpicArtifactInfo, error) { return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. func (_u *EpicArtifactInfoUpdateOne) SaveX(ctx context.Context) *EpicArtifactInfo { node, err := _u.Save(ctx) if err != nil { panic(err) } return node } // Exec executes the query on the entity. func (_u *EpicArtifactInfoUpdateOne) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_u *EpicArtifactInfoUpdateOne) ExecX(ctx context.Context) { if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. func (_u *EpicArtifactInfoUpdateOne) check() error { if v, ok := _u.mutation.ArtifactName(); ok { if err := epicartifactinfo.ArtifactNameValidator(v); err != nil { return &ValidationError{Name: "artifact_name", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.artifact_name": %w`, err)} } } if v, ok := _u.mutation.ArtifactCode(); ok { if err := epicartifactinfo.ArtifactCodeValidator(v); err != nil { return &ValidationError{Name: "artifact_code", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.artifact_code": %w`, err)} } } if v, ok := _u.mutation.Creator(); ok { if err := epicartifactinfo.CreatorValidator(v); err != nil { return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.creator": %w`, err)} } } if v, ok := _u.mutation.Updater(); ok { if err := epicartifactinfo.UpdaterValidator(v); err != nil { return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.updater": %w`, err)} } } if v, ok := _u.mutation.Rarity(); ok { if err := epicartifactinfo.RarityValidator(v); err != nil { return &ValidationError{Name: "rarity", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.rarity": %w`, err)} } } if v, ok := _u.mutation.Role(); ok { if err := epicartifactinfo.RoleValidator(v); err != nil { return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.role": %w`, err)} } } if v, ok := _u.mutation.ArtifactNameEn(); ok { if err := epicartifactinfo.ArtifactNameEnValidator(v); err != nil { return &ValidationError{Name: "artifact_name_en", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.artifact_name_en": %w`, err)} } } if v, ok := _u.mutation.ImageURL(); ok { if err := epicartifactinfo.ImageURLValidator(v); err != nil { return &ValidationError{Name: "image_url", err: fmt.Errorf(`ent: validator failed for field "EpicArtifactInfo.image_url": %w`, err)} } } return nil } func (_u *EpicArtifactInfoUpdateOne) sqlSave(ctx context.Context) (_node *EpicArtifactInfo, err error) { if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(epicartifactinfo.Table, epicartifactinfo.Columns, sqlgraph.NewFieldSpec(epicartifactinfo.FieldID, field.TypeInt64)) id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EpicArtifactInfo.id" for update`)} } _spec.Node.ID.Value = id if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, epicartifactinfo.FieldID) for _, f := range fields { if !epicartifactinfo.ValidColumn(f) { return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } if f != epicartifactinfo.FieldID { _spec.Node.Columns = append(_spec.Node.Columns, f) } } } if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if value, ok := _u.mutation.ArtifactName(); ok { _spec.SetField(epicartifactinfo.FieldArtifactName, field.TypeString, value) } if value, ok := _u.mutation.ArtifactCode(); ok { _spec.SetField(epicartifactinfo.FieldArtifactCode, field.TypeString, value) } if value, ok := _u.mutation.Creator(); ok { _spec.SetField(epicartifactinfo.FieldCreator, field.TypeString, value) } if value, ok := _u.mutation.CreateTime(); ok { _spec.SetField(epicartifactinfo.FieldCreateTime, field.TypeTime, value) } if _u.mutation.CreateTimeCleared() { _spec.ClearField(epicartifactinfo.FieldCreateTime, field.TypeTime) } if value, ok := _u.mutation.Updater(); ok { _spec.SetField(epicartifactinfo.FieldUpdater, field.TypeString, value) } if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(epicartifactinfo.FieldUpdateTime, field.TypeTime, value) } if _u.mutation.UpdateTimeCleared() { _spec.ClearField(epicartifactinfo.FieldUpdateTime, field.TypeTime) } if value, ok := _u.mutation.Deleted(); ok { _spec.SetField(epicartifactinfo.FieldDeleted, field.TypeBool, value) } if value, ok := _u.mutation.StatsHealth(); ok { _spec.SetField(epicartifactinfo.FieldStatsHealth, field.TypeInt, value) } if value, ok := _u.mutation.AddedStatsHealth(); ok { _spec.AddField(epicartifactinfo.FieldStatsHealth, field.TypeInt, value) } if value, ok := _u.mutation.StatsAttack(); ok { _spec.SetField(epicartifactinfo.FieldStatsAttack, field.TypeInt, value) } if value, ok := _u.mutation.AddedStatsAttack(); ok { _spec.AddField(epicartifactinfo.FieldStatsAttack, field.TypeInt, value) } if value, ok := _u.mutation.StatsDefense(); ok { _spec.SetField(epicartifactinfo.FieldStatsDefense, field.TypeInt, value) } if value, ok := _u.mutation.AddedStatsDefense(); ok { _spec.AddField(epicartifactinfo.FieldStatsDefense, field.TypeInt, value) } if value, ok := _u.mutation.Rarity(); ok { _spec.SetField(epicartifactinfo.FieldRarity, field.TypeString, value) } if value, ok := _u.mutation.Role(); ok { _spec.SetField(epicartifactinfo.FieldRole, field.TypeString, value) } if value, ok := _u.mutation.ArtifactNameEn(); ok { _spec.SetField(epicartifactinfo.FieldArtifactNameEn, field.TypeString, value) } if value, ok := _u.mutation.ImageURL(); ok { _spec.SetField(epicartifactinfo.FieldImageURL, field.TypeString, value) } _node = &EpicArtifactInfo{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{epicartifactinfo.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return nil, err } _u.mutation.done = true return _node, nil }