Files
voidraft/internal/models/ent/keybinding_update.go
2025-12-20 16:43:04 +08:00

786 lines
23 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"voidraft/internal/models/ent/keybinding"
"voidraft/internal/models/ent/predicate"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// KeyBindingUpdate is the builder for updating KeyBinding entities.
type KeyBindingUpdate struct {
config
hooks []Hook
mutation *KeyBindingMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the KeyBindingUpdate builder.
func (_u *KeyBindingUpdate) Where(ps ...predicate.KeyBinding) *KeyBindingUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *KeyBindingUpdate) SetUpdatedAt(v string) *KeyBindingUpdate {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillableUpdatedAt(v *string) *KeyBindingUpdate {
if v != nil {
_u.SetUpdatedAt(*v)
}
return _u
}
// SetDeletedAt sets the "deleted_at" field.
func (_u *KeyBindingUpdate) SetDeletedAt(v string) *KeyBindingUpdate {
_u.mutation.SetDeletedAt(v)
return _u
}
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillableDeletedAt(v *string) *KeyBindingUpdate {
if v != nil {
_u.SetDeletedAt(*v)
}
return _u
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func (_u *KeyBindingUpdate) ClearDeletedAt() *KeyBindingUpdate {
_u.mutation.ClearDeletedAt()
return _u
}
// SetName sets the "name" field.
func (_u *KeyBindingUpdate) SetName(v string) *KeyBindingUpdate {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillableName(v *string) *KeyBindingUpdate {
if v != nil {
_u.SetName(*v)
}
return _u
}
// SetType sets the "type" field.
func (_u *KeyBindingUpdate) SetType(v string) *KeyBindingUpdate {
_u.mutation.SetType(v)
return _u
}
// SetNillableType sets the "type" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillableType(v *string) *KeyBindingUpdate {
if v != nil {
_u.SetType(*v)
}
return _u
}
// SetKey sets the "key" field.
func (_u *KeyBindingUpdate) SetKey(v string) *KeyBindingUpdate {
_u.mutation.SetKey(v)
return _u
}
// SetNillableKey sets the "key" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillableKey(v *string) *KeyBindingUpdate {
if v != nil {
_u.SetKey(*v)
}
return _u
}
// ClearKey clears the value of the "key" field.
func (_u *KeyBindingUpdate) ClearKey() *KeyBindingUpdate {
_u.mutation.ClearKey()
return _u
}
// SetMacos sets the "macos" field.
func (_u *KeyBindingUpdate) SetMacos(v string) *KeyBindingUpdate {
_u.mutation.SetMacos(v)
return _u
}
// SetNillableMacos sets the "macos" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillableMacos(v *string) *KeyBindingUpdate {
if v != nil {
_u.SetMacos(*v)
}
return _u
}
// ClearMacos clears the value of the "macos" field.
func (_u *KeyBindingUpdate) ClearMacos() *KeyBindingUpdate {
_u.mutation.ClearMacos()
return _u
}
// SetWindows sets the "windows" field.
func (_u *KeyBindingUpdate) SetWindows(v string) *KeyBindingUpdate {
_u.mutation.SetWindows(v)
return _u
}
// SetNillableWindows sets the "windows" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillableWindows(v *string) *KeyBindingUpdate {
if v != nil {
_u.SetWindows(*v)
}
return _u
}
// ClearWindows clears the value of the "windows" field.
func (_u *KeyBindingUpdate) ClearWindows() *KeyBindingUpdate {
_u.mutation.ClearWindows()
return _u
}
// SetLinux sets the "linux" field.
func (_u *KeyBindingUpdate) SetLinux(v string) *KeyBindingUpdate {
_u.mutation.SetLinux(v)
return _u
}
// SetNillableLinux sets the "linux" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillableLinux(v *string) *KeyBindingUpdate {
if v != nil {
_u.SetLinux(*v)
}
return _u
}
// ClearLinux clears the value of the "linux" field.
func (_u *KeyBindingUpdate) ClearLinux() *KeyBindingUpdate {
_u.mutation.ClearLinux()
return _u
}
// SetExtension sets the "extension" field.
func (_u *KeyBindingUpdate) SetExtension(v string) *KeyBindingUpdate {
_u.mutation.SetExtension(v)
return _u
}
// SetNillableExtension sets the "extension" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillableExtension(v *string) *KeyBindingUpdate {
if v != nil {
_u.SetExtension(*v)
}
return _u
}
// SetEnabled sets the "enabled" field.
func (_u *KeyBindingUpdate) SetEnabled(v bool) *KeyBindingUpdate {
_u.mutation.SetEnabled(v)
return _u
}
// SetNillableEnabled sets the "enabled" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillableEnabled(v *bool) *KeyBindingUpdate {
if v != nil {
_u.SetEnabled(*v)
}
return _u
}
// SetPreventDefault sets the "prevent_default" field.
func (_u *KeyBindingUpdate) SetPreventDefault(v bool) *KeyBindingUpdate {
_u.mutation.SetPreventDefault(v)
return _u
}
// SetNillablePreventDefault sets the "prevent_default" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillablePreventDefault(v *bool) *KeyBindingUpdate {
if v != nil {
_u.SetPreventDefault(*v)
}
return _u
}
// SetScope sets the "scope" field.
func (_u *KeyBindingUpdate) SetScope(v string) *KeyBindingUpdate {
_u.mutation.SetScope(v)
return _u
}
// SetNillableScope sets the "scope" field if the given value is not nil.
func (_u *KeyBindingUpdate) SetNillableScope(v *string) *KeyBindingUpdate {
if v != nil {
_u.SetScope(*v)
}
return _u
}
// Mutation returns the KeyBindingMutation object of the builder.
func (_u *KeyBindingUpdate) Mutation() *KeyBindingMutation {
return _u.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *KeyBindingUpdate) 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 *KeyBindingUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *KeyBindingUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *KeyBindingUpdate) 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 *KeyBindingUpdate) check() error {
if v, ok := _u.mutation.Name(); ok {
if err := keybinding.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.name": %w`, err)}
}
}
if v, ok := _u.mutation.GetType(); ok {
if err := keybinding.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.type": %w`, err)}
}
}
if v, ok := _u.mutation.Key(); ok {
if err := keybinding.KeyValidator(v); err != nil {
return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.key": %w`, err)}
}
}
if v, ok := _u.mutation.Macos(); ok {
if err := keybinding.MacosValidator(v); err != nil {
return &ValidationError{Name: "macos", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.macos": %w`, err)}
}
}
if v, ok := _u.mutation.Windows(); ok {
if err := keybinding.WindowsValidator(v); err != nil {
return &ValidationError{Name: "windows", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.windows": %w`, err)}
}
}
if v, ok := _u.mutation.Linux(); ok {
if err := keybinding.LinuxValidator(v); err != nil {
return &ValidationError{Name: "linux", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.linux": %w`, err)}
}
}
if v, ok := _u.mutation.Extension(); ok {
if err := keybinding.ExtensionValidator(v); err != nil {
return &ValidationError{Name: "extension", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.extension": %w`, err)}
}
}
if v, ok := _u.mutation.Scope(); ok {
if err := keybinding.ScopeValidator(v); err != nil {
return &ValidationError{Name: "scope", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.scope": %w`, err)}
}
}
return nil
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (_u *KeyBindingUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *KeyBindingUpdate {
_u.modifiers = append(_u.modifiers, modifiers...)
return _u
}
func (_u *KeyBindingUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(keybinding.Table, keybinding.Columns, sqlgraph.NewFieldSpec(keybinding.FieldID, field.TypeInt))
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.UpdatedAt(); ok {
_spec.SetField(keybinding.FieldUpdatedAt, field.TypeString, value)
}
if value, ok := _u.mutation.DeletedAt(); ok {
_spec.SetField(keybinding.FieldDeletedAt, field.TypeString, value)
}
if _u.mutation.DeletedAtCleared() {
_spec.ClearField(keybinding.FieldDeletedAt, field.TypeString)
}
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(keybinding.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.GetType(); ok {
_spec.SetField(keybinding.FieldType, field.TypeString, value)
}
if value, ok := _u.mutation.Key(); ok {
_spec.SetField(keybinding.FieldKey, field.TypeString, value)
}
if _u.mutation.KeyCleared() {
_spec.ClearField(keybinding.FieldKey, field.TypeString)
}
if value, ok := _u.mutation.Macos(); ok {
_spec.SetField(keybinding.FieldMacos, field.TypeString, value)
}
if _u.mutation.MacosCleared() {
_spec.ClearField(keybinding.FieldMacos, field.TypeString)
}
if value, ok := _u.mutation.Windows(); ok {
_spec.SetField(keybinding.FieldWindows, field.TypeString, value)
}
if _u.mutation.WindowsCleared() {
_spec.ClearField(keybinding.FieldWindows, field.TypeString)
}
if value, ok := _u.mutation.Linux(); ok {
_spec.SetField(keybinding.FieldLinux, field.TypeString, value)
}
if _u.mutation.LinuxCleared() {
_spec.ClearField(keybinding.FieldLinux, field.TypeString)
}
if value, ok := _u.mutation.Extension(); ok {
_spec.SetField(keybinding.FieldExtension, field.TypeString, value)
}
if value, ok := _u.mutation.Enabled(); ok {
_spec.SetField(keybinding.FieldEnabled, field.TypeBool, value)
}
if value, ok := _u.mutation.PreventDefault(); ok {
_spec.SetField(keybinding.FieldPreventDefault, field.TypeBool, value)
}
if value, ok := _u.mutation.Scope(); ok {
_spec.SetField(keybinding.FieldScope, field.TypeString, value)
}
_spec.AddModifiers(_u.modifiers...)
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{keybinding.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// KeyBindingUpdateOne is the builder for updating a single KeyBinding entity.
type KeyBindingUpdateOne struct {
config
fields []string
hooks []Hook
mutation *KeyBindingMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *KeyBindingUpdateOne) SetUpdatedAt(v string) *KeyBindingUpdateOne {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillableUpdatedAt(v *string) *KeyBindingUpdateOne {
if v != nil {
_u.SetUpdatedAt(*v)
}
return _u
}
// SetDeletedAt sets the "deleted_at" field.
func (_u *KeyBindingUpdateOne) SetDeletedAt(v string) *KeyBindingUpdateOne {
_u.mutation.SetDeletedAt(v)
return _u
}
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillableDeletedAt(v *string) *KeyBindingUpdateOne {
if v != nil {
_u.SetDeletedAt(*v)
}
return _u
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func (_u *KeyBindingUpdateOne) ClearDeletedAt() *KeyBindingUpdateOne {
_u.mutation.ClearDeletedAt()
return _u
}
// SetName sets the "name" field.
func (_u *KeyBindingUpdateOne) SetName(v string) *KeyBindingUpdateOne {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillableName(v *string) *KeyBindingUpdateOne {
if v != nil {
_u.SetName(*v)
}
return _u
}
// SetType sets the "type" field.
func (_u *KeyBindingUpdateOne) SetType(v string) *KeyBindingUpdateOne {
_u.mutation.SetType(v)
return _u
}
// SetNillableType sets the "type" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillableType(v *string) *KeyBindingUpdateOne {
if v != nil {
_u.SetType(*v)
}
return _u
}
// SetKey sets the "key" field.
func (_u *KeyBindingUpdateOne) SetKey(v string) *KeyBindingUpdateOne {
_u.mutation.SetKey(v)
return _u
}
// SetNillableKey sets the "key" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillableKey(v *string) *KeyBindingUpdateOne {
if v != nil {
_u.SetKey(*v)
}
return _u
}
// ClearKey clears the value of the "key" field.
func (_u *KeyBindingUpdateOne) ClearKey() *KeyBindingUpdateOne {
_u.mutation.ClearKey()
return _u
}
// SetMacos sets the "macos" field.
func (_u *KeyBindingUpdateOne) SetMacos(v string) *KeyBindingUpdateOne {
_u.mutation.SetMacos(v)
return _u
}
// SetNillableMacos sets the "macos" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillableMacos(v *string) *KeyBindingUpdateOne {
if v != nil {
_u.SetMacos(*v)
}
return _u
}
// ClearMacos clears the value of the "macos" field.
func (_u *KeyBindingUpdateOne) ClearMacos() *KeyBindingUpdateOne {
_u.mutation.ClearMacos()
return _u
}
// SetWindows sets the "windows" field.
func (_u *KeyBindingUpdateOne) SetWindows(v string) *KeyBindingUpdateOne {
_u.mutation.SetWindows(v)
return _u
}
// SetNillableWindows sets the "windows" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillableWindows(v *string) *KeyBindingUpdateOne {
if v != nil {
_u.SetWindows(*v)
}
return _u
}
// ClearWindows clears the value of the "windows" field.
func (_u *KeyBindingUpdateOne) ClearWindows() *KeyBindingUpdateOne {
_u.mutation.ClearWindows()
return _u
}
// SetLinux sets the "linux" field.
func (_u *KeyBindingUpdateOne) SetLinux(v string) *KeyBindingUpdateOne {
_u.mutation.SetLinux(v)
return _u
}
// SetNillableLinux sets the "linux" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillableLinux(v *string) *KeyBindingUpdateOne {
if v != nil {
_u.SetLinux(*v)
}
return _u
}
// ClearLinux clears the value of the "linux" field.
func (_u *KeyBindingUpdateOne) ClearLinux() *KeyBindingUpdateOne {
_u.mutation.ClearLinux()
return _u
}
// SetExtension sets the "extension" field.
func (_u *KeyBindingUpdateOne) SetExtension(v string) *KeyBindingUpdateOne {
_u.mutation.SetExtension(v)
return _u
}
// SetNillableExtension sets the "extension" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillableExtension(v *string) *KeyBindingUpdateOne {
if v != nil {
_u.SetExtension(*v)
}
return _u
}
// SetEnabled sets the "enabled" field.
func (_u *KeyBindingUpdateOne) SetEnabled(v bool) *KeyBindingUpdateOne {
_u.mutation.SetEnabled(v)
return _u
}
// SetNillableEnabled sets the "enabled" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillableEnabled(v *bool) *KeyBindingUpdateOne {
if v != nil {
_u.SetEnabled(*v)
}
return _u
}
// SetPreventDefault sets the "prevent_default" field.
func (_u *KeyBindingUpdateOne) SetPreventDefault(v bool) *KeyBindingUpdateOne {
_u.mutation.SetPreventDefault(v)
return _u
}
// SetNillablePreventDefault sets the "prevent_default" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillablePreventDefault(v *bool) *KeyBindingUpdateOne {
if v != nil {
_u.SetPreventDefault(*v)
}
return _u
}
// SetScope sets the "scope" field.
func (_u *KeyBindingUpdateOne) SetScope(v string) *KeyBindingUpdateOne {
_u.mutation.SetScope(v)
return _u
}
// SetNillableScope sets the "scope" field if the given value is not nil.
func (_u *KeyBindingUpdateOne) SetNillableScope(v *string) *KeyBindingUpdateOne {
if v != nil {
_u.SetScope(*v)
}
return _u
}
// Mutation returns the KeyBindingMutation object of the builder.
func (_u *KeyBindingUpdateOne) Mutation() *KeyBindingMutation {
return _u.mutation
}
// Where appends a list predicates to the KeyBindingUpdate builder.
func (_u *KeyBindingUpdateOne) Where(ps ...predicate.KeyBinding) *KeyBindingUpdateOne {
_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 *KeyBindingUpdateOne) Select(field string, fields ...string) *KeyBindingUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated KeyBinding entity.
func (_u *KeyBindingUpdateOne) Save(ctx context.Context) (*KeyBinding, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *KeyBindingUpdateOne) SaveX(ctx context.Context) *KeyBinding {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *KeyBindingUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *KeyBindingUpdateOne) 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 *KeyBindingUpdateOne) check() error {
if v, ok := _u.mutation.Name(); ok {
if err := keybinding.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.name": %w`, err)}
}
}
if v, ok := _u.mutation.GetType(); ok {
if err := keybinding.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.type": %w`, err)}
}
}
if v, ok := _u.mutation.Key(); ok {
if err := keybinding.KeyValidator(v); err != nil {
return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.key": %w`, err)}
}
}
if v, ok := _u.mutation.Macos(); ok {
if err := keybinding.MacosValidator(v); err != nil {
return &ValidationError{Name: "macos", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.macos": %w`, err)}
}
}
if v, ok := _u.mutation.Windows(); ok {
if err := keybinding.WindowsValidator(v); err != nil {
return &ValidationError{Name: "windows", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.windows": %w`, err)}
}
}
if v, ok := _u.mutation.Linux(); ok {
if err := keybinding.LinuxValidator(v); err != nil {
return &ValidationError{Name: "linux", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.linux": %w`, err)}
}
}
if v, ok := _u.mutation.Extension(); ok {
if err := keybinding.ExtensionValidator(v); err != nil {
return &ValidationError{Name: "extension", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.extension": %w`, err)}
}
}
if v, ok := _u.mutation.Scope(); ok {
if err := keybinding.ScopeValidator(v); err != nil {
return &ValidationError{Name: "scope", err: fmt.Errorf(`ent: validator failed for field "KeyBinding.scope": %w`, err)}
}
}
return nil
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (_u *KeyBindingUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *KeyBindingUpdateOne {
_u.modifiers = append(_u.modifiers, modifiers...)
return _u
}
func (_u *KeyBindingUpdateOne) sqlSave(ctx context.Context) (_node *KeyBinding, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(keybinding.Table, keybinding.Columns, sqlgraph.NewFieldSpec(keybinding.FieldID, field.TypeInt))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "KeyBinding.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, keybinding.FieldID)
for _, f := range fields {
if !keybinding.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != keybinding.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.UpdatedAt(); ok {
_spec.SetField(keybinding.FieldUpdatedAt, field.TypeString, value)
}
if value, ok := _u.mutation.DeletedAt(); ok {
_spec.SetField(keybinding.FieldDeletedAt, field.TypeString, value)
}
if _u.mutation.DeletedAtCleared() {
_spec.ClearField(keybinding.FieldDeletedAt, field.TypeString)
}
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(keybinding.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.GetType(); ok {
_spec.SetField(keybinding.FieldType, field.TypeString, value)
}
if value, ok := _u.mutation.Key(); ok {
_spec.SetField(keybinding.FieldKey, field.TypeString, value)
}
if _u.mutation.KeyCleared() {
_spec.ClearField(keybinding.FieldKey, field.TypeString)
}
if value, ok := _u.mutation.Macos(); ok {
_spec.SetField(keybinding.FieldMacos, field.TypeString, value)
}
if _u.mutation.MacosCleared() {
_spec.ClearField(keybinding.FieldMacos, field.TypeString)
}
if value, ok := _u.mutation.Windows(); ok {
_spec.SetField(keybinding.FieldWindows, field.TypeString, value)
}
if _u.mutation.WindowsCleared() {
_spec.ClearField(keybinding.FieldWindows, field.TypeString)
}
if value, ok := _u.mutation.Linux(); ok {
_spec.SetField(keybinding.FieldLinux, field.TypeString, value)
}
if _u.mutation.LinuxCleared() {
_spec.ClearField(keybinding.FieldLinux, field.TypeString)
}
if value, ok := _u.mutation.Extension(); ok {
_spec.SetField(keybinding.FieldExtension, field.TypeString, value)
}
if value, ok := _u.mutation.Enabled(); ok {
_spec.SetField(keybinding.FieldEnabled, field.TypeBool, value)
}
if value, ok := _u.mutation.PreventDefault(); ok {
_spec.SetField(keybinding.FieldPreventDefault, field.TypeBool, value)
}
if value, ok := _u.mutation.Scope(); ok {
_spec.SetField(keybinding.FieldScope, field.TypeString, value)
}
_spec.AddModifiers(_u.modifiers...)
_node = &KeyBinding{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{keybinding.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}