mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-22 19:39:31 +08:00
1309 lines
40 KiB
Go
1309 lines
40 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/schema/field"
|
|
"github.com/chaitin/MonkeyCode/backend/consts"
|
|
"github.com/chaitin/MonkeyCode/backend/db/predicate"
|
|
"github.com/chaitin/MonkeyCode/backend/db/project"
|
|
"github.com/chaitin/MonkeyCode/backend/db/projectissue"
|
|
"github.com/chaitin/MonkeyCode/backend/db/projectissuecomment"
|
|
"github.com/chaitin/MonkeyCode/backend/db/projecttask"
|
|
"github.com/chaitin/MonkeyCode/backend/db/user"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// ProjectIssueUpdate is the builder for updating ProjectIssue entities.
|
|
type ProjectIssueUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *ProjectIssueMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// Where appends a list predicates to the ProjectIssueUpdate builder.
|
|
func (_u *ProjectIssueUpdate) Where(ps ...predicate.ProjectIssue) *ProjectIssueUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (_u *ProjectIssueUpdate) SetDeletedAt(v time.Time) *ProjectIssueUpdate {
|
|
_u.mutation.SetDeletedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdate) SetNillableDeletedAt(v *time.Time) *ProjectIssueUpdate {
|
|
if v != nil {
|
|
_u.SetDeletedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (_u *ProjectIssueUpdate) ClearDeletedAt() *ProjectIssueUpdate {
|
|
_u.mutation.ClearDeletedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_u *ProjectIssueUpdate) SetUserID(v uuid.UUID) *ProjectIssueUpdate {
|
|
_u.mutation.SetUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdate) SetNillableUserID(v *uuid.UUID) *ProjectIssueUpdate {
|
|
if v != nil {
|
|
_u.SetUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetProjectID sets the "project_id" field.
|
|
func (_u *ProjectIssueUpdate) SetProjectID(v uuid.UUID) *ProjectIssueUpdate {
|
|
_u.mutation.SetProjectID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableProjectID sets the "project_id" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdate) SetNillableProjectID(v *uuid.UUID) *ProjectIssueUpdate {
|
|
if v != nil {
|
|
_u.SetProjectID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_u *ProjectIssueUpdate) SetStatus(v consts.ProjectIssueStatus) *ProjectIssueUpdate {
|
|
_u.mutation.SetStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdate) SetNillableStatus(v *consts.ProjectIssueStatus) *ProjectIssueUpdate {
|
|
if v != nil {
|
|
_u.SetStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTitle sets the "title" field.
|
|
func (_u *ProjectIssueUpdate) SetTitle(v string) *ProjectIssueUpdate {
|
|
_u.mutation.SetTitle(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTitle sets the "title" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdate) SetNillableTitle(v *string) *ProjectIssueUpdate {
|
|
if v != nil {
|
|
_u.SetTitle(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetRequirementDocument sets the "requirement_document" field.
|
|
func (_u *ProjectIssueUpdate) SetRequirementDocument(v string) *ProjectIssueUpdate {
|
|
_u.mutation.SetRequirementDocument(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRequirementDocument sets the "requirement_document" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdate) SetNillableRequirementDocument(v *string) *ProjectIssueUpdate {
|
|
if v != nil {
|
|
_u.SetRequirementDocument(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearRequirementDocument clears the value of the "requirement_document" field.
|
|
func (_u *ProjectIssueUpdate) ClearRequirementDocument() *ProjectIssueUpdate {
|
|
_u.mutation.ClearRequirementDocument()
|
|
return _u
|
|
}
|
|
|
|
// SetDesignDocument sets the "design_document" field.
|
|
func (_u *ProjectIssueUpdate) SetDesignDocument(v string) *ProjectIssueUpdate {
|
|
_u.mutation.SetDesignDocument(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDesignDocument sets the "design_document" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdate) SetNillableDesignDocument(v *string) *ProjectIssueUpdate {
|
|
if v != nil {
|
|
_u.SetDesignDocument(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDesignDocument clears the value of the "design_document" field.
|
|
func (_u *ProjectIssueUpdate) ClearDesignDocument() *ProjectIssueUpdate {
|
|
_u.mutation.ClearDesignDocument()
|
|
return _u
|
|
}
|
|
|
|
// SetSummary sets the "summary" field.
|
|
func (_u *ProjectIssueUpdate) SetSummary(v string) *ProjectIssueUpdate {
|
|
_u.mutation.SetSummary(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSummary sets the "summary" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdate) SetNillableSummary(v *string) *ProjectIssueUpdate {
|
|
if v != nil {
|
|
_u.SetSummary(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSummary clears the value of the "summary" field.
|
|
func (_u *ProjectIssueUpdate) ClearSummary() *ProjectIssueUpdate {
|
|
_u.mutation.ClearSummary()
|
|
return _u
|
|
}
|
|
|
|
// SetAssigneeID sets the "assignee_id" field.
|
|
func (_u *ProjectIssueUpdate) SetAssigneeID(v uuid.UUID) *ProjectIssueUpdate {
|
|
_u.mutation.SetAssigneeID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAssigneeID sets the "assignee_id" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdate) SetNillableAssigneeID(v *uuid.UUID) *ProjectIssueUpdate {
|
|
if v != nil {
|
|
_u.SetAssigneeID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearAssigneeID clears the value of the "assignee_id" field.
|
|
func (_u *ProjectIssueUpdate) ClearAssigneeID() *ProjectIssueUpdate {
|
|
_u.mutation.ClearAssigneeID()
|
|
return _u
|
|
}
|
|
|
|
// SetPriority sets the "priority" field.
|
|
func (_u *ProjectIssueUpdate) SetPriority(v consts.ProjectIssuePriority) *ProjectIssueUpdate {
|
|
_u.mutation.ResetPriority()
|
|
_u.mutation.SetPriority(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePriority sets the "priority" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdate) SetNillablePriority(v *consts.ProjectIssuePriority) *ProjectIssueUpdate {
|
|
if v != nil {
|
|
_u.SetPriority(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddPriority adds value to the "priority" field.
|
|
func (_u *ProjectIssueUpdate) AddPriority(v consts.ProjectIssuePriority) *ProjectIssueUpdate {
|
|
_u.mutation.AddPriority(v)
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *ProjectIssueUpdate) SetCreatedAt(v time.Time) *ProjectIssueUpdate {
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdate) SetNillableCreatedAt(v *time.Time) *ProjectIssueUpdate {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *ProjectIssueUpdate) SetUpdatedAt(v time.Time) *ProjectIssueUpdate {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetUser sets the "user" edge to the User entity.
|
|
func (_u *ProjectIssueUpdate) SetUser(v *User) *ProjectIssueUpdate {
|
|
return _u.SetUserID(v.ID)
|
|
}
|
|
|
|
// SetAssignee sets the "assignee" edge to the User entity.
|
|
func (_u *ProjectIssueUpdate) SetAssignee(v *User) *ProjectIssueUpdate {
|
|
return _u.SetAssigneeID(v.ID)
|
|
}
|
|
|
|
// SetProject sets the "project" edge to the Project entity.
|
|
func (_u *ProjectIssueUpdate) SetProject(v *Project) *ProjectIssueUpdate {
|
|
return _u.SetProjectID(v.ID)
|
|
}
|
|
|
|
// AddCommentIDs adds the "comments" edge to the ProjectIssueComment entity by IDs.
|
|
func (_u *ProjectIssueUpdate) AddCommentIDs(ids ...uuid.UUID) *ProjectIssueUpdate {
|
|
_u.mutation.AddCommentIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddComments adds the "comments" edges to the ProjectIssueComment entity.
|
|
func (_u *ProjectIssueUpdate) AddComments(v ...*ProjectIssueComment) *ProjectIssueUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddCommentIDs(ids...)
|
|
}
|
|
|
|
// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by IDs.
|
|
func (_u *ProjectIssueUpdate) AddProjectTaskIDs(ids ...uuid.UUID) *ProjectIssueUpdate {
|
|
_u.mutation.AddProjectTaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddProjectTasks adds the "project_tasks" edges to the ProjectTask entity.
|
|
func (_u *ProjectIssueUpdate) AddProjectTasks(v ...*ProjectTask) *ProjectIssueUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddProjectTaskIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the ProjectIssueMutation object of the builder.
|
|
func (_u *ProjectIssueUpdate) Mutation() *ProjectIssueMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearUser clears the "user" edge to the User entity.
|
|
func (_u *ProjectIssueUpdate) ClearUser() *ProjectIssueUpdate {
|
|
_u.mutation.ClearUser()
|
|
return _u
|
|
}
|
|
|
|
// ClearAssignee clears the "assignee" edge to the User entity.
|
|
func (_u *ProjectIssueUpdate) ClearAssignee() *ProjectIssueUpdate {
|
|
_u.mutation.ClearAssignee()
|
|
return _u
|
|
}
|
|
|
|
// ClearProject clears the "project" edge to the Project entity.
|
|
func (_u *ProjectIssueUpdate) ClearProject() *ProjectIssueUpdate {
|
|
_u.mutation.ClearProject()
|
|
return _u
|
|
}
|
|
|
|
// ClearComments clears all "comments" edges to the ProjectIssueComment entity.
|
|
func (_u *ProjectIssueUpdate) ClearComments() *ProjectIssueUpdate {
|
|
_u.mutation.ClearComments()
|
|
return _u
|
|
}
|
|
|
|
// RemoveCommentIDs removes the "comments" edge to ProjectIssueComment entities by IDs.
|
|
func (_u *ProjectIssueUpdate) RemoveCommentIDs(ids ...uuid.UUID) *ProjectIssueUpdate {
|
|
_u.mutation.RemoveCommentIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveComments removes "comments" edges to ProjectIssueComment entities.
|
|
func (_u *ProjectIssueUpdate) RemoveComments(v ...*ProjectIssueComment) *ProjectIssueUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveCommentIDs(ids...)
|
|
}
|
|
|
|
// ClearProjectTasks clears all "project_tasks" edges to the ProjectTask entity.
|
|
func (_u *ProjectIssueUpdate) ClearProjectTasks() *ProjectIssueUpdate {
|
|
_u.mutation.ClearProjectTasks()
|
|
return _u
|
|
}
|
|
|
|
// RemoveProjectTaskIDs removes the "project_tasks" edge to ProjectTask entities by IDs.
|
|
func (_u *ProjectIssueUpdate) RemoveProjectTaskIDs(ids ...uuid.UUID) *ProjectIssueUpdate {
|
|
_u.mutation.RemoveProjectTaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveProjectTasks removes "project_tasks" edges to ProjectTask entities.
|
|
func (_u *ProjectIssueUpdate) RemoveProjectTasks(v ...*ProjectTask) *ProjectIssueUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveProjectTaskIDs(ids...)
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *ProjectIssueUpdate) 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 *ProjectIssueUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *ProjectIssueUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *ProjectIssueUpdate) 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 *ProjectIssueUpdate) defaults() error {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
if projectissue.UpdateDefaultUpdatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized projectissue.UpdateDefaultUpdatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := projectissue.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *ProjectIssueUpdate) check() error {
|
|
if v, ok := _u.mutation.Title(); ok {
|
|
if err := projectissue.TitleValidator(v); err != nil {
|
|
return &ValidationError{Name: "title", err: fmt.Errorf(`db: validator failed for field "ProjectIssue.title": %w`, err)}
|
|
}
|
|
}
|
|
if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "ProjectIssue.user"`)
|
|
}
|
|
if _u.mutation.ProjectCleared() && len(_u.mutation.ProjectIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "ProjectIssue.project"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *ProjectIssueUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ProjectIssueUpdate {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *ProjectIssueUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(projectissue.Table, projectissue.Columns, sqlgraph.NewFieldSpec(projectissue.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(projectissue.FieldDeletedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.DeletedAtCleared() {
|
|
_spec.ClearField(projectissue.FieldDeletedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(projectissue.FieldStatus, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Title(); ok {
|
|
_spec.SetField(projectissue.FieldTitle, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.RequirementDocument(); ok {
|
|
_spec.SetField(projectissue.FieldRequirementDocument, field.TypeString, value)
|
|
}
|
|
if _u.mutation.RequirementDocumentCleared() {
|
|
_spec.ClearField(projectissue.FieldRequirementDocument, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.DesignDocument(); ok {
|
|
_spec.SetField(projectissue.FieldDesignDocument, field.TypeString, value)
|
|
}
|
|
if _u.mutation.DesignDocumentCleared() {
|
|
_spec.ClearField(projectissue.FieldDesignDocument, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Summary(); ok {
|
|
_spec.SetField(projectissue.FieldSummary, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SummaryCleared() {
|
|
_spec.ClearField(projectissue.FieldSummary, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Priority(); ok {
|
|
_spec.SetField(projectissue.FieldPriority, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedPriority(); ok {
|
|
_spec.AddField(projectissue.FieldPriority, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(projectissue.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(projectissue.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.UserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectissue.UserTable,
|
|
Columns: []string{projectissue.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: projectissue.UserTable,
|
|
Columns: []string{projectissue.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.AssigneeCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectissue.AssigneeTable,
|
|
Columns: []string{projectissue.AssigneeColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.AssigneeIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectissue.AssigneeTable,
|
|
Columns: []string{projectissue.AssigneeColumn},
|
|
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.ProjectCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectissue.ProjectTable,
|
|
Columns: []string{projectissue.ProjectColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(project.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.ProjectIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectissue.ProjectTable,
|
|
Columns: []string{projectissue.ProjectColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(project.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.CommentsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: projectissue.CommentsTable,
|
|
Columns: []string{projectissue.CommentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projectissuecomment.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedCommentsIDs(); len(nodes) > 0 && !_u.mutation.CommentsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: projectissue.CommentsTable,
|
|
Columns: []string{projectissue.CommentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projectissuecomment.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.CommentsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: projectissue.CommentsTable,
|
|
Columns: []string{projectissue.CommentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projectissuecomment.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.ProjectTasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: projectissue.ProjectTasksTable,
|
|
Columns: []string{projectissue.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: projectissue.ProjectTasksTable,
|
|
Columns: []string{projectissue.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: projectissue.ProjectTasksTable,
|
|
Columns: []string{projectissue.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)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{projectissue.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// ProjectIssueUpdateOne is the builder for updating a single ProjectIssue entity.
|
|
type ProjectIssueUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *ProjectIssueMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (_u *ProjectIssueUpdateOne) SetDeletedAt(v time.Time) *ProjectIssueUpdateOne {
|
|
_u.mutation.SetDeletedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdateOne) SetNillableDeletedAt(v *time.Time) *ProjectIssueUpdateOne {
|
|
if v != nil {
|
|
_u.SetDeletedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (_u *ProjectIssueUpdateOne) ClearDeletedAt() *ProjectIssueUpdateOne {
|
|
_u.mutation.ClearDeletedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_u *ProjectIssueUpdateOne) SetUserID(v uuid.UUID) *ProjectIssueUpdateOne {
|
|
_u.mutation.SetUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdateOne) SetNillableUserID(v *uuid.UUID) *ProjectIssueUpdateOne {
|
|
if v != nil {
|
|
_u.SetUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetProjectID sets the "project_id" field.
|
|
func (_u *ProjectIssueUpdateOne) SetProjectID(v uuid.UUID) *ProjectIssueUpdateOne {
|
|
_u.mutation.SetProjectID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableProjectID sets the "project_id" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdateOne) SetNillableProjectID(v *uuid.UUID) *ProjectIssueUpdateOne {
|
|
if v != nil {
|
|
_u.SetProjectID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_u *ProjectIssueUpdateOne) SetStatus(v consts.ProjectIssueStatus) *ProjectIssueUpdateOne {
|
|
_u.mutation.SetStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdateOne) SetNillableStatus(v *consts.ProjectIssueStatus) *ProjectIssueUpdateOne {
|
|
if v != nil {
|
|
_u.SetStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTitle sets the "title" field.
|
|
func (_u *ProjectIssueUpdateOne) SetTitle(v string) *ProjectIssueUpdateOne {
|
|
_u.mutation.SetTitle(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTitle sets the "title" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdateOne) SetNillableTitle(v *string) *ProjectIssueUpdateOne {
|
|
if v != nil {
|
|
_u.SetTitle(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetRequirementDocument sets the "requirement_document" field.
|
|
func (_u *ProjectIssueUpdateOne) SetRequirementDocument(v string) *ProjectIssueUpdateOne {
|
|
_u.mutation.SetRequirementDocument(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRequirementDocument sets the "requirement_document" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdateOne) SetNillableRequirementDocument(v *string) *ProjectIssueUpdateOne {
|
|
if v != nil {
|
|
_u.SetRequirementDocument(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearRequirementDocument clears the value of the "requirement_document" field.
|
|
func (_u *ProjectIssueUpdateOne) ClearRequirementDocument() *ProjectIssueUpdateOne {
|
|
_u.mutation.ClearRequirementDocument()
|
|
return _u
|
|
}
|
|
|
|
// SetDesignDocument sets the "design_document" field.
|
|
func (_u *ProjectIssueUpdateOne) SetDesignDocument(v string) *ProjectIssueUpdateOne {
|
|
_u.mutation.SetDesignDocument(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDesignDocument sets the "design_document" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdateOne) SetNillableDesignDocument(v *string) *ProjectIssueUpdateOne {
|
|
if v != nil {
|
|
_u.SetDesignDocument(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDesignDocument clears the value of the "design_document" field.
|
|
func (_u *ProjectIssueUpdateOne) ClearDesignDocument() *ProjectIssueUpdateOne {
|
|
_u.mutation.ClearDesignDocument()
|
|
return _u
|
|
}
|
|
|
|
// SetSummary sets the "summary" field.
|
|
func (_u *ProjectIssueUpdateOne) SetSummary(v string) *ProjectIssueUpdateOne {
|
|
_u.mutation.SetSummary(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSummary sets the "summary" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdateOne) SetNillableSummary(v *string) *ProjectIssueUpdateOne {
|
|
if v != nil {
|
|
_u.SetSummary(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSummary clears the value of the "summary" field.
|
|
func (_u *ProjectIssueUpdateOne) ClearSummary() *ProjectIssueUpdateOne {
|
|
_u.mutation.ClearSummary()
|
|
return _u
|
|
}
|
|
|
|
// SetAssigneeID sets the "assignee_id" field.
|
|
func (_u *ProjectIssueUpdateOne) SetAssigneeID(v uuid.UUID) *ProjectIssueUpdateOne {
|
|
_u.mutation.SetAssigneeID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAssigneeID sets the "assignee_id" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdateOne) SetNillableAssigneeID(v *uuid.UUID) *ProjectIssueUpdateOne {
|
|
if v != nil {
|
|
_u.SetAssigneeID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearAssigneeID clears the value of the "assignee_id" field.
|
|
func (_u *ProjectIssueUpdateOne) ClearAssigneeID() *ProjectIssueUpdateOne {
|
|
_u.mutation.ClearAssigneeID()
|
|
return _u
|
|
}
|
|
|
|
// SetPriority sets the "priority" field.
|
|
func (_u *ProjectIssueUpdateOne) SetPriority(v consts.ProjectIssuePriority) *ProjectIssueUpdateOne {
|
|
_u.mutation.ResetPriority()
|
|
_u.mutation.SetPriority(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePriority sets the "priority" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdateOne) SetNillablePriority(v *consts.ProjectIssuePriority) *ProjectIssueUpdateOne {
|
|
if v != nil {
|
|
_u.SetPriority(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddPriority adds value to the "priority" field.
|
|
func (_u *ProjectIssueUpdateOne) AddPriority(v consts.ProjectIssuePriority) *ProjectIssueUpdateOne {
|
|
_u.mutation.AddPriority(v)
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *ProjectIssueUpdateOne) SetCreatedAt(v time.Time) *ProjectIssueUpdateOne {
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *ProjectIssueUpdateOne) SetNillableCreatedAt(v *time.Time) *ProjectIssueUpdateOne {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *ProjectIssueUpdateOne) SetUpdatedAt(v time.Time) *ProjectIssueUpdateOne {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetUser sets the "user" edge to the User entity.
|
|
func (_u *ProjectIssueUpdateOne) SetUser(v *User) *ProjectIssueUpdateOne {
|
|
return _u.SetUserID(v.ID)
|
|
}
|
|
|
|
// SetAssignee sets the "assignee" edge to the User entity.
|
|
func (_u *ProjectIssueUpdateOne) SetAssignee(v *User) *ProjectIssueUpdateOne {
|
|
return _u.SetAssigneeID(v.ID)
|
|
}
|
|
|
|
// SetProject sets the "project" edge to the Project entity.
|
|
func (_u *ProjectIssueUpdateOne) SetProject(v *Project) *ProjectIssueUpdateOne {
|
|
return _u.SetProjectID(v.ID)
|
|
}
|
|
|
|
// AddCommentIDs adds the "comments" edge to the ProjectIssueComment entity by IDs.
|
|
func (_u *ProjectIssueUpdateOne) AddCommentIDs(ids ...uuid.UUID) *ProjectIssueUpdateOne {
|
|
_u.mutation.AddCommentIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddComments adds the "comments" edges to the ProjectIssueComment entity.
|
|
func (_u *ProjectIssueUpdateOne) AddComments(v ...*ProjectIssueComment) *ProjectIssueUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddCommentIDs(ids...)
|
|
}
|
|
|
|
// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by IDs.
|
|
func (_u *ProjectIssueUpdateOne) AddProjectTaskIDs(ids ...uuid.UUID) *ProjectIssueUpdateOne {
|
|
_u.mutation.AddProjectTaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddProjectTasks adds the "project_tasks" edges to the ProjectTask entity.
|
|
func (_u *ProjectIssueUpdateOne) AddProjectTasks(v ...*ProjectTask) *ProjectIssueUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddProjectTaskIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the ProjectIssueMutation object of the builder.
|
|
func (_u *ProjectIssueUpdateOne) Mutation() *ProjectIssueMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearUser clears the "user" edge to the User entity.
|
|
func (_u *ProjectIssueUpdateOne) ClearUser() *ProjectIssueUpdateOne {
|
|
_u.mutation.ClearUser()
|
|
return _u
|
|
}
|
|
|
|
// ClearAssignee clears the "assignee" edge to the User entity.
|
|
func (_u *ProjectIssueUpdateOne) ClearAssignee() *ProjectIssueUpdateOne {
|
|
_u.mutation.ClearAssignee()
|
|
return _u
|
|
}
|
|
|
|
// ClearProject clears the "project" edge to the Project entity.
|
|
func (_u *ProjectIssueUpdateOne) ClearProject() *ProjectIssueUpdateOne {
|
|
_u.mutation.ClearProject()
|
|
return _u
|
|
}
|
|
|
|
// ClearComments clears all "comments" edges to the ProjectIssueComment entity.
|
|
func (_u *ProjectIssueUpdateOne) ClearComments() *ProjectIssueUpdateOne {
|
|
_u.mutation.ClearComments()
|
|
return _u
|
|
}
|
|
|
|
// RemoveCommentIDs removes the "comments" edge to ProjectIssueComment entities by IDs.
|
|
func (_u *ProjectIssueUpdateOne) RemoveCommentIDs(ids ...uuid.UUID) *ProjectIssueUpdateOne {
|
|
_u.mutation.RemoveCommentIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveComments removes "comments" edges to ProjectIssueComment entities.
|
|
func (_u *ProjectIssueUpdateOne) RemoveComments(v ...*ProjectIssueComment) *ProjectIssueUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveCommentIDs(ids...)
|
|
}
|
|
|
|
// ClearProjectTasks clears all "project_tasks" edges to the ProjectTask entity.
|
|
func (_u *ProjectIssueUpdateOne) ClearProjectTasks() *ProjectIssueUpdateOne {
|
|
_u.mutation.ClearProjectTasks()
|
|
return _u
|
|
}
|
|
|
|
// RemoveProjectTaskIDs removes the "project_tasks" edge to ProjectTask entities by IDs.
|
|
func (_u *ProjectIssueUpdateOne) RemoveProjectTaskIDs(ids ...uuid.UUID) *ProjectIssueUpdateOne {
|
|
_u.mutation.RemoveProjectTaskIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveProjectTasks removes "project_tasks" edges to ProjectTask entities.
|
|
func (_u *ProjectIssueUpdateOne) RemoveProjectTasks(v ...*ProjectTask) *ProjectIssueUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveProjectTaskIDs(ids...)
|
|
}
|
|
|
|
// Where appends a list predicates to the ProjectIssueUpdate builder.
|
|
func (_u *ProjectIssueUpdateOne) Where(ps ...predicate.ProjectIssue) *ProjectIssueUpdateOne {
|
|
_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 *ProjectIssueUpdateOne) Select(field string, fields ...string) *ProjectIssueUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated ProjectIssue entity.
|
|
func (_u *ProjectIssueUpdateOne) Save(ctx context.Context) (*ProjectIssue, 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 *ProjectIssueUpdateOne) SaveX(ctx context.Context) *ProjectIssue {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *ProjectIssueUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *ProjectIssueUpdateOne) 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 *ProjectIssueUpdateOne) defaults() error {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
if projectissue.UpdateDefaultUpdatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized projectissue.UpdateDefaultUpdatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := projectissue.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *ProjectIssueUpdateOne) check() error {
|
|
if v, ok := _u.mutation.Title(); ok {
|
|
if err := projectissue.TitleValidator(v); err != nil {
|
|
return &ValidationError{Name: "title", err: fmt.Errorf(`db: validator failed for field "ProjectIssue.title": %w`, err)}
|
|
}
|
|
}
|
|
if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "ProjectIssue.user"`)
|
|
}
|
|
if _u.mutation.ProjectCleared() && len(_u.mutation.ProjectIDs()) > 0 {
|
|
return errors.New(`db: clearing a required unique edge "ProjectIssue.project"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *ProjectIssueUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ProjectIssueUpdateOne {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *ProjectIssueUpdateOne) sqlSave(ctx context.Context) (_node *ProjectIssue, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(projectissue.Table, projectissue.Columns, sqlgraph.NewFieldSpec(projectissue.FieldID, field.TypeUUID))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "ProjectIssue.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, projectissue.FieldID)
|
|
for _, f := range fields {
|
|
if !projectissue.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)}
|
|
}
|
|
if f != projectissue.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(projectissue.FieldDeletedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.DeletedAtCleared() {
|
|
_spec.ClearField(projectissue.FieldDeletedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(projectissue.FieldStatus, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Title(); ok {
|
|
_spec.SetField(projectissue.FieldTitle, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.RequirementDocument(); ok {
|
|
_spec.SetField(projectissue.FieldRequirementDocument, field.TypeString, value)
|
|
}
|
|
if _u.mutation.RequirementDocumentCleared() {
|
|
_spec.ClearField(projectissue.FieldRequirementDocument, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.DesignDocument(); ok {
|
|
_spec.SetField(projectissue.FieldDesignDocument, field.TypeString, value)
|
|
}
|
|
if _u.mutation.DesignDocumentCleared() {
|
|
_spec.ClearField(projectissue.FieldDesignDocument, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Summary(); ok {
|
|
_spec.SetField(projectissue.FieldSummary, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SummaryCleared() {
|
|
_spec.ClearField(projectissue.FieldSummary, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Priority(); ok {
|
|
_spec.SetField(projectissue.FieldPriority, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedPriority(); ok {
|
|
_spec.AddField(projectissue.FieldPriority, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(projectissue.FieldCreatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(projectissue.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.UserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectissue.UserTable,
|
|
Columns: []string{projectissue.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: projectissue.UserTable,
|
|
Columns: []string{projectissue.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.AssigneeCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectissue.AssigneeTable,
|
|
Columns: []string{projectissue.AssigneeColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.AssigneeIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectissue.AssigneeTable,
|
|
Columns: []string{projectissue.AssigneeColumn},
|
|
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.ProjectCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectissue.ProjectTable,
|
|
Columns: []string{projectissue.ProjectColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(project.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.ProjectIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectissue.ProjectTable,
|
|
Columns: []string{projectissue.ProjectColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(project.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.CommentsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: projectissue.CommentsTable,
|
|
Columns: []string{projectissue.CommentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projectissuecomment.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedCommentsIDs(); len(nodes) > 0 && !_u.mutation.CommentsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: projectissue.CommentsTable,
|
|
Columns: []string{projectissue.CommentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projectissuecomment.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.CommentsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: projectissue.CommentsTable,
|
|
Columns: []string{projectissue.CommentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projectissuecomment.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.ProjectTasksCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: projectissue.ProjectTasksTable,
|
|
Columns: []string{projectissue.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: projectissue.ProjectTasksTable,
|
|
Columns: []string{projectissue.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: projectissue.ProjectTasksTable,
|
|
Columns: []string{projectissue.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)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
_node = &ProjectIssue{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{projectissue.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|