mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-22 03:18:50 +08:00
1314 lines
39 KiB
Go
1314 lines
39 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/gitidentity"
|
|
"github.com/chaitin/MonkeyCode/backend/db/image"
|
|
"github.com/chaitin/MonkeyCode/backend/db/model"
|
|
"github.com/chaitin/MonkeyCode/backend/db/project"
|
|
"github.com/chaitin/MonkeyCode/backend/db/projectissue"
|
|
"github.com/chaitin/MonkeyCode/backend/db/projecttask"
|
|
"github.com/chaitin/MonkeyCode/backend/db/task"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// ProjectTaskCreate is the builder for creating a ProjectTask entity.
|
|
type ProjectTaskCreate struct {
|
|
config
|
|
mutation *ProjectTaskMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetTaskID sets the "task_id" field.
|
|
func (_c *ProjectTaskCreate) SetTaskID(v uuid.UUID) *ProjectTaskCreate {
|
|
_c.mutation.SetTaskID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetModelID sets the "model_id" field.
|
|
func (_c *ProjectTaskCreate) SetModelID(v uuid.UUID) *ProjectTaskCreate {
|
|
_c.mutation.SetModelID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetImageID sets the "image_id" field.
|
|
func (_c *ProjectTaskCreate) SetImageID(v uuid.UUID) *ProjectTaskCreate {
|
|
_c.mutation.SetImageID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetGitIdentityID sets the "git_identity_id" field.
|
|
func (_c *ProjectTaskCreate) SetGitIdentityID(v uuid.UUID) *ProjectTaskCreate {
|
|
_c.mutation.SetGitIdentityID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableGitIdentityID sets the "git_identity_id" field if the given value is not nil.
|
|
func (_c *ProjectTaskCreate) SetNillableGitIdentityID(v *uuid.UUID) *ProjectTaskCreate {
|
|
if v != nil {
|
|
_c.SetGitIdentityID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetProjectID sets the "project_id" field.
|
|
func (_c *ProjectTaskCreate) SetProjectID(v uuid.UUID) *ProjectTaskCreate {
|
|
_c.mutation.SetProjectID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableProjectID sets the "project_id" field if the given value is not nil.
|
|
func (_c *ProjectTaskCreate) SetNillableProjectID(v *uuid.UUID) *ProjectTaskCreate {
|
|
if v != nil {
|
|
_c.SetProjectID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetIssueID sets the "issue_id" field.
|
|
func (_c *ProjectTaskCreate) SetIssueID(v uuid.UUID) *ProjectTaskCreate {
|
|
_c.mutation.SetIssueID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableIssueID sets the "issue_id" field if the given value is not nil.
|
|
func (_c *ProjectTaskCreate) SetNillableIssueID(v *uuid.UUID) *ProjectTaskCreate {
|
|
if v != nil {
|
|
_c.SetIssueID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetRepoURL sets the "repo_url" field.
|
|
func (_c *ProjectTaskCreate) SetRepoURL(v string) *ProjectTaskCreate {
|
|
_c.mutation.SetRepoURL(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableRepoURL sets the "repo_url" field if the given value is not nil.
|
|
func (_c *ProjectTaskCreate) SetNillableRepoURL(v *string) *ProjectTaskCreate {
|
|
if v != nil {
|
|
_c.SetRepoURL(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetRepoFilename sets the "repo_filename" field.
|
|
func (_c *ProjectTaskCreate) SetRepoFilename(v string) *ProjectTaskCreate {
|
|
_c.mutation.SetRepoFilename(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableRepoFilename sets the "repo_filename" field if the given value is not nil.
|
|
func (_c *ProjectTaskCreate) SetNillableRepoFilename(v *string) *ProjectTaskCreate {
|
|
if v != nil {
|
|
_c.SetRepoFilename(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetBranch sets the "branch" field.
|
|
func (_c *ProjectTaskCreate) SetBranch(v string) *ProjectTaskCreate {
|
|
_c.mutation.SetBranch(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableBranch sets the "branch" field if the given value is not nil.
|
|
func (_c *ProjectTaskCreate) SetNillableBranch(v *string) *ProjectTaskCreate {
|
|
if v != nil {
|
|
_c.SetBranch(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCliName sets the "cli_name" field.
|
|
func (_c *ProjectTaskCreate) SetCliName(v consts.CliName) *ProjectTaskCreate {
|
|
_c.mutation.SetCliName(v)
|
|
return _c
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_c *ProjectTaskCreate) SetCreatedAt(v time.Time) *ProjectTaskCreate {
|
|
_c.mutation.SetCreatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_c *ProjectTaskCreate) SetNillableCreatedAt(v *time.Time) *ProjectTaskCreate {
|
|
if v != nil {
|
|
_c.SetCreatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetID sets the "id" field.
|
|
func (_c *ProjectTaskCreate) SetID(v uuid.UUID) *ProjectTaskCreate {
|
|
_c.mutation.SetID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetTask sets the "task" edge to the Task entity.
|
|
func (_c *ProjectTaskCreate) SetTask(v *Task) *ProjectTaskCreate {
|
|
return _c.SetTaskID(v.ID)
|
|
}
|
|
|
|
// SetModel sets the "model" edge to the Model entity.
|
|
func (_c *ProjectTaskCreate) SetModel(v *Model) *ProjectTaskCreate {
|
|
return _c.SetModelID(v.ID)
|
|
}
|
|
|
|
// SetImage sets the "image" edge to the Image entity.
|
|
func (_c *ProjectTaskCreate) SetImage(v *Image) *ProjectTaskCreate {
|
|
return _c.SetImageID(v.ID)
|
|
}
|
|
|
|
// SetGitIdentity sets the "git_identity" edge to the GitIdentity entity.
|
|
func (_c *ProjectTaskCreate) SetGitIdentity(v *GitIdentity) *ProjectTaskCreate {
|
|
return _c.SetGitIdentityID(v.ID)
|
|
}
|
|
|
|
// SetProject sets the "project" edge to the Project entity.
|
|
func (_c *ProjectTaskCreate) SetProject(v *Project) *ProjectTaskCreate {
|
|
return _c.SetProjectID(v.ID)
|
|
}
|
|
|
|
// SetIssue sets the "issue" edge to the ProjectIssue entity.
|
|
func (_c *ProjectTaskCreate) SetIssue(v *ProjectIssue) *ProjectTaskCreate {
|
|
return _c.SetIssueID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the ProjectTaskMutation object of the builder.
|
|
func (_c *ProjectTaskCreate) Mutation() *ProjectTaskMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the ProjectTask in the database.
|
|
func (_c *ProjectTaskCreate) Save(ctx context.Context) (*ProjectTask, error) {
|
|
_c.defaults()
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *ProjectTaskCreate) SaveX(ctx context.Context) *ProjectTask {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *ProjectTaskCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *ProjectTaskCreate) 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 *ProjectTaskCreate) defaults() {
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
v := projecttask.DefaultCreatedAt()
|
|
_c.mutation.SetCreatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *ProjectTaskCreate) check() error {
|
|
if _, ok := _c.mutation.TaskID(); !ok {
|
|
return &ValidationError{Name: "task_id", err: errors.New(`db: missing required field "ProjectTask.task_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.ModelID(); !ok {
|
|
return &ValidationError{Name: "model_id", err: errors.New(`db: missing required field "ProjectTask.model_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.ImageID(); !ok {
|
|
return &ValidationError{Name: "image_id", err: errors.New(`db: missing required field "ProjectTask.image_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.CliName(); !ok {
|
|
return &ValidationError{Name: "cli_name", err: errors.New(`db: missing required field "ProjectTask.cli_name"`)}
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "ProjectTask.created_at"`)}
|
|
}
|
|
if len(_c.mutation.TaskIDs()) == 0 {
|
|
return &ValidationError{Name: "task", err: errors.New(`db: missing required edge "ProjectTask.task"`)}
|
|
}
|
|
if len(_c.mutation.ModelIDs()) == 0 {
|
|
return &ValidationError{Name: "model", err: errors.New(`db: missing required edge "ProjectTask.model"`)}
|
|
}
|
|
if len(_c.mutation.ImageIDs()) == 0 {
|
|
return &ValidationError{Name: "image", err: errors.New(`db: missing required edge "ProjectTask.image"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *ProjectTaskCreate) sqlSave(ctx context.Context) (*ProjectTask, 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 *ProjectTaskCreate) createSpec() (*ProjectTask, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &ProjectTask{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(projecttask.Table, sqlgraph.NewFieldSpec(projecttask.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.RepoURL(); ok {
|
|
_spec.SetField(projecttask.FieldRepoURL, field.TypeString, value)
|
|
_node.RepoURL = value
|
|
}
|
|
if value, ok := _c.mutation.RepoFilename(); ok {
|
|
_spec.SetField(projecttask.FieldRepoFilename, field.TypeString, value)
|
|
_node.RepoFilename = value
|
|
}
|
|
if value, ok := _c.mutation.Branch(); ok {
|
|
_spec.SetField(projecttask.FieldBranch, field.TypeString, value)
|
|
_node.Branch = value
|
|
}
|
|
if value, ok := _c.mutation.CliName(); ok {
|
|
_spec.SetField(projecttask.FieldCliName, field.TypeString, value)
|
|
_node.CliName = value
|
|
}
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
|
_spec.SetField(projecttask.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if nodes := _c.mutation.TaskIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projecttask.TaskTable,
|
|
Columns: []string{projecttask.TaskColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.TaskID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.ModelIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projecttask.ModelTable,
|
|
Columns: []string{projecttask.ModelColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(model.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.ModelID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.ImageIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projecttask.ImageTable,
|
|
Columns: []string{projecttask.ImageColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(image.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.ImageID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.GitIdentityIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projecttask.GitIdentityTable,
|
|
Columns: []string{projecttask.GitIdentityColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(gitidentity.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.GitIdentityID = 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: projecttask.ProjectTable,
|
|
Columns: []string{projecttask.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.IssueIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projecttask.IssueTable,
|
|
Columns: []string{projecttask.IssueColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projectissue.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.IssueID = nodes[0]
|
|
_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.ProjectTask.Create().
|
|
// SetTaskID(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.ProjectTaskUpsert) {
|
|
// SetTaskID(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *ProjectTaskCreate) OnConflict(opts ...sql.ConflictOption) *ProjectTaskUpsertOne {
|
|
_c.conflict = opts
|
|
return &ProjectTaskUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.ProjectTask.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *ProjectTaskCreate) OnConflictColumns(columns ...string) *ProjectTaskUpsertOne {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &ProjectTaskUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// ProjectTaskUpsertOne is the builder for "upsert"-ing
|
|
// one ProjectTask node.
|
|
ProjectTaskUpsertOne struct {
|
|
create *ProjectTaskCreate
|
|
}
|
|
|
|
// ProjectTaskUpsert is the "OnConflict" setter.
|
|
ProjectTaskUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetTaskID sets the "task_id" field.
|
|
func (u *ProjectTaskUpsert) SetTaskID(v uuid.UUID) *ProjectTaskUpsert {
|
|
u.Set(projecttask.FieldTaskID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateTaskID sets the "task_id" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsert) UpdateTaskID() *ProjectTaskUpsert {
|
|
u.SetExcluded(projecttask.FieldTaskID)
|
|
return u
|
|
}
|
|
|
|
// SetModelID sets the "model_id" field.
|
|
func (u *ProjectTaskUpsert) SetModelID(v uuid.UUID) *ProjectTaskUpsert {
|
|
u.Set(projecttask.FieldModelID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateModelID sets the "model_id" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsert) UpdateModelID() *ProjectTaskUpsert {
|
|
u.SetExcluded(projecttask.FieldModelID)
|
|
return u
|
|
}
|
|
|
|
// SetImageID sets the "image_id" field.
|
|
func (u *ProjectTaskUpsert) SetImageID(v uuid.UUID) *ProjectTaskUpsert {
|
|
u.Set(projecttask.FieldImageID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateImageID sets the "image_id" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsert) UpdateImageID() *ProjectTaskUpsert {
|
|
u.SetExcluded(projecttask.FieldImageID)
|
|
return u
|
|
}
|
|
|
|
// SetGitIdentityID sets the "git_identity_id" field.
|
|
func (u *ProjectTaskUpsert) SetGitIdentityID(v uuid.UUID) *ProjectTaskUpsert {
|
|
u.Set(projecttask.FieldGitIdentityID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateGitIdentityID sets the "git_identity_id" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsert) UpdateGitIdentityID() *ProjectTaskUpsert {
|
|
u.SetExcluded(projecttask.FieldGitIdentityID)
|
|
return u
|
|
}
|
|
|
|
// ClearGitIdentityID clears the value of the "git_identity_id" field.
|
|
func (u *ProjectTaskUpsert) ClearGitIdentityID() *ProjectTaskUpsert {
|
|
u.SetNull(projecttask.FieldGitIdentityID)
|
|
return u
|
|
}
|
|
|
|
// SetProjectID sets the "project_id" field.
|
|
func (u *ProjectTaskUpsert) SetProjectID(v uuid.UUID) *ProjectTaskUpsert {
|
|
u.Set(projecttask.FieldProjectID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateProjectID sets the "project_id" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsert) UpdateProjectID() *ProjectTaskUpsert {
|
|
u.SetExcluded(projecttask.FieldProjectID)
|
|
return u
|
|
}
|
|
|
|
// ClearProjectID clears the value of the "project_id" field.
|
|
func (u *ProjectTaskUpsert) ClearProjectID() *ProjectTaskUpsert {
|
|
u.SetNull(projecttask.FieldProjectID)
|
|
return u
|
|
}
|
|
|
|
// SetIssueID sets the "issue_id" field.
|
|
func (u *ProjectTaskUpsert) SetIssueID(v uuid.UUID) *ProjectTaskUpsert {
|
|
u.Set(projecttask.FieldIssueID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateIssueID sets the "issue_id" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsert) UpdateIssueID() *ProjectTaskUpsert {
|
|
u.SetExcluded(projecttask.FieldIssueID)
|
|
return u
|
|
}
|
|
|
|
// ClearIssueID clears the value of the "issue_id" field.
|
|
func (u *ProjectTaskUpsert) ClearIssueID() *ProjectTaskUpsert {
|
|
u.SetNull(projecttask.FieldIssueID)
|
|
return u
|
|
}
|
|
|
|
// SetRepoURL sets the "repo_url" field.
|
|
func (u *ProjectTaskUpsert) SetRepoURL(v string) *ProjectTaskUpsert {
|
|
u.Set(projecttask.FieldRepoURL, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateRepoURL sets the "repo_url" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsert) UpdateRepoURL() *ProjectTaskUpsert {
|
|
u.SetExcluded(projecttask.FieldRepoURL)
|
|
return u
|
|
}
|
|
|
|
// ClearRepoURL clears the value of the "repo_url" field.
|
|
func (u *ProjectTaskUpsert) ClearRepoURL() *ProjectTaskUpsert {
|
|
u.SetNull(projecttask.FieldRepoURL)
|
|
return u
|
|
}
|
|
|
|
// SetRepoFilename sets the "repo_filename" field.
|
|
func (u *ProjectTaskUpsert) SetRepoFilename(v string) *ProjectTaskUpsert {
|
|
u.Set(projecttask.FieldRepoFilename, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateRepoFilename sets the "repo_filename" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsert) UpdateRepoFilename() *ProjectTaskUpsert {
|
|
u.SetExcluded(projecttask.FieldRepoFilename)
|
|
return u
|
|
}
|
|
|
|
// ClearRepoFilename clears the value of the "repo_filename" field.
|
|
func (u *ProjectTaskUpsert) ClearRepoFilename() *ProjectTaskUpsert {
|
|
u.SetNull(projecttask.FieldRepoFilename)
|
|
return u
|
|
}
|
|
|
|
// SetBranch sets the "branch" field.
|
|
func (u *ProjectTaskUpsert) SetBranch(v string) *ProjectTaskUpsert {
|
|
u.Set(projecttask.FieldBranch, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateBranch sets the "branch" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsert) UpdateBranch() *ProjectTaskUpsert {
|
|
u.SetExcluded(projecttask.FieldBranch)
|
|
return u
|
|
}
|
|
|
|
// ClearBranch clears the value of the "branch" field.
|
|
func (u *ProjectTaskUpsert) ClearBranch() *ProjectTaskUpsert {
|
|
u.SetNull(projecttask.FieldBranch)
|
|
return u
|
|
}
|
|
|
|
// SetCliName sets the "cli_name" field.
|
|
func (u *ProjectTaskUpsert) SetCliName(v consts.CliName) *ProjectTaskUpsert {
|
|
u.Set(projecttask.FieldCliName, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCliName sets the "cli_name" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsert) UpdateCliName() *ProjectTaskUpsert {
|
|
u.SetExcluded(projecttask.FieldCliName)
|
|
return u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *ProjectTaskUpsert) SetCreatedAt(v time.Time) *ProjectTaskUpsert {
|
|
u.Set(projecttask.FieldCreatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsert) UpdateCreatedAt() *ProjectTaskUpsert {
|
|
u.SetExcluded(projecttask.FieldCreatedAt)
|
|
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.ProjectTask.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(projecttask.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *ProjectTaskUpsertOne) UpdateNewValues() *ProjectTaskUpsertOne {
|
|
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(projecttask.FieldID)
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.ProjectTask.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *ProjectTaskUpsertOne) Ignore() *ProjectTaskUpsertOne {
|
|
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 *ProjectTaskUpsertOne) DoNothing() *ProjectTaskUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the ProjectTaskCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *ProjectTaskUpsertOne) Update(set func(*ProjectTaskUpsert)) *ProjectTaskUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&ProjectTaskUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetTaskID sets the "task_id" field.
|
|
func (u *ProjectTaskUpsertOne) SetTaskID(v uuid.UUID) *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetTaskID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTaskID sets the "task_id" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertOne) UpdateTaskID() *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateTaskID()
|
|
})
|
|
}
|
|
|
|
// SetModelID sets the "model_id" field.
|
|
func (u *ProjectTaskUpsertOne) SetModelID(v uuid.UUID) *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetModelID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateModelID sets the "model_id" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertOne) UpdateModelID() *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateModelID()
|
|
})
|
|
}
|
|
|
|
// SetImageID sets the "image_id" field.
|
|
func (u *ProjectTaskUpsertOne) SetImageID(v uuid.UUID) *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetImageID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateImageID sets the "image_id" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertOne) UpdateImageID() *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateImageID()
|
|
})
|
|
}
|
|
|
|
// SetGitIdentityID sets the "git_identity_id" field.
|
|
func (u *ProjectTaskUpsertOne) SetGitIdentityID(v uuid.UUID) *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetGitIdentityID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateGitIdentityID sets the "git_identity_id" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertOne) UpdateGitIdentityID() *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateGitIdentityID()
|
|
})
|
|
}
|
|
|
|
// ClearGitIdentityID clears the value of the "git_identity_id" field.
|
|
func (u *ProjectTaskUpsertOne) ClearGitIdentityID() *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.ClearGitIdentityID()
|
|
})
|
|
}
|
|
|
|
// SetProjectID sets the "project_id" field.
|
|
func (u *ProjectTaskUpsertOne) SetProjectID(v uuid.UUID) *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetProjectID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateProjectID sets the "project_id" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertOne) UpdateProjectID() *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateProjectID()
|
|
})
|
|
}
|
|
|
|
// ClearProjectID clears the value of the "project_id" field.
|
|
func (u *ProjectTaskUpsertOne) ClearProjectID() *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.ClearProjectID()
|
|
})
|
|
}
|
|
|
|
// SetIssueID sets the "issue_id" field.
|
|
func (u *ProjectTaskUpsertOne) SetIssueID(v uuid.UUID) *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetIssueID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIssueID sets the "issue_id" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertOne) UpdateIssueID() *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateIssueID()
|
|
})
|
|
}
|
|
|
|
// ClearIssueID clears the value of the "issue_id" field.
|
|
func (u *ProjectTaskUpsertOne) ClearIssueID() *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.ClearIssueID()
|
|
})
|
|
}
|
|
|
|
// SetRepoURL sets the "repo_url" field.
|
|
func (u *ProjectTaskUpsertOne) SetRepoURL(v string) *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetRepoURL(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRepoURL sets the "repo_url" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertOne) UpdateRepoURL() *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateRepoURL()
|
|
})
|
|
}
|
|
|
|
// ClearRepoURL clears the value of the "repo_url" field.
|
|
func (u *ProjectTaskUpsertOne) ClearRepoURL() *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.ClearRepoURL()
|
|
})
|
|
}
|
|
|
|
// SetRepoFilename sets the "repo_filename" field.
|
|
func (u *ProjectTaskUpsertOne) SetRepoFilename(v string) *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetRepoFilename(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRepoFilename sets the "repo_filename" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertOne) UpdateRepoFilename() *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateRepoFilename()
|
|
})
|
|
}
|
|
|
|
// ClearRepoFilename clears the value of the "repo_filename" field.
|
|
func (u *ProjectTaskUpsertOne) ClearRepoFilename() *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.ClearRepoFilename()
|
|
})
|
|
}
|
|
|
|
// SetBranch sets the "branch" field.
|
|
func (u *ProjectTaskUpsertOne) SetBranch(v string) *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetBranch(v)
|
|
})
|
|
}
|
|
|
|
// UpdateBranch sets the "branch" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertOne) UpdateBranch() *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateBranch()
|
|
})
|
|
}
|
|
|
|
// ClearBranch clears the value of the "branch" field.
|
|
func (u *ProjectTaskUpsertOne) ClearBranch() *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.ClearBranch()
|
|
})
|
|
}
|
|
|
|
// SetCliName sets the "cli_name" field.
|
|
func (u *ProjectTaskUpsertOne) SetCliName(v consts.CliName) *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetCliName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCliName sets the "cli_name" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertOne) UpdateCliName() *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateCliName()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *ProjectTaskUpsertOne) SetCreatedAt(v time.Time) *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertOne) UpdateCreatedAt() *ProjectTaskUpsertOne {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *ProjectTaskUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for ProjectTaskCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *ProjectTaskUpsertOne) 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 *ProjectTaskUpsertOne) 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: ProjectTaskUpsertOne.ID is not supported by MySQL driver. Use ProjectTaskUpsertOne.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 *ProjectTaskUpsertOne) IDX(ctx context.Context) uuid.UUID {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// ProjectTaskCreateBulk is the builder for creating many ProjectTask entities in bulk.
|
|
type ProjectTaskCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*ProjectTaskCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the ProjectTask entities in the database.
|
|
func (_c *ProjectTaskCreateBulk) Save(ctx context.Context) ([]*ProjectTask, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*ProjectTask, 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.(*ProjectTaskMutation)
|
|
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 *ProjectTaskCreateBulk) SaveX(ctx context.Context) []*ProjectTask {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *ProjectTaskCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *ProjectTaskCreateBulk) 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.ProjectTask.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.ProjectTaskUpsert) {
|
|
// SetTaskID(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *ProjectTaskCreateBulk) OnConflict(opts ...sql.ConflictOption) *ProjectTaskUpsertBulk {
|
|
_c.conflict = opts
|
|
return &ProjectTaskUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.ProjectTask.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *ProjectTaskCreateBulk) OnConflictColumns(columns ...string) *ProjectTaskUpsertBulk {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &ProjectTaskUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// ProjectTaskUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of ProjectTask nodes.
|
|
type ProjectTaskUpsertBulk struct {
|
|
create *ProjectTaskCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.ProjectTask.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(projecttask.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *ProjectTaskUpsertBulk) UpdateNewValues() *ProjectTaskUpsertBulk {
|
|
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(projecttask.FieldID)
|
|
}
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.ProjectTask.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *ProjectTaskUpsertBulk) Ignore() *ProjectTaskUpsertBulk {
|
|
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 *ProjectTaskUpsertBulk) DoNothing() *ProjectTaskUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the ProjectTaskCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *ProjectTaskUpsertBulk) Update(set func(*ProjectTaskUpsert)) *ProjectTaskUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&ProjectTaskUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetTaskID sets the "task_id" field.
|
|
func (u *ProjectTaskUpsertBulk) SetTaskID(v uuid.UUID) *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetTaskID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTaskID sets the "task_id" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertBulk) UpdateTaskID() *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateTaskID()
|
|
})
|
|
}
|
|
|
|
// SetModelID sets the "model_id" field.
|
|
func (u *ProjectTaskUpsertBulk) SetModelID(v uuid.UUID) *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetModelID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateModelID sets the "model_id" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertBulk) UpdateModelID() *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateModelID()
|
|
})
|
|
}
|
|
|
|
// SetImageID sets the "image_id" field.
|
|
func (u *ProjectTaskUpsertBulk) SetImageID(v uuid.UUID) *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetImageID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateImageID sets the "image_id" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertBulk) UpdateImageID() *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateImageID()
|
|
})
|
|
}
|
|
|
|
// SetGitIdentityID sets the "git_identity_id" field.
|
|
func (u *ProjectTaskUpsertBulk) SetGitIdentityID(v uuid.UUID) *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetGitIdentityID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateGitIdentityID sets the "git_identity_id" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertBulk) UpdateGitIdentityID() *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateGitIdentityID()
|
|
})
|
|
}
|
|
|
|
// ClearGitIdentityID clears the value of the "git_identity_id" field.
|
|
func (u *ProjectTaskUpsertBulk) ClearGitIdentityID() *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.ClearGitIdentityID()
|
|
})
|
|
}
|
|
|
|
// SetProjectID sets the "project_id" field.
|
|
func (u *ProjectTaskUpsertBulk) SetProjectID(v uuid.UUID) *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetProjectID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateProjectID sets the "project_id" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertBulk) UpdateProjectID() *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateProjectID()
|
|
})
|
|
}
|
|
|
|
// ClearProjectID clears the value of the "project_id" field.
|
|
func (u *ProjectTaskUpsertBulk) ClearProjectID() *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.ClearProjectID()
|
|
})
|
|
}
|
|
|
|
// SetIssueID sets the "issue_id" field.
|
|
func (u *ProjectTaskUpsertBulk) SetIssueID(v uuid.UUID) *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetIssueID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIssueID sets the "issue_id" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertBulk) UpdateIssueID() *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateIssueID()
|
|
})
|
|
}
|
|
|
|
// ClearIssueID clears the value of the "issue_id" field.
|
|
func (u *ProjectTaskUpsertBulk) ClearIssueID() *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.ClearIssueID()
|
|
})
|
|
}
|
|
|
|
// SetRepoURL sets the "repo_url" field.
|
|
func (u *ProjectTaskUpsertBulk) SetRepoURL(v string) *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetRepoURL(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRepoURL sets the "repo_url" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertBulk) UpdateRepoURL() *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateRepoURL()
|
|
})
|
|
}
|
|
|
|
// ClearRepoURL clears the value of the "repo_url" field.
|
|
func (u *ProjectTaskUpsertBulk) ClearRepoURL() *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.ClearRepoURL()
|
|
})
|
|
}
|
|
|
|
// SetRepoFilename sets the "repo_filename" field.
|
|
func (u *ProjectTaskUpsertBulk) SetRepoFilename(v string) *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetRepoFilename(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRepoFilename sets the "repo_filename" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertBulk) UpdateRepoFilename() *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateRepoFilename()
|
|
})
|
|
}
|
|
|
|
// ClearRepoFilename clears the value of the "repo_filename" field.
|
|
func (u *ProjectTaskUpsertBulk) ClearRepoFilename() *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.ClearRepoFilename()
|
|
})
|
|
}
|
|
|
|
// SetBranch sets the "branch" field.
|
|
func (u *ProjectTaskUpsertBulk) SetBranch(v string) *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetBranch(v)
|
|
})
|
|
}
|
|
|
|
// UpdateBranch sets the "branch" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertBulk) UpdateBranch() *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateBranch()
|
|
})
|
|
}
|
|
|
|
// ClearBranch clears the value of the "branch" field.
|
|
func (u *ProjectTaskUpsertBulk) ClearBranch() *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.ClearBranch()
|
|
})
|
|
}
|
|
|
|
// SetCliName sets the "cli_name" field.
|
|
func (u *ProjectTaskUpsertBulk) SetCliName(v consts.CliName) *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetCliName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCliName sets the "cli_name" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertBulk) UpdateCliName() *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateCliName()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *ProjectTaskUpsertBulk) SetCreatedAt(v time.Time) *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *ProjectTaskUpsertBulk) UpdateCreatedAt() *ProjectTaskUpsertBulk {
|
|
return u.Update(func(s *ProjectTaskUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *ProjectTaskUpsertBulk) 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 ProjectTaskCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for ProjectTaskCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *ProjectTaskUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|