mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-22 19:39:31 +08:00
1931 lines
56 KiB
Go
1931 lines
56 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/dialect/sql/sqljson"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/chaitin/MonkeyCode/backend/consts"
|
|
"github.com/chaitin/MonkeyCode/backend/db/gitbottask"
|
|
"github.com/chaitin/MonkeyCode/backend/db/gittask"
|
|
"github.com/chaitin/MonkeyCode/backend/db/predicate"
|
|
"github.com/chaitin/MonkeyCode/backend/db/projecttask"
|
|
"github.com/chaitin/MonkeyCode/backend/db/task"
|
|
"github.com/chaitin/MonkeyCode/backend/db/taskmodelswitch"
|
|
"github.com/chaitin/MonkeyCode/backend/db/taskvirtualmachine"
|
|
"github.com/chaitin/MonkeyCode/backend/db/user"
|
|
"github.com/chaitin/MonkeyCode/backend/db/virtualmachine"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// 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
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (_u *TaskUpdate) SetDeletedAt(v time.Time) *TaskUpdate {
|
|
_u.mutation.SetDeletedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (_u *TaskUpdate) SetNillableDeletedAt(v *time.Time) *TaskUpdate {
|
|
if v != nil {
|
|
_u.SetDeletedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (_u *TaskUpdate) ClearDeletedAt() *TaskUpdate {
|
|
_u.mutation.ClearDeletedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_u *TaskUpdate) SetUserID(v uuid.UUID) *TaskUpdate {
|
|
_u.mutation.SetUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
|
func (_u *TaskUpdate) SetNillableUserID(v *uuid.UUID) *TaskUpdate {
|
|
if v != nil {
|
|
_u.SetUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetKind sets the "kind" field.
|
|
func (_u *TaskUpdate) SetKind(v consts.TaskType) *TaskUpdate {
|
|
_u.mutation.SetKind(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableKind sets the "kind" field if the given value is not nil.
|
|
func (_u *TaskUpdate) SetNillableKind(v *consts.TaskType) *TaskUpdate {
|
|
if v != nil {
|
|
_u.SetKind(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSubType sets the "sub_type" field.
|
|
func (_u *TaskUpdate) SetSubType(v consts.TaskSubType) *TaskUpdate {
|
|
_u.mutation.SetSubType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSubType sets the "sub_type" field if the given value is not nil.
|
|
func (_u *TaskUpdate) SetNillableSubType(v *consts.TaskSubType) *TaskUpdate {
|
|
if v != nil {
|
|
_u.SetSubType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSubType clears the value of the "sub_type" field.
|
|
func (_u *TaskUpdate) ClearSubType() *TaskUpdate {
|
|
_u.mutation.ClearSubType()
|
|
return _u
|
|
}
|
|
|
|
// SetContent sets the "content" field.
|
|
func (_u *TaskUpdate) SetContent(v string) *TaskUpdate {
|
|
_u.mutation.SetContent(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableContent sets the "content" field if the given value is not nil.
|
|
func (_u *TaskUpdate) SetNillableContent(v *string) *TaskUpdate {
|
|
if v != nil {
|
|
_u.SetContent(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTitle sets the "title" field.
|
|
func (_u *TaskUpdate) SetTitle(v string) *TaskUpdate {
|
|
_u.mutation.SetTitle(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTitle sets the "title" field if the given value is not nil.
|
|
func (_u *TaskUpdate) SetNillableTitle(v *string) *TaskUpdate {
|
|
if v != nil {
|
|
_u.SetTitle(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearTitle clears the value of the "title" field.
|
|
func (_u *TaskUpdate) ClearTitle() *TaskUpdate {
|
|
_u.mutation.ClearTitle()
|
|
return _u
|
|
}
|
|
|
|
// SetSummary sets the "summary" field.
|
|
func (_u *TaskUpdate) SetSummary(v string) *TaskUpdate {
|
|
_u.mutation.SetSummary(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSummary sets the "summary" field if the given value is not nil.
|
|
func (_u *TaskUpdate) SetNillableSummary(v *string) *TaskUpdate {
|
|
if v != nil {
|
|
_u.SetSummary(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSummary clears the value of the "summary" field.
|
|
func (_u *TaskUpdate) ClearSummary() *TaskUpdate {
|
|
_u.mutation.ClearSummary()
|
|
return _u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_u *TaskUpdate) SetStatus(v consts.TaskStatus) *TaskUpdate {
|
|
_u.mutation.SetStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_u *TaskUpdate) SetNillableStatus(v *consts.TaskStatus) *TaskUpdate {
|
|
if v != nil {
|
|
_u.SetStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetLogStore sets the "log_store" field.
|
|
func (_u *TaskUpdate) SetLogStore(v consts.LogStore) *TaskUpdate {
|
|
_u.mutation.SetLogStore(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLogStore sets the "log_store" field if the given value is not nil.
|
|
func (_u *TaskUpdate) SetNillableLogStore(v *consts.LogStore) *TaskUpdate {
|
|
if v != nil {
|
|
_u.SetLogStore(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearLogStore clears the value of the "log_store" field.
|
|
func (_u *TaskUpdate) ClearLogStore() *TaskUpdate {
|
|
_u.mutation.ClearLogStore()
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *TaskUpdate) SetCreatedAt(v time.Time) *TaskUpdate {
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *TaskUpdate) SetNillableCreatedAt(v *time.Time) *TaskUpdate {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetLastActiveAt sets the "last_active_at" field.
|
|
func (_u *TaskUpdate) SetLastActiveAt(v time.Time) *TaskUpdate {
|
|
_u.mutation.SetLastActiveAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLastActiveAt sets the "last_active_at" field if the given value is not nil.
|
|
func (_u *TaskUpdate) SetNillableLastActiveAt(v *time.Time) *TaskUpdate {
|
|
if v != nil {
|
|
_u.SetLastActiveAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *TaskUpdate) SetUpdatedAt(v time.Time) *TaskUpdate {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetCompletedAt sets the "completed_at" field.
|
|
func (_u *TaskUpdate) SetCompletedAt(v time.Time) *TaskUpdate {
|
|
_u.mutation.SetCompletedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCompletedAt sets the "completed_at" field if the given value is not nil.
|
|
func (_u *TaskUpdate) SetNillableCompletedAt(v *time.Time) *TaskUpdate {
|
|
if v != nil {
|
|
_u.SetCompletedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearCompletedAt clears the value of the "completed_at" field.
|
|
func (_u *TaskUpdate) ClearCompletedAt() *TaskUpdate {
|
|
_u.mutation.ClearCompletedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetSkillIds sets the "skill_ids" field.
|
|
func (_u *TaskUpdate) SetSkillIds(v []string) *TaskUpdate {
|
|
_u.mutation.SetSkillIds(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendSkillIds appends value to the "skill_ids" field.
|
|
func (_u *TaskUpdate) AppendSkillIds(v []string) *TaskUpdate {
|
|
_u.mutation.AppendSkillIds(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearSkillIds clears the value of the "skill_ids" field.
|
|
func (_u *TaskUpdate) ClearSkillIds() *TaskUpdate {
|
|
_u.mutation.ClearSkillIds()
|
|
return _u
|
|
}
|
|
|
|
// SetPluginIds sets the "plugin_ids" field.
|
|
func (_u *TaskUpdate) SetPluginIds(v []string) *TaskUpdate {
|
|
_u.mutation.SetPluginIds(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendPluginIds appends value to the "plugin_ids" field.
|
|
func (_u *TaskUpdate) AppendPluginIds(v []string) *TaskUpdate {
|
|
_u.mutation.AppendPluginIds(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearPluginIds clears the value of the "plugin_ids" field.
|
|
func (_u *TaskUpdate) ClearPluginIds() *TaskUpdate {
|
|
_u.mutation.ClearPluginIds()
|
|
return _u
|
|
}
|
|
|
|
// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by IDs.
|
|
func (_u *TaskUpdate) AddProjectTaskIDs(ids ...uuid.UUID) *TaskUpdate {
|
|
_u.mutation.AddProjectTaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddProjectTasks adds the "project_tasks" edges to the ProjectTask entity.
|
|
func (_u *TaskUpdate) AddProjectTasks(v ...*ProjectTask) *TaskUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddProjectTaskIDs(ids...)
|
|
}
|
|
|
|
// SetGitTasksID sets the "git_tasks" edge to the GitTask entity by ID.
|
|
func (_u *TaskUpdate) SetGitTasksID(id uuid.UUID) *TaskUpdate {
|
|
_u.mutation.SetGitTasksID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableGitTasksID sets the "git_tasks" edge to the GitTask entity by ID if the given value is not nil.
|
|
func (_u *TaskUpdate) SetNillableGitTasksID(id *uuid.UUID) *TaskUpdate {
|
|
if id != nil {
|
|
_u = _u.SetGitTasksID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetGitTasks sets the "git_tasks" edge to the GitTask entity.
|
|
func (_u *TaskUpdate) SetGitTasks(v *GitTask) *TaskUpdate {
|
|
return _u.SetGitTasksID(v.ID)
|
|
}
|
|
|
|
// SetUser sets the "user" edge to the User entity.
|
|
func (_u *TaskUpdate) SetUser(v *User) *TaskUpdate {
|
|
return _u.SetUserID(v.ID)
|
|
}
|
|
|
|
// AddVMIDs adds the "vms" edge to the VirtualMachine entity by IDs.
|
|
func (_u *TaskUpdate) AddVMIDs(ids ...string) *TaskUpdate {
|
|
_u.mutation.AddVMIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddVms adds the "vms" edges to the VirtualMachine entity.
|
|
func (_u *TaskUpdate) AddVms(v ...*VirtualMachine) *TaskUpdate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddVMIDs(ids...)
|
|
}
|
|
|
|
// AddGitBotTaskIDs adds the "git_bot_tasks" edge to the GitBotTask entity by IDs.
|
|
func (_u *TaskUpdate) AddGitBotTaskIDs(ids ...uuid.UUID) *TaskUpdate {
|
|
_u.mutation.AddGitBotTaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddGitBotTasks adds the "git_bot_tasks" edges to the GitBotTask entity.
|
|
func (_u *TaskUpdate) AddGitBotTasks(v ...*GitBotTask) *TaskUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddGitBotTaskIDs(ids...)
|
|
}
|
|
|
|
// AddModelSwitchIDs adds the "model_switches" edge to the TaskModelSwitch entity by IDs.
|
|
func (_u *TaskUpdate) AddModelSwitchIDs(ids ...uuid.UUID) *TaskUpdate {
|
|
_u.mutation.AddModelSwitchIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddModelSwitches adds the "model_switches" edges to the TaskModelSwitch entity.
|
|
func (_u *TaskUpdate) AddModelSwitches(v ...*TaskModelSwitch) *TaskUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddModelSwitchIDs(ids...)
|
|
}
|
|
|
|
// AddTaskVMIDs adds the "task_vms" edge to the TaskVirtualMachine entity by IDs.
|
|
func (_u *TaskUpdate) AddTaskVMIDs(ids ...uuid.UUID) *TaskUpdate {
|
|
_u.mutation.AddTaskVMIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddTaskVms adds the "task_vms" edges to the TaskVirtualMachine entity.
|
|
func (_u *TaskUpdate) AddTaskVms(v ...*TaskVirtualMachine) *TaskUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddTaskVMIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the TaskMutation object of the builder.
|
|
func (_u *TaskUpdate) Mutation() *TaskMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearProjectTasks clears all "project_tasks" edges to the ProjectTask entity.
|
|
func (_u *TaskUpdate) ClearProjectTasks() *TaskUpdate {
|
|
_u.mutation.ClearProjectTasks()
|
|
return _u
|
|
}
|
|
|
|
// RemoveProjectTaskIDs removes the "project_tasks" edge to ProjectTask entities by IDs.
|
|
func (_u *TaskUpdate) RemoveProjectTaskIDs(ids ...uuid.UUID) *TaskUpdate {
|
|
_u.mutation.RemoveProjectTaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveProjectTasks removes "project_tasks" edges to ProjectTask entities.
|
|
func (_u *TaskUpdate) RemoveProjectTasks(v ...*ProjectTask) *TaskUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveProjectTaskIDs(ids...)
|
|
}
|
|
|
|
// ClearGitTasks clears the "git_tasks" edge to the GitTask entity.
|
|
func (_u *TaskUpdate) ClearGitTasks() *TaskUpdate {
|
|
_u.mutation.ClearGitTasks()
|
|
return _u
|
|
}
|
|
|
|
// ClearUser clears the "user" edge to the User entity.
|
|
func (_u *TaskUpdate) ClearUser() *TaskUpdate {
|
|
_u.mutation.ClearUser()
|
|
return _u
|
|
}
|
|
|
|
// ClearVms clears all "vms" edges to the VirtualMachine entity.
|
|
func (_u *TaskUpdate) ClearVms() *TaskUpdate {
|
|
_u.mutation.ClearVms()
|
|
return _u
|
|
}
|
|
|
|
// RemoveVMIDs removes the "vms" edge to VirtualMachine entities by IDs.
|
|
func (_u *TaskUpdate) RemoveVMIDs(ids ...string) *TaskUpdate {
|
|
_u.mutation.RemoveVMIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveVms removes "vms" edges to VirtualMachine entities.
|
|
func (_u *TaskUpdate) RemoveVms(v ...*VirtualMachine) *TaskUpdate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveVMIDs(ids...)
|
|
}
|
|
|
|
// ClearGitBotTasks clears all "git_bot_tasks" edges to the GitBotTask entity.
|
|
func (_u *TaskUpdate) ClearGitBotTasks() *TaskUpdate {
|
|
_u.mutation.ClearGitBotTasks()
|
|
return _u
|
|
}
|
|
|
|
// RemoveGitBotTaskIDs removes the "git_bot_tasks" edge to GitBotTask entities by IDs.
|
|
func (_u *TaskUpdate) RemoveGitBotTaskIDs(ids ...uuid.UUID) *TaskUpdate {
|
|
_u.mutation.RemoveGitBotTaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveGitBotTasks removes "git_bot_tasks" edges to GitBotTask entities.
|
|
func (_u *TaskUpdate) RemoveGitBotTasks(v ...*GitBotTask) *TaskUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveGitBotTaskIDs(ids...)
|
|
}
|
|
|
|
// ClearModelSwitches clears all "model_switches" edges to the TaskModelSwitch entity.
|
|
func (_u *TaskUpdate) ClearModelSwitches() *TaskUpdate {
|
|
_u.mutation.ClearModelSwitches()
|
|
return _u
|
|
}
|
|
|
|
// RemoveModelSwitchIDs removes the "model_switches" edge to TaskModelSwitch entities by IDs.
|
|
func (_u *TaskUpdate) RemoveModelSwitchIDs(ids ...uuid.UUID) *TaskUpdate {
|
|
_u.mutation.RemoveModelSwitchIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveModelSwitches removes "model_switches" edges to TaskModelSwitch entities.
|
|
func (_u *TaskUpdate) RemoveModelSwitches(v ...*TaskModelSwitch) *TaskUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveModelSwitchIDs(ids...)
|
|
}
|
|
|
|
// ClearTaskVms clears all "task_vms" edges to the TaskVirtualMachine entity.
|
|
func (_u *TaskUpdate) ClearTaskVms() *TaskUpdate {
|
|
_u.mutation.ClearTaskVms()
|
|
return _u
|
|
}
|
|
|
|
// RemoveTaskVMIDs removes the "task_vms" edge to TaskVirtualMachine entities by IDs.
|
|
func (_u *TaskUpdate) RemoveTaskVMIDs(ids ...uuid.UUID) *TaskUpdate {
|
|
_u.mutation.RemoveTaskVMIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveTaskVms removes "task_vms" edges to TaskVirtualMachine entities.
|
|
func (_u *TaskUpdate) RemoveTaskVms(v ...*TaskVirtualMachine) *TaskUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveTaskVMIDs(ids...)
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *TaskUpdate) Save(ctx context.Context) (int, error) {
|
|
if err := _u.defaults(); err != nil {
|
|
return 0, err
|
|
}
|
|
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)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *TaskUpdate) defaults() error {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
if task.UpdateDefaultUpdatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized task.UpdateDefaultUpdatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := task.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *TaskUpdate) check() error {
|
|
if v, ok := _u.mutation.Content(); ok {
|
|
if err := task.ContentValidator(v); err != nil {
|
|
return &ValidationError{Name: "content", err: fmt.Errorf(`db: validator failed for field "Task.content": %w`, err)}
|
|
}
|
|
}
|
|
if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "Task.user"`)
|
|
}
|
|
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(task.Table, task.Columns, sqlgraph.NewFieldSpec(task.FieldID, field.TypeUUID))
|
|
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.DeletedAt(); ok {
|
|
_spec.SetField(task.FieldDeletedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.DeletedAtCleared() {
|
|
_spec.ClearField(task.FieldDeletedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Kind(); ok {
|
|
_spec.SetField(task.FieldKind, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.SubType(); ok {
|
|
_spec.SetField(task.FieldSubType, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SubTypeCleared() {
|
|
_spec.ClearField(task.FieldSubType, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Content(); ok {
|
|
_spec.SetField(task.FieldContent, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Title(); ok {
|
|
_spec.SetField(task.FieldTitle, field.TypeString, value)
|
|
}
|
|
if _u.mutation.TitleCleared() {
|
|
_spec.ClearField(task.FieldTitle, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Summary(); ok {
|
|
_spec.SetField(task.FieldSummary, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SummaryCleared() {
|
|
_spec.ClearField(task.FieldSummary, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(task.FieldStatus, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.LogStore(); ok {
|
|
_spec.SetField(task.FieldLogStore, field.TypeString, value)
|
|
}
|
|
if _u.mutation.LogStoreCleared() {
|
|
_spec.ClearField(task.FieldLogStore, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(task.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.LastActiveAt(); ok {
|
|
_spec.SetField(task.FieldLastActiveAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(task.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.CompletedAt(); ok {
|
|
_spec.SetField(task.FieldCompletedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.CompletedAtCleared() {
|
|
_spec.ClearField(task.FieldCompletedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.SkillIds(); ok {
|
|
_spec.SetField(task.FieldSkillIds, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedSkillIds(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, task.FieldSkillIds, value)
|
|
})
|
|
}
|
|
if _u.mutation.SkillIdsCleared() {
|
|
_spec.ClearField(task.FieldSkillIds, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.PluginIds(); ok {
|
|
_spec.SetField(task.FieldPluginIds, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedPluginIds(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, task.FieldPluginIds, value)
|
|
})
|
|
}
|
|
if _u.mutation.PluginIdsCleared() {
|
|
_spec.ClearField(task.FieldPluginIds, field.TypeJSON)
|
|
}
|
|
if _u.mutation.ProjectTasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: task.ProjectTasksTable,
|
|
Columns: []string{task.ProjectTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projecttask.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedProjectTasksIDs(); len(nodes) > 0 && !_u.mutation.ProjectTasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: task.ProjectTasksTable,
|
|
Columns: []string{task.ProjectTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projecttask.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.ProjectTasksIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: task.ProjectTasksTable,
|
|
Columns: []string{task.ProjectTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projecttask.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.GitTasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2O,
|
|
Inverse: false,
|
|
Table: task.GitTasksTable,
|
|
Columns: []string{task.GitTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(gittask.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.GitTasksIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2O,
|
|
Inverse: false,
|
|
Table: task.GitTasksTable,
|
|
Columns: []string{task.GitTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(gittask.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.UserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: task.UserTable,
|
|
Columns: []string{task.UserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.UserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: task.UserTable,
|
|
Columns: []string{task.UserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.VmsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: task.VmsTable,
|
|
Columns: task.VmsPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(virtualmachine.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
createE := &TaskVirtualMachineCreate{config: _u.config, mutation: newTaskVirtualMachineMutation(_u.config, OpCreate)}
|
|
createE.defaults()
|
|
_, specE := createE.createSpec()
|
|
edge.Target.Fields = specE.Fields
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedVmsIDs(); len(nodes) > 0 && !_u.mutation.VmsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: task.VmsTable,
|
|
Columns: task.VmsPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(virtualmachine.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
createE := &TaskVirtualMachineCreate{config: _u.config, mutation: newTaskVirtualMachineMutation(_u.config, OpCreate)}
|
|
createE.defaults()
|
|
_, specE := createE.createSpec()
|
|
edge.Target.Fields = specE.Fields
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.VmsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: task.VmsTable,
|
|
Columns: task.VmsPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(virtualmachine.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
createE := &TaskVirtualMachineCreate{config: _u.config, mutation: newTaskVirtualMachineMutation(_u.config, OpCreate)}
|
|
createE.defaults()
|
|
_, specE := createE.createSpec()
|
|
edge.Target.Fields = specE.Fields
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.GitBotTasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: task.GitBotTasksTable,
|
|
Columns: []string{task.GitBotTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(gitbottask.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedGitBotTasksIDs(); len(nodes) > 0 && !_u.mutation.GitBotTasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: task.GitBotTasksTable,
|
|
Columns: []string{task.GitBotTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(gitbottask.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.GitBotTasksIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: task.GitBotTasksTable,
|
|
Columns: []string{task.GitBotTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(gitbottask.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.ModelSwitchesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: task.ModelSwitchesTable,
|
|
Columns: []string{task.ModelSwitchesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(taskmodelswitch.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedModelSwitchesIDs(); len(nodes) > 0 && !_u.mutation.ModelSwitchesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: task.ModelSwitchesTable,
|
|
Columns: []string{task.ModelSwitchesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(taskmodelswitch.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.ModelSwitchesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: task.ModelSwitchesTable,
|
|
Columns: []string{task.ModelSwitchesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(taskmodelswitch.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.TaskVmsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
Table: task.TaskVmsTable,
|
|
Columns: []string{task.TaskVmsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(taskvirtualmachine.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedTaskVmsIDs(); len(nodes) > 0 && !_u.mutation.TaskVmsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
Table: task.TaskVmsTable,
|
|
Columns: []string{task.TaskVmsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(taskvirtualmachine.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.TaskVmsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
Table: task.TaskVmsTable,
|
|
Columns: []string{task.TaskVmsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(taskvirtualmachine.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{task.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)
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (_u *TaskUpdateOne) SetDeletedAt(v time.Time) *TaskUpdateOne {
|
|
_u.mutation.SetDeletedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (_u *TaskUpdateOne) SetNillableDeletedAt(v *time.Time) *TaskUpdateOne {
|
|
if v != nil {
|
|
_u.SetDeletedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (_u *TaskUpdateOne) ClearDeletedAt() *TaskUpdateOne {
|
|
_u.mutation.ClearDeletedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_u *TaskUpdateOne) SetUserID(v uuid.UUID) *TaskUpdateOne {
|
|
_u.mutation.SetUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
|
func (_u *TaskUpdateOne) SetNillableUserID(v *uuid.UUID) *TaskUpdateOne {
|
|
if v != nil {
|
|
_u.SetUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetKind sets the "kind" field.
|
|
func (_u *TaskUpdateOne) SetKind(v consts.TaskType) *TaskUpdateOne {
|
|
_u.mutation.SetKind(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableKind sets the "kind" field if the given value is not nil.
|
|
func (_u *TaskUpdateOne) SetNillableKind(v *consts.TaskType) *TaskUpdateOne {
|
|
if v != nil {
|
|
_u.SetKind(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSubType sets the "sub_type" field.
|
|
func (_u *TaskUpdateOne) SetSubType(v consts.TaskSubType) *TaskUpdateOne {
|
|
_u.mutation.SetSubType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSubType sets the "sub_type" field if the given value is not nil.
|
|
func (_u *TaskUpdateOne) SetNillableSubType(v *consts.TaskSubType) *TaskUpdateOne {
|
|
if v != nil {
|
|
_u.SetSubType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSubType clears the value of the "sub_type" field.
|
|
func (_u *TaskUpdateOne) ClearSubType() *TaskUpdateOne {
|
|
_u.mutation.ClearSubType()
|
|
return _u
|
|
}
|
|
|
|
// SetContent sets the "content" field.
|
|
func (_u *TaskUpdateOne) SetContent(v string) *TaskUpdateOne {
|
|
_u.mutation.SetContent(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableContent sets the "content" field if the given value is not nil.
|
|
func (_u *TaskUpdateOne) SetNillableContent(v *string) *TaskUpdateOne {
|
|
if v != nil {
|
|
_u.SetContent(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTitle sets the "title" field.
|
|
func (_u *TaskUpdateOne) SetTitle(v string) *TaskUpdateOne {
|
|
_u.mutation.SetTitle(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTitle sets the "title" field if the given value is not nil.
|
|
func (_u *TaskUpdateOne) SetNillableTitle(v *string) *TaskUpdateOne {
|
|
if v != nil {
|
|
_u.SetTitle(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearTitle clears the value of the "title" field.
|
|
func (_u *TaskUpdateOne) ClearTitle() *TaskUpdateOne {
|
|
_u.mutation.ClearTitle()
|
|
return _u
|
|
}
|
|
|
|
// SetSummary sets the "summary" field.
|
|
func (_u *TaskUpdateOne) SetSummary(v string) *TaskUpdateOne {
|
|
_u.mutation.SetSummary(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSummary sets the "summary" field if the given value is not nil.
|
|
func (_u *TaskUpdateOne) SetNillableSummary(v *string) *TaskUpdateOne {
|
|
if v != nil {
|
|
_u.SetSummary(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSummary clears the value of the "summary" field.
|
|
func (_u *TaskUpdateOne) ClearSummary() *TaskUpdateOne {
|
|
_u.mutation.ClearSummary()
|
|
return _u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_u *TaskUpdateOne) SetStatus(v consts.TaskStatus) *TaskUpdateOne {
|
|
_u.mutation.SetStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_u *TaskUpdateOne) SetNillableStatus(v *consts.TaskStatus) *TaskUpdateOne {
|
|
if v != nil {
|
|
_u.SetStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetLogStore sets the "log_store" field.
|
|
func (_u *TaskUpdateOne) SetLogStore(v consts.LogStore) *TaskUpdateOne {
|
|
_u.mutation.SetLogStore(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLogStore sets the "log_store" field if the given value is not nil.
|
|
func (_u *TaskUpdateOne) SetNillableLogStore(v *consts.LogStore) *TaskUpdateOne {
|
|
if v != nil {
|
|
_u.SetLogStore(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearLogStore clears the value of the "log_store" field.
|
|
func (_u *TaskUpdateOne) ClearLogStore() *TaskUpdateOne {
|
|
_u.mutation.ClearLogStore()
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *TaskUpdateOne) SetCreatedAt(v time.Time) *TaskUpdateOne {
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *TaskUpdateOne) SetNillableCreatedAt(v *time.Time) *TaskUpdateOne {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetLastActiveAt sets the "last_active_at" field.
|
|
func (_u *TaskUpdateOne) SetLastActiveAt(v time.Time) *TaskUpdateOne {
|
|
_u.mutation.SetLastActiveAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLastActiveAt sets the "last_active_at" field if the given value is not nil.
|
|
func (_u *TaskUpdateOne) SetNillableLastActiveAt(v *time.Time) *TaskUpdateOne {
|
|
if v != nil {
|
|
_u.SetLastActiveAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *TaskUpdateOne) SetUpdatedAt(v time.Time) *TaskUpdateOne {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetCompletedAt sets the "completed_at" field.
|
|
func (_u *TaskUpdateOne) SetCompletedAt(v time.Time) *TaskUpdateOne {
|
|
_u.mutation.SetCompletedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCompletedAt sets the "completed_at" field if the given value is not nil.
|
|
func (_u *TaskUpdateOne) SetNillableCompletedAt(v *time.Time) *TaskUpdateOne {
|
|
if v != nil {
|
|
_u.SetCompletedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearCompletedAt clears the value of the "completed_at" field.
|
|
func (_u *TaskUpdateOne) ClearCompletedAt() *TaskUpdateOne {
|
|
_u.mutation.ClearCompletedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetSkillIds sets the "skill_ids" field.
|
|
func (_u *TaskUpdateOne) SetSkillIds(v []string) *TaskUpdateOne {
|
|
_u.mutation.SetSkillIds(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendSkillIds appends value to the "skill_ids" field.
|
|
func (_u *TaskUpdateOne) AppendSkillIds(v []string) *TaskUpdateOne {
|
|
_u.mutation.AppendSkillIds(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearSkillIds clears the value of the "skill_ids" field.
|
|
func (_u *TaskUpdateOne) ClearSkillIds() *TaskUpdateOne {
|
|
_u.mutation.ClearSkillIds()
|
|
return _u
|
|
}
|
|
|
|
// SetPluginIds sets the "plugin_ids" field.
|
|
func (_u *TaskUpdateOne) SetPluginIds(v []string) *TaskUpdateOne {
|
|
_u.mutation.SetPluginIds(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendPluginIds appends value to the "plugin_ids" field.
|
|
func (_u *TaskUpdateOne) AppendPluginIds(v []string) *TaskUpdateOne {
|
|
_u.mutation.AppendPluginIds(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearPluginIds clears the value of the "plugin_ids" field.
|
|
func (_u *TaskUpdateOne) ClearPluginIds() *TaskUpdateOne {
|
|
_u.mutation.ClearPluginIds()
|
|
return _u
|
|
}
|
|
|
|
// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by IDs.
|
|
func (_u *TaskUpdateOne) AddProjectTaskIDs(ids ...uuid.UUID) *TaskUpdateOne {
|
|
_u.mutation.AddProjectTaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddProjectTasks adds the "project_tasks" edges to the ProjectTask entity.
|
|
func (_u *TaskUpdateOne) AddProjectTasks(v ...*ProjectTask) *TaskUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddProjectTaskIDs(ids...)
|
|
}
|
|
|
|
// SetGitTasksID sets the "git_tasks" edge to the GitTask entity by ID.
|
|
func (_u *TaskUpdateOne) SetGitTasksID(id uuid.UUID) *TaskUpdateOne {
|
|
_u.mutation.SetGitTasksID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableGitTasksID sets the "git_tasks" edge to the GitTask entity by ID if the given value is not nil.
|
|
func (_u *TaskUpdateOne) SetNillableGitTasksID(id *uuid.UUID) *TaskUpdateOne {
|
|
if id != nil {
|
|
_u = _u.SetGitTasksID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetGitTasks sets the "git_tasks" edge to the GitTask entity.
|
|
func (_u *TaskUpdateOne) SetGitTasks(v *GitTask) *TaskUpdateOne {
|
|
return _u.SetGitTasksID(v.ID)
|
|
}
|
|
|
|
// SetUser sets the "user" edge to the User entity.
|
|
func (_u *TaskUpdateOne) SetUser(v *User) *TaskUpdateOne {
|
|
return _u.SetUserID(v.ID)
|
|
}
|
|
|
|
// AddVMIDs adds the "vms" edge to the VirtualMachine entity by IDs.
|
|
func (_u *TaskUpdateOne) AddVMIDs(ids ...string) *TaskUpdateOne {
|
|
_u.mutation.AddVMIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddVms adds the "vms" edges to the VirtualMachine entity.
|
|
func (_u *TaskUpdateOne) AddVms(v ...*VirtualMachine) *TaskUpdateOne {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddVMIDs(ids...)
|
|
}
|
|
|
|
// AddGitBotTaskIDs adds the "git_bot_tasks" edge to the GitBotTask entity by IDs.
|
|
func (_u *TaskUpdateOne) AddGitBotTaskIDs(ids ...uuid.UUID) *TaskUpdateOne {
|
|
_u.mutation.AddGitBotTaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddGitBotTasks adds the "git_bot_tasks" edges to the GitBotTask entity.
|
|
func (_u *TaskUpdateOne) AddGitBotTasks(v ...*GitBotTask) *TaskUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddGitBotTaskIDs(ids...)
|
|
}
|
|
|
|
// AddModelSwitchIDs adds the "model_switches" edge to the TaskModelSwitch entity by IDs.
|
|
func (_u *TaskUpdateOne) AddModelSwitchIDs(ids ...uuid.UUID) *TaskUpdateOne {
|
|
_u.mutation.AddModelSwitchIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddModelSwitches adds the "model_switches" edges to the TaskModelSwitch entity.
|
|
func (_u *TaskUpdateOne) AddModelSwitches(v ...*TaskModelSwitch) *TaskUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddModelSwitchIDs(ids...)
|
|
}
|
|
|
|
// AddTaskVMIDs adds the "task_vms" edge to the TaskVirtualMachine entity by IDs.
|
|
func (_u *TaskUpdateOne) AddTaskVMIDs(ids ...uuid.UUID) *TaskUpdateOne {
|
|
_u.mutation.AddTaskVMIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddTaskVms adds the "task_vms" edges to the TaskVirtualMachine entity.
|
|
func (_u *TaskUpdateOne) AddTaskVms(v ...*TaskVirtualMachine) *TaskUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddTaskVMIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the TaskMutation object of the builder.
|
|
func (_u *TaskUpdateOne) Mutation() *TaskMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearProjectTasks clears all "project_tasks" edges to the ProjectTask entity.
|
|
func (_u *TaskUpdateOne) ClearProjectTasks() *TaskUpdateOne {
|
|
_u.mutation.ClearProjectTasks()
|
|
return _u
|
|
}
|
|
|
|
// RemoveProjectTaskIDs removes the "project_tasks" edge to ProjectTask entities by IDs.
|
|
func (_u *TaskUpdateOne) RemoveProjectTaskIDs(ids ...uuid.UUID) *TaskUpdateOne {
|
|
_u.mutation.RemoveProjectTaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveProjectTasks removes "project_tasks" edges to ProjectTask entities.
|
|
func (_u *TaskUpdateOne) RemoveProjectTasks(v ...*ProjectTask) *TaskUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveProjectTaskIDs(ids...)
|
|
}
|
|
|
|
// ClearGitTasks clears the "git_tasks" edge to the GitTask entity.
|
|
func (_u *TaskUpdateOne) ClearGitTasks() *TaskUpdateOne {
|
|
_u.mutation.ClearGitTasks()
|
|
return _u
|
|
}
|
|
|
|
// ClearUser clears the "user" edge to the User entity.
|
|
func (_u *TaskUpdateOne) ClearUser() *TaskUpdateOne {
|
|
_u.mutation.ClearUser()
|
|
return _u
|
|
}
|
|
|
|
// ClearVms clears all "vms" edges to the VirtualMachine entity.
|
|
func (_u *TaskUpdateOne) ClearVms() *TaskUpdateOne {
|
|
_u.mutation.ClearVms()
|
|
return _u
|
|
}
|
|
|
|
// RemoveVMIDs removes the "vms" edge to VirtualMachine entities by IDs.
|
|
func (_u *TaskUpdateOne) RemoveVMIDs(ids ...string) *TaskUpdateOne {
|
|
_u.mutation.RemoveVMIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveVms removes "vms" edges to VirtualMachine entities.
|
|
func (_u *TaskUpdateOne) RemoveVms(v ...*VirtualMachine) *TaskUpdateOne {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveVMIDs(ids...)
|
|
}
|
|
|
|
// ClearGitBotTasks clears all "git_bot_tasks" edges to the GitBotTask entity.
|
|
func (_u *TaskUpdateOne) ClearGitBotTasks() *TaskUpdateOne {
|
|
_u.mutation.ClearGitBotTasks()
|
|
return _u
|
|
}
|
|
|
|
// RemoveGitBotTaskIDs removes the "git_bot_tasks" edge to GitBotTask entities by IDs.
|
|
func (_u *TaskUpdateOne) RemoveGitBotTaskIDs(ids ...uuid.UUID) *TaskUpdateOne {
|
|
_u.mutation.RemoveGitBotTaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveGitBotTasks removes "git_bot_tasks" edges to GitBotTask entities.
|
|
func (_u *TaskUpdateOne) RemoveGitBotTasks(v ...*GitBotTask) *TaskUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveGitBotTaskIDs(ids...)
|
|
}
|
|
|
|
// ClearModelSwitches clears all "model_switches" edges to the TaskModelSwitch entity.
|
|
func (_u *TaskUpdateOne) ClearModelSwitches() *TaskUpdateOne {
|
|
_u.mutation.ClearModelSwitches()
|
|
return _u
|
|
}
|
|
|
|
// RemoveModelSwitchIDs removes the "model_switches" edge to TaskModelSwitch entities by IDs.
|
|
func (_u *TaskUpdateOne) RemoveModelSwitchIDs(ids ...uuid.UUID) *TaskUpdateOne {
|
|
_u.mutation.RemoveModelSwitchIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveModelSwitches removes "model_switches" edges to TaskModelSwitch entities.
|
|
func (_u *TaskUpdateOne) RemoveModelSwitches(v ...*TaskModelSwitch) *TaskUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveModelSwitchIDs(ids...)
|
|
}
|
|
|
|
// ClearTaskVms clears all "task_vms" edges to the TaskVirtualMachine entity.
|
|
func (_u *TaskUpdateOne) ClearTaskVms() *TaskUpdateOne {
|
|
_u.mutation.ClearTaskVms()
|
|
return _u
|
|
}
|
|
|
|
// RemoveTaskVMIDs removes the "task_vms" edge to TaskVirtualMachine entities by IDs.
|
|
func (_u *TaskUpdateOne) RemoveTaskVMIDs(ids ...uuid.UUID) *TaskUpdateOne {
|
|
_u.mutation.RemoveTaskVMIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveTaskVms removes "task_vms" edges to TaskVirtualMachine entities.
|
|
func (_u *TaskUpdateOne) RemoveTaskVms(v ...*TaskVirtualMachine) *TaskUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveTaskVMIDs(ids...)
|
|
}
|
|
|
|
// 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) {
|
|
if err := _u.defaults(); err != nil {
|
|
return nil, err
|
|
}
|
|
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)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *TaskUpdateOne) defaults() error {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
if task.UpdateDefaultUpdatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized task.UpdateDefaultUpdatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := task.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *TaskUpdateOne) check() error {
|
|
if v, ok := _u.mutation.Content(); ok {
|
|
if err := task.ContentValidator(v); err != nil {
|
|
return &ValidationError{Name: "content", err: fmt.Errorf(`db: validator failed for field "Task.content": %w`, err)}
|
|
}
|
|
}
|
|
if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "Task.user"`)
|
|
}
|
|
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(task.Table, task.Columns, sqlgraph.NewFieldSpec(task.FieldID, field.TypeUUID))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: 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, task.FieldID)
|
|
for _, f := range fields {
|
|
if !task.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)}
|
|
}
|
|
if f != task.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.DeletedAt(); ok {
|
|
_spec.SetField(task.FieldDeletedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.DeletedAtCleared() {
|
|
_spec.ClearField(task.FieldDeletedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Kind(); ok {
|
|
_spec.SetField(task.FieldKind, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.SubType(); ok {
|
|
_spec.SetField(task.FieldSubType, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SubTypeCleared() {
|
|
_spec.ClearField(task.FieldSubType, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Content(); ok {
|
|
_spec.SetField(task.FieldContent, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Title(); ok {
|
|
_spec.SetField(task.FieldTitle, field.TypeString, value)
|
|
}
|
|
if _u.mutation.TitleCleared() {
|
|
_spec.ClearField(task.FieldTitle, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Summary(); ok {
|
|
_spec.SetField(task.FieldSummary, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SummaryCleared() {
|
|
_spec.ClearField(task.FieldSummary, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(task.FieldStatus, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.LogStore(); ok {
|
|
_spec.SetField(task.FieldLogStore, field.TypeString, value)
|
|
}
|
|
if _u.mutation.LogStoreCleared() {
|
|
_spec.ClearField(task.FieldLogStore, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(task.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.LastActiveAt(); ok {
|
|
_spec.SetField(task.FieldLastActiveAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(task.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.CompletedAt(); ok {
|
|
_spec.SetField(task.FieldCompletedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.CompletedAtCleared() {
|
|
_spec.ClearField(task.FieldCompletedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.SkillIds(); ok {
|
|
_spec.SetField(task.FieldSkillIds, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedSkillIds(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, task.FieldSkillIds, value)
|
|
})
|
|
}
|
|
if _u.mutation.SkillIdsCleared() {
|
|
_spec.ClearField(task.FieldSkillIds, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.PluginIds(); ok {
|
|
_spec.SetField(task.FieldPluginIds, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedPluginIds(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, task.FieldPluginIds, value)
|
|
})
|
|
}
|
|
if _u.mutation.PluginIdsCleared() {
|
|
_spec.ClearField(task.FieldPluginIds, field.TypeJSON)
|
|
}
|
|
if _u.mutation.ProjectTasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: task.ProjectTasksTable,
|
|
Columns: []string{task.ProjectTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projecttask.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedProjectTasksIDs(); len(nodes) > 0 && !_u.mutation.ProjectTasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: task.ProjectTasksTable,
|
|
Columns: []string{task.ProjectTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projecttask.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.ProjectTasksIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: task.ProjectTasksTable,
|
|
Columns: []string{task.ProjectTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projecttask.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.GitTasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2O,
|
|
Inverse: false,
|
|
Table: task.GitTasksTable,
|
|
Columns: []string{task.GitTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(gittask.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.GitTasksIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2O,
|
|
Inverse: false,
|
|
Table: task.GitTasksTable,
|
|
Columns: []string{task.GitTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(gittask.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.UserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: task.UserTable,
|
|
Columns: []string{task.UserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.UserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: task.UserTable,
|
|
Columns: []string{task.UserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.VmsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: task.VmsTable,
|
|
Columns: task.VmsPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(virtualmachine.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
createE := &TaskVirtualMachineCreate{config: _u.config, mutation: newTaskVirtualMachineMutation(_u.config, OpCreate)}
|
|
createE.defaults()
|
|
_, specE := createE.createSpec()
|
|
edge.Target.Fields = specE.Fields
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedVmsIDs(); len(nodes) > 0 && !_u.mutation.VmsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: task.VmsTable,
|
|
Columns: task.VmsPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(virtualmachine.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
createE := &TaskVirtualMachineCreate{config: _u.config, mutation: newTaskVirtualMachineMutation(_u.config, OpCreate)}
|
|
createE.defaults()
|
|
_, specE := createE.createSpec()
|
|
edge.Target.Fields = specE.Fields
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.VmsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: task.VmsTable,
|
|
Columns: task.VmsPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(virtualmachine.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
createE := &TaskVirtualMachineCreate{config: _u.config, mutation: newTaskVirtualMachineMutation(_u.config, OpCreate)}
|
|
createE.defaults()
|
|
_, specE := createE.createSpec()
|
|
edge.Target.Fields = specE.Fields
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.GitBotTasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: task.GitBotTasksTable,
|
|
Columns: []string{task.GitBotTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(gitbottask.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedGitBotTasksIDs(); len(nodes) > 0 && !_u.mutation.GitBotTasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: task.GitBotTasksTable,
|
|
Columns: []string{task.GitBotTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(gitbottask.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.GitBotTasksIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: task.GitBotTasksTable,
|
|
Columns: []string{task.GitBotTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(gitbottask.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.ModelSwitchesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: task.ModelSwitchesTable,
|
|
Columns: []string{task.ModelSwitchesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(taskmodelswitch.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedModelSwitchesIDs(); len(nodes) > 0 && !_u.mutation.ModelSwitchesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: task.ModelSwitchesTable,
|
|
Columns: []string{task.ModelSwitchesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(taskmodelswitch.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.ModelSwitchesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: task.ModelSwitchesTable,
|
|
Columns: []string{task.ModelSwitchesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(taskmodelswitch.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.TaskVmsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
Table: task.TaskVmsTable,
|
|
Columns: []string{task.TaskVmsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(taskvirtualmachine.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedTaskVmsIDs(); len(nodes) > 0 && !_u.mutation.TaskVmsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
Table: task.TaskVmsTable,
|
|
Columns: []string{task.TaskVmsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(taskvirtualmachine.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.TaskVmsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
Table: task.TaskVmsTable,
|
|
Columns: []string{task.TaskVmsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(taskvirtualmachine.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_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{task.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|