mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-22 19:39:31 +08:00
1415 lines
43 KiB
Go
1415 lines
43 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect"
|
|
"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/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"
|
|
)
|
|
|
|
// ProjectIssueCreate is the builder for creating a ProjectIssue entity.
|
|
type ProjectIssueCreate struct {
|
|
config
|
|
mutation *ProjectIssueMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (_c *ProjectIssueCreate) SetDeletedAt(v time.Time) *ProjectIssueCreate {
|
|
_c.mutation.SetDeletedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (_c *ProjectIssueCreate) SetNillableDeletedAt(v *time.Time) *ProjectIssueCreate {
|
|
if v != nil {
|
|
_c.SetDeletedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_c *ProjectIssueCreate) SetUserID(v uuid.UUID) *ProjectIssueCreate {
|
|
_c.mutation.SetUserID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetProjectID sets the "project_id" field.
|
|
func (_c *ProjectIssueCreate) SetProjectID(v uuid.UUID) *ProjectIssueCreate {
|
|
_c.mutation.SetProjectID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_c *ProjectIssueCreate) SetStatus(v consts.ProjectIssueStatus) *ProjectIssueCreate {
|
|
_c.mutation.SetStatus(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_c *ProjectIssueCreate) SetNillableStatus(v *consts.ProjectIssueStatus) *ProjectIssueCreate {
|
|
if v != nil {
|
|
_c.SetStatus(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetTitle sets the "title" field.
|
|
func (_c *ProjectIssueCreate) SetTitle(v string) *ProjectIssueCreate {
|
|
_c.mutation.SetTitle(v)
|
|
return _c
|
|
}
|
|
|
|
// SetRequirementDocument sets the "requirement_document" field.
|
|
func (_c *ProjectIssueCreate) SetRequirementDocument(v string) *ProjectIssueCreate {
|
|
_c.mutation.SetRequirementDocument(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableRequirementDocument sets the "requirement_document" field if the given value is not nil.
|
|
func (_c *ProjectIssueCreate) SetNillableRequirementDocument(v *string) *ProjectIssueCreate {
|
|
if v != nil {
|
|
_c.SetRequirementDocument(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetDesignDocument sets the "design_document" field.
|
|
func (_c *ProjectIssueCreate) SetDesignDocument(v string) *ProjectIssueCreate {
|
|
_c.mutation.SetDesignDocument(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableDesignDocument sets the "design_document" field if the given value is not nil.
|
|
func (_c *ProjectIssueCreate) SetNillableDesignDocument(v *string) *ProjectIssueCreate {
|
|
if v != nil {
|
|
_c.SetDesignDocument(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetSummary sets the "summary" field.
|
|
func (_c *ProjectIssueCreate) SetSummary(v string) *ProjectIssueCreate {
|
|
_c.mutation.SetSummary(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableSummary sets the "summary" field if the given value is not nil.
|
|
func (_c *ProjectIssueCreate) SetNillableSummary(v *string) *ProjectIssueCreate {
|
|
if v != nil {
|
|
_c.SetSummary(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetAssigneeID sets the "assignee_id" field.
|
|
func (_c *ProjectIssueCreate) SetAssigneeID(v uuid.UUID) *ProjectIssueCreate {
|
|
_c.mutation.SetAssigneeID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableAssigneeID sets the "assignee_id" field if the given value is not nil.
|
|
func (_c *ProjectIssueCreate) SetNillableAssigneeID(v *uuid.UUID) *ProjectIssueCreate {
|
|
if v != nil {
|
|
_c.SetAssigneeID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetPriority sets the "priority" field.
|
|
func (_c *ProjectIssueCreate) SetPriority(v consts.ProjectIssuePriority) *ProjectIssueCreate {
|
|
_c.mutation.SetPriority(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillablePriority sets the "priority" field if the given value is not nil.
|
|
func (_c *ProjectIssueCreate) SetNillablePriority(v *consts.ProjectIssuePriority) *ProjectIssueCreate {
|
|
if v != nil {
|
|
_c.SetPriority(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_c *ProjectIssueCreate) SetCreatedAt(v time.Time) *ProjectIssueCreate {
|
|
_c.mutation.SetCreatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_c *ProjectIssueCreate) SetNillableCreatedAt(v *time.Time) *ProjectIssueCreate {
|
|
if v != nil {
|
|
_c.SetCreatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_c *ProjectIssueCreate) SetUpdatedAt(v time.Time) *ProjectIssueCreate {
|
|
_c.mutation.SetUpdatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_c *ProjectIssueCreate) SetNillableUpdatedAt(v *time.Time) *ProjectIssueCreate {
|
|
if v != nil {
|
|
_c.SetUpdatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetID sets the "id" field.
|
|
func (_c *ProjectIssueCreate) SetID(v uuid.UUID) *ProjectIssueCreate {
|
|
_c.mutation.SetID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetUser sets the "user" edge to the User entity.
|
|
func (_c *ProjectIssueCreate) SetUser(v *User) *ProjectIssueCreate {
|
|
return _c.SetUserID(v.ID)
|
|
}
|
|
|
|
// SetAssignee sets the "assignee" edge to the User entity.
|
|
func (_c *ProjectIssueCreate) SetAssignee(v *User) *ProjectIssueCreate {
|
|
return _c.SetAssigneeID(v.ID)
|
|
}
|
|
|
|
// SetProject sets the "project" edge to the Project entity.
|
|
func (_c *ProjectIssueCreate) SetProject(v *Project) *ProjectIssueCreate {
|
|
return _c.SetProjectID(v.ID)
|
|
}
|
|
|
|
// AddCommentIDs adds the "comments" edge to the ProjectIssueComment entity by IDs.
|
|
func (_c *ProjectIssueCreate) AddCommentIDs(ids ...uuid.UUID) *ProjectIssueCreate {
|
|
_c.mutation.AddCommentIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddComments adds the "comments" edges to the ProjectIssueComment entity.
|
|
func (_c *ProjectIssueCreate) AddComments(v ...*ProjectIssueComment) *ProjectIssueCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddCommentIDs(ids...)
|
|
}
|
|
|
|
// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by IDs.
|
|
func (_c *ProjectIssueCreate) AddProjectTaskIDs(ids ...uuid.UUID) *ProjectIssueCreate {
|
|
_c.mutation.AddProjectTaskIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddProjectTasks adds the "project_tasks" edges to the ProjectTask entity.
|
|
func (_c *ProjectIssueCreate) AddProjectTasks(v ...*ProjectTask) *ProjectIssueCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddProjectTaskIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the ProjectIssueMutation object of the builder.
|
|
func (_c *ProjectIssueCreate) Mutation() *ProjectIssueMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the ProjectIssue in the database.
|
|
func (_c *ProjectIssueCreate) Save(ctx context.Context) (*ProjectIssue, error) {
|
|
if err := _c.defaults(); err != nil {
|
|
return nil, err
|
|
}
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *ProjectIssueCreate) SaveX(ctx context.Context) *ProjectIssue {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *ProjectIssueCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *ProjectIssueCreate) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_c *ProjectIssueCreate) defaults() error {
|
|
if _, ok := _c.mutation.Status(); !ok {
|
|
v := projectissue.DefaultStatus
|
|
_c.mutation.SetStatus(v)
|
|
}
|
|
if _, ok := _c.mutation.Priority(); !ok {
|
|
v := projectissue.DefaultPriority
|
|
_c.mutation.SetPriority(v)
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
if projectissue.DefaultCreatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized projectissue.DefaultCreatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := projectissue.DefaultCreatedAt()
|
|
_c.mutation.SetCreatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
if projectissue.DefaultUpdatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized projectissue.DefaultUpdatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := projectissue.DefaultUpdatedAt()
|
|
_c.mutation.SetUpdatedAt(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *ProjectIssueCreate) check() error {
|
|
if _, ok := _c.mutation.UserID(); !ok {
|
|
return &ValidationError{Name: "user_id", err: errors.New(`db: missing required field "ProjectIssue.user_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.ProjectID(); !ok {
|
|
return &ValidationError{Name: "project_id", err: errors.New(`db: missing required field "ProjectIssue.project_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.Status(); !ok {
|
|
return &ValidationError{Name: "status", err: errors.New(`db: missing required field "ProjectIssue.status"`)}
|
|
}
|
|
if _, ok := _c.mutation.Title(); !ok {
|
|
return &ValidationError{Name: "title", err: errors.New(`db: missing required field "ProjectIssue.title"`)}
|
|
}
|
|
if v, ok := _c.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 _, ok := _c.mutation.Priority(); !ok {
|
|
return &ValidationError{Name: "priority", err: errors.New(`db: missing required field "ProjectIssue.priority"`)}
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "ProjectIssue.created_at"`)}
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "ProjectIssue.updated_at"`)}
|
|
}
|
|
if len(_c.mutation.UserIDs()) == 0 {
|
|
return &ValidationError{Name: "user", err: errors.New(`db: missing required edge "ProjectIssue.user"`)}
|
|
}
|
|
if len(_c.mutation.ProjectIDs()) == 0 {
|
|
return &ValidationError{Name: "project", err: errors.New(`db: missing required edge "ProjectIssue.project"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *ProjectIssueCreate) sqlSave(ctx context.Context) (*ProjectIssue, error) {
|
|
if err := _c.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
_node, _spec := _c.createSpec()
|
|
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
if _spec.ID.Value != nil {
|
|
if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
|
|
_node.ID = *id
|
|
} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
_c.mutation.id = &_node.ID
|
|
_c.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
func (_c *ProjectIssueCreate) createSpec() (*ProjectIssue, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &ProjectIssue{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(projectissue.Table, sqlgraph.NewFieldSpec(projectissue.FieldID, field.TypeUUID))
|
|
)
|
|
_spec.OnConflict = _c.conflict
|
|
if id, ok := _c.mutation.ID(); ok {
|
|
_node.ID = id
|
|
_spec.ID.Value = &id
|
|
}
|
|
if value, ok := _c.mutation.DeletedAt(); ok {
|
|
_spec.SetField(projectissue.FieldDeletedAt, field.TypeTime, value)
|
|
_node.DeletedAt = value
|
|
}
|
|
if value, ok := _c.mutation.Status(); ok {
|
|
_spec.SetField(projectissue.FieldStatus, field.TypeString, value)
|
|
_node.Status = value
|
|
}
|
|
if value, ok := _c.mutation.Title(); ok {
|
|
_spec.SetField(projectissue.FieldTitle, field.TypeString, value)
|
|
_node.Title = value
|
|
}
|
|
if value, ok := _c.mutation.RequirementDocument(); ok {
|
|
_spec.SetField(projectissue.FieldRequirementDocument, field.TypeString, value)
|
|
_node.RequirementDocument = value
|
|
}
|
|
if value, ok := _c.mutation.DesignDocument(); ok {
|
|
_spec.SetField(projectissue.FieldDesignDocument, field.TypeString, value)
|
|
_node.DesignDocument = value
|
|
}
|
|
if value, ok := _c.mutation.Summary(); ok {
|
|
_spec.SetField(projectissue.FieldSummary, field.TypeString, value)
|
|
_node.Summary = value
|
|
}
|
|
if value, ok := _c.mutation.Priority(); ok {
|
|
_spec.SetField(projectissue.FieldPriority, field.TypeInt, value)
|
|
_node.Priority = value
|
|
}
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
|
_spec.SetField(projectissue.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if value, ok := _c.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(projectissue.FieldUpdatedAt, field.TypeTime, value)
|
|
_node.UpdatedAt = value
|
|
}
|
|
if nodes := _c.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)
|
|
}
|
|
_node.UserID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.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)
|
|
}
|
|
_node.AssigneeID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.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)
|
|
}
|
|
_node.ProjectID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.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 = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.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 = append(_spec.Edges, edge)
|
|
}
|
|
return _node, _spec
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.ProjectIssue.Create().
|
|
// SetDeletedAt(v).
|
|
// OnConflict(
|
|
// // Update the row with the new values
|
|
// // the was proposed for insertion.
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// // Override some of the fields with custom
|
|
// // update values.
|
|
// Update(func(u *ent.ProjectIssueUpsert) {
|
|
// SetDeletedAt(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *ProjectIssueCreate) OnConflict(opts ...sql.ConflictOption) *ProjectIssueUpsertOne {
|
|
_c.conflict = opts
|
|
return &ProjectIssueUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.ProjectIssue.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *ProjectIssueCreate) OnConflictColumns(columns ...string) *ProjectIssueUpsertOne {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &ProjectIssueUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// ProjectIssueUpsertOne is the builder for "upsert"-ing
|
|
// one ProjectIssue node.
|
|
ProjectIssueUpsertOne struct {
|
|
create *ProjectIssueCreate
|
|
}
|
|
|
|
// ProjectIssueUpsert is the "OnConflict" setter.
|
|
ProjectIssueUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *ProjectIssueUpsert) SetDeletedAt(v time.Time) *ProjectIssueUpsert {
|
|
u.Set(projectissue.FieldDeletedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsert) UpdateDeletedAt() *ProjectIssueUpsert {
|
|
u.SetExcluded(projectissue.FieldDeletedAt)
|
|
return u
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *ProjectIssueUpsert) ClearDeletedAt() *ProjectIssueUpsert {
|
|
u.SetNull(projectissue.FieldDeletedAt)
|
|
return u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *ProjectIssueUpsert) SetUserID(v uuid.UUID) *ProjectIssueUpsert {
|
|
u.Set(projectissue.FieldUserID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsert) UpdateUserID() *ProjectIssueUpsert {
|
|
u.SetExcluded(projectissue.FieldUserID)
|
|
return u
|
|
}
|
|
|
|
// SetProjectID sets the "project_id" field.
|
|
func (u *ProjectIssueUpsert) SetProjectID(v uuid.UUID) *ProjectIssueUpsert {
|
|
u.Set(projectissue.FieldProjectID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateProjectID sets the "project_id" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsert) UpdateProjectID() *ProjectIssueUpsert {
|
|
u.SetExcluded(projectissue.FieldProjectID)
|
|
return u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (u *ProjectIssueUpsert) SetStatus(v consts.ProjectIssueStatus) *ProjectIssueUpsert {
|
|
u.Set(projectissue.FieldStatus, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsert) UpdateStatus() *ProjectIssueUpsert {
|
|
u.SetExcluded(projectissue.FieldStatus)
|
|
return u
|
|
}
|
|
|
|
// SetTitle sets the "title" field.
|
|
func (u *ProjectIssueUpsert) SetTitle(v string) *ProjectIssueUpsert {
|
|
u.Set(projectissue.FieldTitle, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateTitle sets the "title" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsert) UpdateTitle() *ProjectIssueUpsert {
|
|
u.SetExcluded(projectissue.FieldTitle)
|
|
return u
|
|
}
|
|
|
|
// SetRequirementDocument sets the "requirement_document" field.
|
|
func (u *ProjectIssueUpsert) SetRequirementDocument(v string) *ProjectIssueUpsert {
|
|
u.Set(projectissue.FieldRequirementDocument, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateRequirementDocument sets the "requirement_document" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsert) UpdateRequirementDocument() *ProjectIssueUpsert {
|
|
u.SetExcluded(projectissue.FieldRequirementDocument)
|
|
return u
|
|
}
|
|
|
|
// ClearRequirementDocument clears the value of the "requirement_document" field.
|
|
func (u *ProjectIssueUpsert) ClearRequirementDocument() *ProjectIssueUpsert {
|
|
u.SetNull(projectissue.FieldRequirementDocument)
|
|
return u
|
|
}
|
|
|
|
// SetDesignDocument sets the "design_document" field.
|
|
func (u *ProjectIssueUpsert) SetDesignDocument(v string) *ProjectIssueUpsert {
|
|
u.Set(projectissue.FieldDesignDocument, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDesignDocument sets the "design_document" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsert) UpdateDesignDocument() *ProjectIssueUpsert {
|
|
u.SetExcluded(projectissue.FieldDesignDocument)
|
|
return u
|
|
}
|
|
|
|
// ClearDesignDocument clears the value of the "design_document" field.
|
|
func (u *ProjectIssueUpsert) ClearDesignDocument() *ProjectIssueUpsert {
|
|
u.SetNull(projectissue.FieldDesignDocument)
|
|
return u
|
|
}
|
|
|
|
// SetSummary sets the "summary" field.
|
|
func (u *ProjectIssueUpsert) SetSummary(v string) *ProjectIssueUpsert {
|
|
u.Set(projectissue.FieldSummary, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateSummary sets the "summary" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsert) UpdateSummary() *ProjectIssueUpsert {
|
|
u.SetExcluded(projectissue.FieldSummary)
|
|
return u
|
|
}
|
|
|
|
// ClearSummary clears the value of the "summary" field.
|
|
func (u *ProjectIssueUpsert) ClearSummary() *ProjectIssueUpsert {
|
|
u.SetNull(projectissue.FieldSummary)
|
|
return u
|
|
}
|
|
|
|
// SetAssigneeID sets the "assignee_id" field.
|
|
func (u *ProjectIssueUpsert) SetAssigneeID(v uuid.UUID) *ProjectIssueUpsert {
|
|
u.Set(projectissue.FieldAssigneeID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateAssigneeID sets the "assignee_id" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsert) UpdateAssigneeID() *ProjectIssueUpsert {
|
|
u.SetExcluded(projectissue.FieldAssigneeID)
|
|
return u
|
|
}
|
|
|
|
// ClearAssigneeID clears the value of the "assignee_id" field.
|
|
func (u *ProjectIssueUpsert) ClearAssigneeID() *ProjectIssueUpsert {
|
|
u.SetNull(projectissue.FieldAssigneeID)
|
|
return u
|
|
}
|
|
|
|
// SetPriority sets the "priority" field.
|
|
func (u *ProjectIssueUpsert) SetPriority(v consts.ProjectIssuePriority) *ProjectIssueUpsert {
|
|
u.Set(projectissue.FieldPriority, v)
|
|
return u
|
|
}
|
|
|
|
// UpdatePriority sets the "priority" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsert) UpdatePriority() *ProjectIssueUpsert {
|
|
u.SetExcluded(projectissue.FieldPriority)
|
|
return u
|
|
}
|
|
|
|
// AddPriority adds v to the "priority" field.
|
|
func (u *ProjectIssueUpsert) AddPriority(v consts.ProjectIssuePriority) *ProjectIssueUpsert {
|
|
u.Add(projectissue.FieldPriority, v)
|
|
return u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *ProjectIssueUpsert) SetCreatedAt(v time.Time) *ProjectIssueUpsert {
|
|
u.Set(projectissue.FieldCreatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsert) UpdateCreatedAt() *ProjectIssueUpsert {
|
|
u.SetExcluded(projectissue.FieldCreatedAt)
|
|
return u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *ProjectIssueUpsert) SetUpdatedAt(v time.Time) *ProjectIssueUpsert {
|
|
u.Set(projectissue.FieldUpdatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsert) UpdateUpdatedAt() *ProjectIssueUpsert {
|
|
u.SetExcluded(projectissue.FieldUpdatedAt)
|
|
return u
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.ProjectIssue.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(projectissue.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *ProjectIssueUpsertOne) UpdateNewValues() *ProjectIssueUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
|
|
if _, exists := u.create.mutation.ID(); exists {
|
|
s.SetIgnore(projectissue.FieldID)
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.ProjectIssue.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *ProjectIssueUpsertOne) Ignore() *ProjectIssueUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
|
|
return u
|
|
}
|
|
|
|
// DoNothing configures the conflict_action to `DO NOTHING`.
|
|
// Supported only by SQLite and PostgreSQL.
|
|
func (u *ProjectIssueUpsertOne) DoNothing() *ProjectIssueUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the ProjectIssueCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *ProjectIssueUpsertOne) Update(set func(*ProjectIssueUpsert)) *ProjectIssueUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&ProjectIssueUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *ProjectIssueUpsertOne) SetDeletedAt(v time.Time) *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetDeletedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertOne) UpdateDeletedAt() *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateDeletedAt()
|
|
})
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *ProjectIssueUpsertOne) ClearDeletedAt() *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.ClearDeletedAt()
|
|
})
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *ProjectIssueUpsertOne) SetUserID(v uuid.UUID) *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetUserID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertOne) UpdateUserID() *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateUserID()
|
|
})
|
|
}
|
|
|
|
// SetProjectID sets the "project_id" field.
|
|
func (u *ProjectIssueUpsertOne) SetProjectID(v uuid.UUID) *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetProjectID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateProjectID sets the "project_id" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertOne) UpdateProjectID() *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateProjectID()
|
|
})
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (u *ProjectIssueUpsertOne) SetStatus(v consts.ProjectIssueStatus) *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetStatus(v)
|
|
})
|
|
}
|
|
|
|
// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertOne) UpdateStatus() *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateStatus()
|
|
})
|
|
}
|
|
|
|
// SetTitle sets the "title" field.
|
|
func (u *ProjectIssueUpsertOne) SetTitle(v string) *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetTitle(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTitle sets the "title" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertOne) UpdateTitle() *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateTitle()
|
|
})
|
|
}
|
|
|
|
// SetRequirementDocument sets the "requirement_document" field.
|
|
func (u *ProjectIssueUpsertOne) SetRequirementDocument(v string) *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetRequirementDocument(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRequirementDocument sets the "requirement_document" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertOne) UpdateRequirementDocument() *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateRequirementDocument()
|
|
})
|
|
}
|
|
|
|
// ClearRequirementDocument clears the value of the "requirement_document" field.
|
|
func (u *ProjectIssueUpsertOne) ClearRequirementDocument() *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.ClearRequirementDocument()
|
|
})
|
|
}
|
|
|
|
// SetDesignDocument sets the "design_document" field.
|
|
func (u *ProjectIssueUpsertOne) SetDesignDocument(v string) *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetDesignDocument(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDesignDocument sets the "design_document" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertOne) UpdateDesignDocument() *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateDesignDocument()
|
|
})
|
|
}
|
|
|
|
// ClearDesignDocument clears the value of the "design_document" field.
|
|
func (u *ProjectIssueUpsertOne) ClearDesignDocument() *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.ClearDesignDocument()
|
|
})
|
|
}
|
|
|
|
// SetSummary sets the "summary" field.
|
|
func (u *ProjectIssueUpsertOne) SetSummary(v string) *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetSummary(v)
|
|
})
|
|
}
|
|
|
|
// UpdateSummary sets the "summary" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertOne) UpdateSummary() *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateSummary()
|
|
})
|
|
}
|
|
|
|
// ClearSummary clears the value of the "summary" field.
|
|
func (u *ProjectIssueUpsertOne) ClearSummary() *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.ClearSummary()
|
|
})
|
|
}
|
|
|
|
// SetAssigneeID sets the "assignee_id" field.
|
|
func (u *ProjectIssueUpsertOne) SetAssigneeID(v uuid.UUID) *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetAssigneeID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateAssigneeID sets the "assignee_id" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertOne) UpdateAssigneeID() *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateAssigneeID()
|
|
})
|
|
}
|
|
|
|
// ClearAssigneeID clears the value of the "assignee_id" field.
|
|
func (u *ProjectIssueUpsertOne) ClearAssigneeID() *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.ClearAssigneeID()
|
|
})
|
|
}
|
|
|
|
// SetPriority sets the "priority" field.
|
|
func (u *ProjectIssueUpsertOne) SetPriority(v consts.ProjectIssuePriority) *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetPriority(v)
|
|
})
|
|
}
|
|
|
|
// AddPriority adds v to the "priority" field.
|
|
func (u *ProjectIssueUpsertOne) AddPriority(v consts.ProjectIssuePriority) *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.AddPriority(v)
|
|
})
|
|
}
|
|
|
|
// UpdatePriority sets the "priority" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertOne) UpdatePriority() *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdatePriority()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *ProjectIssueUpsertOne) SetCreatedAt(v time.Time) *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertOne) UpdateCreatedAt() *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *ProjectIssueUpsertOne) SetUpdatedAt(v time.Time) *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertOne) UpdateUpdatedAt() *ProjectIssueUpsertOne {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *ProjectIssueUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for ProjectIssueCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *ProjectIssueUpsertOne) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// Exec executes the UPSERT query and returns the inserted/updated ID.
|
|
func (u *ProjectIssueUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) {
|
|
if u.create.driver.Dialect() == dialect.MySQL {
|
|
// In case of "ON CONFLICT", there is no way to get back non-numeric ID
|
|
// fields from the database since MySQL does not support the RETURNING clause.
|
|
return id, errors.New("db: ProjectIssueUpsertOne.ID is not supported by MySQL driver. Use ProjectIssueUpsertOne.Exec instead")
|
|
}
|
|
node, err := u.create.Save(ctx)
|
|
if err != nil {
|
|
return id, err
|
|
}
|
|
return node.ID, nil
|
|
}
|
|
|
|
// IDX is like ID, but panics if an error occurs.
|
|
func (u *ProjectIssueUpsertOne) IDX(ctx context.Context) uuid.UUID {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// ProjectIssueCreateBulk is the builder for creating many ProjectIssue entities in bulk.
|
|
type ProjectIssueCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*ProjectIssueCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the ProjectIssue entities in the database.
|
|
func (_c *ProjectIssueCreateBulk) Save(ctx context.Context) ([]*ProjectIssue, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*ProjectIssue, len(_c.builders))
|
|
mutators := make([]Mutator, len(_c.builders))
|
|
for i := range _c.builders {
|
|
func(i int, root context.Context) {
|
|
builder := _c.builders[i]
|
|
builder.defaults()
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*ProjectIssueMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
if err := builder.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
builder.mutation = mutation
|
|
var err error
|
|
nodes[i], specs[i] = builder.createSpec()
|
|
if i < len(mutators)-1 {
|
|
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
|
} else {
|
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
|
spec.OnConflict = _c.conflict
|
|
// Invoke the actual operation on the latest mutation in the chain.
|
|
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
}
|
|
}
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
mutation.id = &nodes[i].ID
|
|
mutation.done = true
|
|
return nodes[i], nil
|
|
})
|
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
|
mut = builder.hooks[i](mut)
|
|
}
|
|
mutators[i] = mut
|
|
}(i, ctx)
|
|
}
|
|
if len(mutators) > 0 {
|
|
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return nodes, nil
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_c *ProjectIssueCreateBulk) SaveX(ctx context.Context) []*ProjectIssue {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *ProjectIssueCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *ProjectIssueCreateBulk) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.ProjectIssue.CreateBulk(builders...).
|
|
// OnConflict(
|
|
// // Update the row with the new values
|
|
// // the was proposed for insertion.
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// // Override some of the fields with custom
|
|
// // update values.
|
|
// Update(func(u *ent.ProjectIssueUpsert) {
|
|
// SetDeletedAt(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *ProjectIssueCreateBulk) OnConflict(opts ...sql.ConflictOption) *ProjectIssueUpsertBulk {
|
|
_c.conflict = opts
|
|
return &ProjectIssueUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.ProjectIssue.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *ProjectIssueCreateBulk) OnConflictColumns(columns ...string) *ProjectIssueUpsertBulk {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &ProjectIssueUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// ProjectIssueUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of ProjectIssue nodes.
|
|
type ProjectIssueUpsertBulk struct {
|
|
create *ProjectIssueCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.ProjectIssue.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(projectissue.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *ProjectIssueUpsertBulk) UpdateNewValues() *ProjectIssueUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
|
|
for _, b := range u.create.builders {
|
|
if _, exists := b.mutation.ID(); exists {
|
|
s.SetIgnore(projectissue.FieldID)
|
|
}
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.ProjectIssue.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *ProjectIssueUpsertBulk) Ignore() *ProjectIssueUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
|
|
return u
|
|
}
|
|
|
|
// DoNothing configures the conflict_action to `DO NOTHING`.
|
|
// Supported only by SQLite and PostgreSQL.
|
|
func (u *ProjectIssueUpsertBulk) DoNothing() *ProjectIssueUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the ProjectIssueCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *ProjectIssueUpsertBulk) Update(set func(*ProjectIssueUpsert)) *ProjectIssueUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&ProjectIssueUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *ProjectIssueUpsertBulk) SetDeletedAt(v time.Time) *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetDeletedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertBulk) UpdateDeletedAt() *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateDeletedAt()
|
|
})
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *ProjectIssueUpsertBulk) ClearDeletedAt() *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.ClearDeletedAt()
|
|
})
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *ProjectIssueUpsertBulk) SetUserID(v uuid.UUID) *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetUserID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertBulk) UpdateUserID() *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateUserID()
|
|
})
|
|
}
|
|
|
|
// SetProjectID sets the "project_id" field.
|
|
func (u *ProjectIssueUpsertBulk) SetProjectID(v uuid.UUID) *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetProjectID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateProjectID sets the "project_id" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertBulk) UpdateProjectID() *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateProjectID()
|
|
})
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (u *ProjectIssueUpsertBulk) SetStatus(v consts.ProjectIssueStatus) *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetStatus(v)
|
|
})
|
|
}
|
|
|
|
// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertBulk) UpdateStatus() *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateStatus()
|
|
})
|
|
}
|
|
|
|
// SetTitle sets the "title" field.
|
|
func (u *ProjectIssueUpsertBulk) SetTitle(v string) *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetTitle(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTitle sets the "title" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertBulk) UpdateTitle() *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateTitle()
|
|
})
|
|
}
|
|
|
|
// SetRequirementDocument sets the "requirement_document" field.
|
|
func (u *ProjectIssueUpsertBulk) SetRequirementDocument(v string) *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetRequirementDocument(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRequirementDocument sets the "requirement_document" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertBulk) UpdateRequirementDocument() *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateRequirementDocument()
|
|
})
|
|
}
|
|
|
|
// ClearRequirementDocument clears the value of the "requirement_document" field.
|
|
func (u *ProjectIssueUpsertBulk) ClearRequirementDocument() *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.ClearRequirementDocument()
|
|
})
|
|
}
|
|
|
|
// SetDesignDocument sets the "design_document" field.
|
|
func (u *ProjectIssueUpsertBulk) SetDesignDocument(v string) *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetDesignDocument(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDesignDocument sets the "design_document" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertBulk) UpdateDesignDocument() *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateDesignDocument()
|
|
})
|
|
}
|
|
|
|
// ClearDesignDocument clears the value of the "design_document" field.
|
|
func (u *ProjectIssueUpsertBulk) ClearDesignDocument() *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.ClearDesignDocument()
|
|
})
|
|
}
|
|
|
|
// SetSummary sets the "summary" field.
|
|
func (u *ProjectIssueUpsertBulk) SetSummary(v string) *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetSummary(v)
|
|
})
|
|
}
|
|
|
|
// UpdateSummary sets the "summary" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertBulk) UpdateSummary() *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateSummary()
|
|
})
|
|
}
|
|
|
|
// ClearSummary clears the value of the "summary" field.
|
|
func (u *ProjectIssueUpsertBulk) ClearSummary() *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.ClearSummary()
|
|
})
|
|
}
|
|
|
|
// SetAssigneeID sets the "assignee_id" field.
|
|
func (u *ProjectIssueUpsertBulk) SetAssigneeID(v uuid.UUID) *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetAssigneeID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateAssigneeID sets the "assignee_id" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertBulk) UpdateAssigneeID() *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateAssigneeID()
|
|
})
|
|
}
|
|
|
|
// ClearAssigneeID clears the value of the "assignee_id" field.
|
|
func (u *ProjectIssueUpsertBulk) ClearAssigneeID() *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.ClearAssigneeID()
|
|
})
|
|
}
|
|
|
|
// SetPriority sets the "priority" field.
|
|
func (u *ProjectIssueUpsertBulk) SetPriority(v consts.ProjectIssuePriority) *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetPriority(v)
|
|
})
|
|
}
|
|
|
|
// AddPriority adds v to the "priority" field.
|
|
func (u *ProjectIssueUpsertBulk) AddPriority(v consts.ProjectIssuePriority) *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.AddPriority(v)
|
|
})
|
|
}
|
|
|
|
// UpdatePriority sets the "priority" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertBulk) UpdatePriority() *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdatePriority()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *ProjectIssueUpsertBulk) SetCreatedAt(v time.Time) *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertBulk) UpdateCreatedAt() *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *ProjectIssueUpsertBulk) SetUpdatedAt(v time.Time) *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *ProjectIssueUpsertBulk) UpdateUpdatedAt() *ProjectIssueUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *ProjectIssueUpsertBulk) Exec(ctx context.Context) error {
|
|
if u.create.err != nil {
|
|
return u.create.err
|
|
}
|
|
for i, b := range u.create.builders {
|
|
if len(b.conflict) != 0 {
|
|
return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the ProjectIssueCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for ProjectIssueCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *ProjectIssueUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|