605 lines
17 KiB
Go
605 lines
17 KiB
Go
// Copyright 2019-present Facebook Inc. All rights reserved.
|
|
// This source code is licensed under the Apache 2.0 license found
|
|
// in the LICENSE file in the root directory of this source tree.
|
|
|
|
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/entc/integration/ent/predicate"
|
|
"entgo.io/ent/entc/integration/ent/schema/task"
|
|
enttask "entgo.io/ent/entc/integration/ent/task"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// TaskUpdate is the builder for updating Task entities.
|
|
type TaskUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *TaskMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// Where appends a list predicates to the TaskUpdate builder.
|
|
func (_u *TaskUpdate) Where(ps ...predicate.Task) *TaskUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetPriority sets the "priority" field.
|
|
func (_u *TaskUpdate) SetPriority(v task.Priority) *TaskUpdate {
|
|
_u.mutation.ResetPriority()
|
|
_u.mutation.SetPriority(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePriority sets the "priority" field if the given value is not nil.
|
|
func (_u *TaskUpdate) SetNillablePriority(v *task.Priority) *TaskUpdate {
|
|
if v != nil {
|
|
_u.SetPriority(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddPriority adds value to the "priority" field.
|
|
func (_u *TaskUpdate) AddPriority(v task.Priority) *TaskUpdate {
|
|
_u.mutation.AddPriority(v)
|
|
return _u
|
|
}
|
|
|
|
// SetPriorities sets the "priorities" field.
|
|
func (_u *TaskUpdate) SetPriorities(v map[string]task.Priority) *TaskUpdate {
|
|
_u.mutation.SetPriorities(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearPriorities clears the value of the "priorities" field.
|
|
func (_u *TaskUpdate) ClearPriorities() *TaskUpdate {
|
|
_u.mutation.ClearPriorities()
|
|
return _u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *TaskUpdate) SetName(v string) *TaskUpdate {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *TaskUpdate) SetNillableName(v *string) *TaskUpdate {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearName clears the value of the "name" field.
|
|
func (_u *TaskUpdate) ClearName() *TaskUpdate {
|
|
_u.mutation.ClearName()
|
|
return _u
|
|
}
|
|
|
|
// SetOwner sets the "owner" field.
|
|
func (_u *TaskUpdate) SetOwner(v string) *TaskUpdate {
|
|
_u.mutation.SetOwner(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOwner sets the "owner" field if the given value is not nil.
|
|
func (_u *TaskUpdate) SetNillableOwner(v *string) *TaskUpdate {
|
|
if v != nil {
|
|
_u.SetOwner(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearOwner clears the value of the "owner" field.
|
|
func (_u *TaskUpdate) ClearOwner() *TaskUpdate {
|
|
_u.mutation.ClearOwner()
|
|
return _u
|
|
}
|
|
|
|
// SetOrder sets the "order" field.
|
|
func (_u *TaskUpdate) SetOrder(v int) *TaskUpdate {
|
|
_u.mutation.ResetOrder()
|
|
_u.mutation.SetOrder(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOrder sets the "order" field if the given value is not nil.
|
|
func (_u *TaskUpdate) SetNillableOrder(v *int) *TaskUpdate {
|
|
if v != nil {
|
|
_u.SetOrder(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddOrder adds value to the "order" field.
|
|
func (_u *TaskUpdate) AddOrder(v int) *TaskUpdate {
|
|
_u.mutation.AddOrder(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearOrder clears the value of the "order" field.
|
|
func (_u *TaskUpdate) ClearOrder() *TaskUpdate {
|
|
_u.mutation.ClearOrder()
|
|
return _u
|
|
}
|
|
|
|
// SetOrderOption sets the "order_option" field.
|
|
func (_u *TaskUpdate) SetOrderOption(v int) *TaskUpdate {
|
|
_u.mutation.ResetOrderOption()
|
|
_u.mutation.SetOrderOption(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOrderOption sets the "order_option" field if the given value is not nil.
|
|
func (_u *TaskUpdate) SetNillableOrderOption(v *int) *TaskUpdate {
|
|
if v != nil {
|
|
_u.SetOrderOption(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddOrderOption adds value to the "order_option" field.
|
|
func (_u *TaskUpdate) AddOrderOption(v int) *TaskUpdate {
|
|
_u.mutation.AddOrderOption(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearOrderOption clears the value of the "order_option" field.
|
|
func (_u *TaskUpdate) ClearOrderOption() *TaskUpdate {
|
|
_u.mutation.ClearOrderOption()
|
|
return _u
|
|
}
|
|
|
|
// SetOp sets the "op" field.
|
|
func (_u *TaskUpdate) SetOp(v string) *TaskUpdate {
|
|
_u.mutation.SetOpField(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOp sets the "op" field if the given value is not nil.
|
|
func (_u *TaskUpdate) SetNillableOp(v *string) *TaskUpdate {
|
|
if v != nil {
|
|
_u.SetOp(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the TaskMutation object of the builder.
|
|
func (_u *TaskUpdate) Mutation() *TaskMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *TaskUpdate) 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 *TaskUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *TaskUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *TaskUpdate) 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 *TaskUpdate) check() error {
|
|
if v, ok := _u.mutation.Priority(); ok {
|
|
if err := v.Validate(); err != nil {
|
|
return &ValidationError{Name: "priority", err: fmt.Errorf(`ent: validator failed for field "Task.priority": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.GetOp(); ok {
|
|
if err := enttask.OpValidator(v); err != nil {
|
|
return &ValidationError{Name: "op", err: fmt.Errorf(`ent: validator failed for field "Task.op": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *TaskUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *TaskUpdate {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *TaskUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(enttask.Table, enttask.Columns, sqlgraph.NewFieldSpec(enttask.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.Priority(); ok {
|
|
_spec.SetField(enttask.FieldPriority, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedPriority(); ok {
|
|
_spec.AddField(enttask.FieldPriority, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.Priorities(); ok {
|
|
_spec.SetField(enttask.FieldPriorities, field.TypeJSON, value)
|
|
}
|
|
if _u.mutation.PrioritiesCleared() {
|
|
_spec.ClearField(enttask.FieldPriorities, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.Name(); ok {
|
|
_spec.SetField(enttask.FieldName, field.TypeString, value)
|
|
}
|
|
if _u.mutation.NameCleared() {
|
|
_spec.ClearField(enttask.FieldName, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Owner(); ok {
|
|
_spec.SetField(enttask.FieldOwner, field.TypeString, value)
|
|
}
|
|
if _u.mutation.OwnerCleared() {
|
|
_spec.ClearField(enttask.FieldOwner, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Order(); ok {
|
|
_spec.SetField(enttask.FieldOrder, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedOrder(); ok {
|
|
_spec.AddField(enttask.FieldOrder, field.TypeInt, value)
|
|
}
|
|
if _u.mutation.OrderCleared() {
|
|
_spec.ClearField(enttask.FieldOrder, field.TypeInt)
|
|
}
|
|
if value, ok := _u.mutation.OrderOption(); ok {
|
|
_spec.SetField(enttask.FieldOrderOption, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedOrderOption(); ok {
|
|
_spec.AddField(enttask.FieldOrderOption, field.TypeInt, value)
|
|
}
|
|
if _u.mutation.OrderOptionCleared() {
|
|
_spec.ClearField(enttask.FieldOrderOption, field.TypeInt)
|
|
}
|
|
if value, ok := _u.mutation.GetOp(); ok {
|
|
_spec.SetField(enttask.FieldOp, 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{enttask.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// TaskUpdateOne is the builder for updating a single Task entity.
|
|
type TaskUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *TaskMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// SetPriority sets the "priority" field.
|
|
func (_u *TaskUpdateOne) SetPriority(v task.Priority) *TaskUpdateOne {
|
|
_u.mutation.ResetPriority()
|
|
_u.mutation.SetPriority(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePriority sets the "priority" field if the given value is not nil.
|
|
func (_u *TaskUpdateOne) SetNillablePriority(v *task.Priority) *TaskUpdateOne {
|
|
if v != nil {
|
|
_u.SetPriority(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddPriority adds value to the "priority" field.
|
|
func (_u *TaskUpdateOne) AddPriority(v task.Priority) *TaskUpdateOne {
|
|
_u.mutation.AddPriority(v)
|
|
return _u
|
|
}
|
|
|
|
// SetPriorities sets the "priorities" field.
|
|
func (_u *TaskUpdateOne) SetPriorities(v map[string]task.Priority) *TaskUpdateOne {
|
|
_u.mutation.SetPriorities(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearPriorities clears the value of the "priorities" field.
|
|
func (_u *TaskUpdateOne) ClearPriorities() *TaskUpdateOne {
|
|
_u.mutation.ClearPriorities()
|
|
return _u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *TaskUpdateOne) SetName(v string) *TaskUpdateOne {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *TaskUpdateOne) SetNillableName(v *string) *TaskUpdateOne {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearName clears the value of the "name" field.
|
|
func (_u *TaskUpdateOne) ClearName() *TaskUpdateOne {
|
|
_u.mutation.ClearName()
|
|
return _u
|
|
}
|
|
|
|
// SetOwner sets the "owner" field.
|
|
func (_u *TaskUpdateOne) SetOwner(v string) *TaskUpdateOne {
|
|
_u.mutation.SetOwner(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOwner sets the "owner" field if the given value is not nil.
|
|
func (_u *TaskUpdateOne) SetNillableOwner(v *string) *TaskUpdateOne {
|
|
if v != nil {
|
|
_u.SetOwner(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearOwner clears the value of the "owner" field.
|
|
func (_u *TaskUpdateOne) ClearOwner() *TaskUpdateOne {
|
|
_u.mutation.ClearOwner()
|
|
return _u
|
|
}
|
|
|
|
// SetOrder sets the "order" field.
|
|
func (_u *TaskUpdateOne) SetOrder(v int) *TaskUpdateOne {
|
|
_u.mutation.ResetOrder()
|
|
_u.mutation.SetOrder(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOrder sets the "order" field if the given value is not nil.
|
|
func (_u *TaskUpdateOne) SetNillableOrder(v *int) *TaskUpdateOne {
|
|
if v != nil {
|
|
_u.SetOrder(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddOrder adds value to the "order" field.
|
|
func (_u *TaskUpdateOne) AddOrder(v int) *TaskUpdateOne {
|
|
_u.mutation.AddOrder(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearOrder clears the value of the "order" field.
|
|
func (_u *TaskUpdateOne) ClearOrder() *TaskUpdateOne {
|
|
_u.mutation.ClearOrder()
|
|
return _u
|
|
}
|
|
|
|
// SetOrderOption sets the "order_option" field.
|
|
func (_u *TaskUpdateOne) SetOrderOption(v int) *TaskUpdateOne {
|
|
_u.mutation.ResetOrderOption()
|
|
_u.mutation.SetOrderOption(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOrderOption sets the "order_option" field if the given value is not nil.
|
|
func (_u *TaskUpdateOne) SetNillableOrderOption(v *int) *TaskUpdateOne {
|
|
if v != nil {
|
|
_u.SetOrderOption(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddOrderOption adds value to the "order_option" field.
|
|
func (_u *TaskUpdateOne) AddOrderOption(v int) *TaskUpdateOne {
|
|
_u.mutation.AddOrderOption(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearOrderOption clears the value of the "order_option" field.
|
|
func (_u *TaskUpdateOne) ClearOrderOption() *TaskUpdateOne {
|
|
_u.mutation.ClearOrderOption()
|
|
return _u
|
|
}
|
|
|
|
// SetOp sets the "op" field.
|
|
func (_u *TaskUpdateOne) SetOp(v string) *TaskUpdateOne {
|
|
_u.mutation.SetOpField(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOp sets the "op" field if the given value is not nil.
|
|
func (_u *TaskUpdateOne) SetNillableOp(v *string) *TaskUpdateOne {
|
|
if v != nil {
|
|
_u.SetOp(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the TaskMutation object of the builder.
|
|
func (_u *TaskUpdateOne) Mutation() *TaskMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Where appends a list predicates to the TaskUpdate builder.
|
|
func (_u *TaskUpdateOne) Where(ps ...predicate.Task) *TaskUpdateOne {
|
|
_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 *TaskUpdateOne) Select(field string, fields ...string) *TaskUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated Task entity.
|
|
func (_u *TaskUpdateOne) Save(ctx context.Context) (*Task, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *TaskUpdateOne) SaveX(ctx context.Context) *Task {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *TaskUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *TaskUpdateOne) 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 *TaskUpdateOne) check() error {
|
|
if v, ok := _u.mutation.Priority(); ok {
|
|
if err := v.Validate(); err != nil {
|
|
return &ValidationError{Name: "priority", err: fmt.Errorf(`ent: validator failed for field "Task.priority": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.GetOp(); ok {
|
|
if err := enttask.OpValidator(v); err != nil {
|
|
return &ValidationError{Name: "op", err: fmt.Errorf(`ent: validator failed for field "Task.op": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *TaskUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *TaskUpdateOne {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *TaskUpdateOne) sqlSave(ctx context.Context) (_node *Task, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(enttask.Table, enttask.Columns, sqlgraph.NewFieldSpec(enttask.FieldID, field.TypeInt))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Task.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, enttask.FieldID)
|
|
for _, f := range fields {
|
|
if !enttask.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != enttask.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.Priority(); ok {
|
|
_spec.SetField(enttask.FieldPriority, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedPriority(); ok {
|
|
_spec.AddField(enttask.FieldPriority, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.Priorities(); ok {
|
|
_spec.SetField(enttask.FieldPriorities, field.TypeJSON, value)
|
|
}
|
|
if _u.mutation.PrioritiesCleared() {
|
|
_spec.ClearField(enttask.FieldPriorities, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.Name(); ok {
|
|
_spec.SetField(enttask.FieldName, field.TypeString, value)
|
|
}
|
|
if _u.mutation.NameCleared() {
|
|
_spec.ClearField(enttask.FieldName, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Owner(); ok {
|
|
_spec.SetField(enttask.FieldOwner, field.TypeString, value)
|
|
}
|
|
if _u.mutation.OwnerCleared() {
|
|
_spec.ClearField(enttask.FieldOwner, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Order(); ok {
|
|
_spec.SetField(enttask.FieldOrder, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedOrder(); ok {
|
|
_spec.AddField(enttask.FieldOrder, field.TypeInt, value)
|
|
}
|
|
if _u.mutation.OrderCleared() {
|
|
_spec.ClearField(enttask.FieldOrder, field.TypeInt)
|
|
}
|
|
if value, ok := _u.mutation.OrderOption(); ok {
|
|
_spec.SetField(enttask.FieldOrderOption, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedOrderOption(); ok {
|
|
_spec.AddField(enttask.FieldOrderOption, field.TypeInt, value)
|
|
}
|
|
if _u.mutation.OrderOptionCleared() {
|
|
_spec.ClearField(enttask.FieldOrderOption, field.TypeInt)
|
|
}
|
|
if value, ok := _u.mutation.GetOp(); ok {
|
|
_spec.SetField(enttask.FieldOp, field.TypeString, value)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
_node = &Task{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{enttask.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|