713 lines
22 KiB
Go
713 lines
22 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"epic-ent/internal/ent/epici18nmappings"
|
|
"epic-ent/internal/ent/predicate"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// EpicI18NMappingsUpdate is the builder for updating EpicI18NMappings entities.
|
|
type EpicI18NMappingsUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *EpicI18NMappingsMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the EpicI18NMappingsUpdate builder.
|
|
func (_u *EpicI18NMappingsUpdate) Where(ps ...predicate.EpicI18NMappings) *EpicI18NMappingsUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetKeyName sets the "key_name" field.
|
|
func (_u *EpicI18NMappingsUpdate) SetKeyName(v string) *EpicI18NMappingsUpdate {
|
|
_u.mutation.SetKeyName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableKeyName sets the "key_name" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdate) SetNillableKeyName(v *string) *EpicI18NMappingsUpdate {
|
|
if v != nil {
|
|
_u.SetKeyName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetLanguage sets the "language" field.
|
|
func (_u *EpicI18NMappingsUpdate) SetLanguage(v string) *EpicI18NMappingsUpdate {
|
|
_u.mutation.SetLanguage(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLanguage sets the "language" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdate) SetNillableLanguage(v *string) *EpicI18NMappingsUpdate {
|
|
if v != nil {
|
|
_u.SetLanguage(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetValue sets the "value" field.
|
|
func (_u *EpicI18NMappingsUpdate) SetValue(v string) *EpicI18NMappingsUpdate {
|
|
_u.mutation.SetValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableValue sets the "value" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdate) SetNillableValue(v *string) *EpicI18NMappingsUpdate {
|
|
if v != nil {
|
|
_u.SetValue(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCategory sets the "category" field.
|
|
func (_u *EpicI18NMappingsUpdate) SetCategory(v string) *EpicI18NMappingsUpdate {
|
|
_u.mutation.SetCategory(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCategory sets the "category" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdate) SetNillableCategory(v *string) *EpicI18NMappingsUpdate {
|
|
if v != nil {
|
|
_u.SetCategory(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_u *EpicI18NMappingsUpdate) SetStatus(v int) *EpicI18NMappingsUpdate {
|
|
_u.mutation.ResetStatus()
|
|
_u.mutation.SetStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdate) SetNillableStatus(v *int) *EpicI18NMappingsUpdate {
|
|
if v != nil {
|
|
_u.SetStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddStatus adds value to the "status" field.
|
|
func (_u *EpicI18NMappingsUpdate) AddStatus(v int) *EpicI18NMappingsUpdate {
|
|
_u.mutation.AddStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetCreator sets the "creator" field.
|
|
func (_u *EpicI18NMappingsUpdate) SetCreator(v string) *EpicI18NMappingsUpdate {
|
|
_u.mutation.SetCreator(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreator sets the "creator" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdate) SetNillableCreator(v *string) *EpicI18NMappingsUpdate {
|
|
if v != nil {
|
|
_u.SetCreator(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCreateTime sets the "create_time" field.
|
|
func (_u *EpicI18NMappingsUpdate) SetCreateTime(v time.Time) *EpicI18NMappingsUpdate {
|
|
_u.mutation.SetCreateTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdate) SetNillableCreateTime(v *time.Time) *EpicI18NMappingsUpdate {
|
|
if v != nil {
|
|
_u.SetCreateTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearCreateTime clears the value of the "create_time" field.
|
|
func (_u *EpicI18NMappingsUpdate) ClearCreateTime() *EpicI18NMappingsUpdate {
|
|
_u.mutation.ClearCreateTime()
|
|
return _u
|
|
}
|
|
|
|
// SetUpdater sets the "updater" field.
|
|
func (_u *EpicI18NMappingsUpdate) SetUpdater(v string) *EpicI18NMappingsUpdate {
|
|
_u.mutation.SetUpdater(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdater sets the "updater" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdate) SetNillableUpdater(v *string) *EpicI18NMappingsUpdate {
|
|
if v != nil {
|
|
_u.SetUpdater(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdateTime sets the "update_time" field.
|
|
func (_u *EpicI18NMappingsUpdate) SetUpdateTime(v time.Time) *EpicI18NMappingsUpdate {
|
|
_u.mutation.SetUpdateTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdateTime sets the "update_time" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdate) SetNillableUpdateTime(v *time.Time) *EpicI18NMappingsUpdate {
|
|
if v != nil {
|
|
_u.SetUpdateTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearUpdateTime clears the value of the "update_time" field.
|
|
func (_u *EpicI18NMappingsUpdate) ClearUpdateTime() *EpicI18NMappingsUpdate {
|
|
_u.mutation.ClearUpdateTime()
|
|
return _u
|
|
}
|
|
|
|
// SetDeleted sets the "deleted" field.
|
|
func (_u *EpicI18NMappingsUpdate) SetDeleted(v int) *EpicI18NMappingsUpdate {
|
|
_u.mutation.ResetDeleted()
|
|
_u.mutation.SetDeleted(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdate) SetNillableDeleted(v *int) *EpicI18NMappingsUpdate {
|
|
if v != nil {
|
|
_u.SetDeleted(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddDeleted adds value to the "deleted" field.
|
|
func (_u *EpicI18NMappingsUpdate) AddDeleted(v int) *EpicI18NMappingsUpdate {
|
|
_u.mutation.AddDeleted(v)
|
|
return _u
|
|
}
|
|
|
|
// SetCode sets the "code" field.
|
|
func (_u *EpicI18NMappingsUpdate) SetCode(v string) *EpicI18NMappingsUpdate {
|
|
_u.mutation.SetCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCode sets the "code" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdate) SetNillableCode(v *string) *EpicI18NMappingsUpdate {
|
|
if v != nil {
|
|
_u.SetCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the EpicI18NMappingsMutation object of the builder.
|
|
func (_u *EpicI18NMappingsUpdate) Mutation() *EpicI18NMappingsMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *EpicI18NMappingsUpdate) 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 *EpicI18NMappingsUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *EpicI18NMappingsUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *EpicI18NMappingsUpdate) 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 *EpicI18NMappingsUpdate) check() error {
|
|
if v, ok := _u.mutation.KeyName(); ok {
|
|
if err := epici18nmappings.KeyNameValidator(v); err != nil {
|
|
return &ValidationError{Name: "key_name", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.key_name": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Language(); ok {
|
|
if err := epici18nmappings.LanguageValidator(v); err != nil {
|
|
return &ValidationError{Name: "language", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.language": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Value(); ok {
|
|
if err := epici18nmappings.ValueValidator(v); err != nil {
|
|
return &ValidationError{Name: "value", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.value": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Category(); ok {
|
|
if err := epici18nmappings.CategoryValidator(v); err != nil {
|
|
return &ValidationError{Name: "category", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.category": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Creator(); ok {
|
|
if err := epici18nmappings.CreatorValidator(v); err != nil {
|
|
return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.creator": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Updater(); ok {
|
|
if err := epici18nmappings.UpdaterValidator(v); err != nil {
|
|
return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.updater": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Code(); ok {
|
|
if err := epici18nmappings.CodeValidator(v); err != nil {
|
|
return &ValidationError{Name: "code", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.code": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *EpicI18NMappingsUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(epici18nmappings.Table, epici18nmappings.Columns, sqlgraph.NewFieldSpec(epici18nmappings.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.KeyName(); ok {
|
|
_spec.SetField(epici18nmappings.FieldKeyName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Language(); ok {
|
|
_spec.SetField(epici18nmappings.FieldLanguage, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Value(); ok {
|
|
_spec.SetField(epici18nmappings.FieldValue, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Category(); ok {
|
|
_spec.SetField(epici18nmappings.FieldCategory, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(epici18nmappings.FieldStatus, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedStatus(); ok {
|
|
_spec.AddField(epici18nmappings.FieldStatus, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.Creator(); ok {
|
|
_spec.SetField(epici18nmappings.FieldCreator, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.CreateTime(); ok {
|
|
_spec.SetField(epici18nmappings.FieldCreateTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.CreateTimeCleared() {
|
|
_spec.ClearField(epici18nmappings.FieldCreateTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Updater(); ok {
|
|
_spec.SetField(epici18nmappings.FieldUpdater, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdateTime(); ok {
|
|
_spec.SetField(epici18nmappings.FieldUpdateTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.UpdateTimeCleared() {
|
|
_spec.ClearField(epici18nmappings.FieldUpdateTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Deleted(); ok {
|
|
_spec.SetField(epici18nmappings.FieldDeleted, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedDeleted(); ok {
|
|
_spec.AddField(epici18nmappings.FieldDeleted, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.Code(); ok {
|
|
_spec.SetField(epici18nmappings.FieldCode, field.TypeString, value)
|
|
}
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{epici18nmappings.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// EpicI18NMappingsUpdateOne is the builder for updating a single EpicI18NMappings entity.
|
|
type EpicI18NMappingsUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *EpicI18NMappingsMutation
|
|
}
|
|
|
|
// SetKeyName sets the "key_name" field.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetKeyName(v string) *EpicI18NMappingsUpdateOne {
|
|
_u.mutation.SetKeyName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableKeyName sets the "key_name" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetNillableKeyName(v *string) *EpicI18NMappingsUpdateOne {
|
|
if v != nil {
|
|
_u.SetKeyName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetLanguage sets the "language" field.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetLanguage(v string) *EpicI18NMappingsUpdateOne {
|
|
_u.mutation.SetLanguage(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLanguage sets the "language" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetNillableLanguage(v *string) *EpicI18NMappingsUpdateOne {
|
|
if v != nil {
|
|
_u.SetLanguage(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetValue sets the "value" field.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetValue(v string) *EpicI18NMappingsUpdateOne {
|
|
_u.mutation.SetValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableValue sets the "value" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetNillableValue(v *string) *EpicI18NMappingsUpdateOne {
|
|
if v != nil {
|
|
_u.SetValue(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCategory sets the "category" field.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetCategory(v string) *EpicI18NMappingsUpdateOne {
|
|
_u.mutation.SetCategory(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCategory sets the "category" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetNillableCategory(v *string) *EpicI18NMappingsUpdateOne {
|
|
if v != nil {
|
|
_u.SetCategory(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetStatus(v int) *EpicI18NMappingsUpdateOne {
|
|
_u.mutation.ResetStatus()
|
|
_u.mutation.SetStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetNillableStatus(v *int) *EpicI18NMappingsUpdateOne {
|
|
if v != nil {
|
|
_u.SetStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddStatus adds value to the "status" field.
|
|
func (_u *EpicI18NMappingsUpdateOne) AddStatus(v int) *EpicI18NMappingsUpdateOne {
|
|
_u.mutation.AddStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetCreator sets the "creator" field.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetCreator(v string) *EpicI18NMappingsUpdateOne {
|
|
_u.mutation.SetCreator(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreator sets the "creator" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetNillableCreator(v *string) *EpicI18NMappingsUpdateOne {
|
|
if v != nil {
|
|
_u.SetCreator(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCreateTime sets the "create_time" field.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetCreateTime(v time.Time) *EpicI18NMappingsUpdateOne {
|
|
_u.mutation.SetCreateTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetNillableCreateTime(v *time.Time) *EpicI18NMappingsUpdateOne {
|
|
if v != nil {
|
|
_u.SetCreateTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearCreateTime clears the value of the "create_time" field.
|
|
func (_u *EpicI18NMappingsUpdateOne) ClearCreateTime() *EpicI18NMappingsUpdateOne {
|
|
_u.mutation.ClearCreateTime()
|
|
return _u
|
|
}
|
|
|
|
// SetUpdater sets the "updater" field.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetUpdater(v string) *EpicI18NMappingsUpdateOne {
|
|
_u.mutation.SetUpdater(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdater sets the "updater" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetNillableUpdater(v *string) *EpicI18NMappingsUpdateOne {
|
|
if v != nil {
|
|
_u.SetUpdater(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdateTime sets the "update_time" field.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetUpdateTime(v time.Time) *EpicI18NMappingsUpdateOne {
|
|
_u.mutation.SetUpdateTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdateTime sets the "update_time" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetNillableUpdateTime(v *time.Time) *EpicI18NMappingsUpdateOne {
|
|
if v != nil {
|
|
_u.SetUpdateTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearUpdateTime clears the value of the "update_time" field.
|
|
func (_u *EpicI18NMappingsUpdateOne) ClearUpdateTime() *EpicI18NMappingsUpdateOne {
|
|
_u.mutation.ClearUpdateTime()
|
|
return _u
|
|
}
|
|
|
|
// SetDeleted sets the "deleted" field.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetDeleted(v int) *EpicI18NMappingsUpdateOne {
|
|
_u.mutation.ResetDeleted()
|
|
_u.mutation.SetDeleted(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetNillableDeleted(v *int) *EpicI18NMappingsUpdateOne {
|
|
if v != nil {
|
|
_u.SetDeleted(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddDeleted adds value to the "deleted" field.
|
|
func (_u *EpicI18NMappingsUpdateOne) AddDeleted(v int) *EpicI18NMappingsUpdateOne {
|
|
_u.mutation.AddDeleted(v)
|
|
return _u
|
|
}
|
|
|
|
// SetCode sets the "code" field.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetCode(v string) *EpicI18NMappingsUpdateOne {
|
|
_u.mutation.SetCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCode sets the "code" field if the given value is not nil.
|
|
func (_u *EpicI18NMappingsUpdateOne) SetNillableCode(v *string) *EpicI18NMappingsUpdateOne {
|
|
if v != nil {
|
|
_u.SetCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the EpicI18NMappingsMutation object of the builder.
|
|
func (_u *EpicI18NMappingsUpdateOne) Mutation() *EpicI18NMappingsMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Where appends a list predicates to the EpicI18NMappingsUpdate builder.
|
|
func (_u *EpicI18NMappingsUpdateOne) Where(ps ...predicate.EpicI18NMappings) *EpicI18NMappingsUpdateOne {
|
|
_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 *EpicI18NMappingsUpdateOne) Select(field string, fields ...string) *EpicI18NMappingsUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated EpicI18NMappings entity.
|
|
func (_u *EpicI18NMappingsUpdateOne) Save(ctx context.Context) (*EpicI18NMappings, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *EpicI18NMappingsUpdateOne) SaveX(ctx context.Context) *EpicI18NMappings {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *EpicI18NMappingsUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *EpicI18NMappingsUpdateOne) 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 *EpicI18NMappingsUpdateOne) check() error {
|
|
if v, ok := _u.mutation.KeyName(); ok {
|
|
if err := epici18nmappings.KeyNameValidator(v); err != nil {
|
|
return &ValidationError{Name: "key_name", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.key_name": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Language(); ok {
|
|
if err := epici18nmappings.LanguageValidator(v); err != nil {
|
|
return &ValidationError{Name: "language", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.language": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Value(); ok {
|
|
if err := epici18nmappings.ValueValidator(v); err != nil {
|
|
return &ValidationError{Name: "value", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.value": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Category(); ok {
|
|
if err := epici18nmappings.CategoryValidator(v); err != nil {
|
|
return &ValidationError{Name: "category", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.category": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Creator(); ok {
|
|
if err := epici18nmappings.CreatorValidator(v); err != nil {
|
|
return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.creator": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Updater(); ok {
|
|
if err := epici18nmappings.UpdaterValidator(v); err != nil {
|
|
return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.updater": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Code(); ok {
|
|
if err := epici18nmappings.CodeValidator(v); err != nil {
|
|
return &ValidationError{Name: "code", err: fmt.Errorf(`ent: validator failed for field "EpicI18NMappings.code": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *EpicI18NMappingsUpdateOne) sqlSave(ctx context.Context) (_node *EpicI18NMappings, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(epici18nmappings.Table, epici18nmappings.Columns, sqlgraph.NewFieldSpec(epici18nmappings.FieldID, field.TypeInt64))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EpicI18NMappings.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, epici18nmappings.FieldID)
|
|
for _, f := range fields {
|
|
if !epici18nmappings.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != epici18nmappings.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.KeyName(); ok {
|
|
_spec.SetField(epici18nmappings.FieldKeyName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Language(); ok {
|
|
_spec.SetField(epici18nmappings.FieldLanguage, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Value(); ok {
|
|
_spec.SetField(epici18nmappings.FieldValue, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Category(); ok {
|
|
_spec.SetField(epici18nmappings.FieldCategory, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(epici18nmappings.FieldStatus, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedStatus(); ok {
|
|
_spec.AddField(epici18nmappings.FieldStatus, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.Creator(); ok {
|
|
_spec.SetField(epici18nmappings.FieldCreator, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.CreateTime(); ok {
|
|
_spec.SetField(epici18nmappings.FieldCreateTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.CreateTimeCleared() {
|
|
_spec.ClearField(epici18nmappings.FieldCreateTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Updater(); ok {
|
|
_spec.SetField(epici18nmappings.FieldUpdater, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdateTime(); ok {
|
|
_spec.SetField(epici18nmappings.FieldUpdateTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.UpdateTimeCleared() {
|
|
_spec.ClearField(epici18nmappings.FieldUpdateTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Deleted(); ok {
|
|
_spec.SetField(epici18nmappings.FieldDeleted, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedDeleted(); ok {
|
|
_spec.AddField(epici18nmappings.FieldDeleted, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.Code(); ok {
|
|
_spec.SetField(epici18nmappings.FieldCode, field.TypeString, value)
|
|
}
|
|
_node = &EpicI18NMappings{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{epici18nmappings.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|