mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-22 03:18:50 +08:00
997 lines
32 KiB
Go
997 lines
32 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/db/projectissue"
|
|
"github.com/chaitin/MonkeyCode/backend/db/projectissuecomment"
|
|
"github.com/chaitin/MonkeyCode/backend/db/user"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// ProjectIssueCommentCreate is the builder for creating a ProjectIssueComment entity.
|
|
type ProjectIssueCommentCreate struct {
|
|
config
|
|
mutation *ProjectIssueCommentMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (_c *ProjectIssueCommentCreate) SetDeletedAt(v time.Time) *ProjectIssueCommentCreate {
|
|
_c.mutation.SetDeletedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (_c *ProjectIssueCommentCreate) SetNillableDeletedAt(v *time.Time) *ProjectIssueCommentCreate {
|
|
if v != nil {
|
|
_c.SetDeletedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_c *ProjectIssueCommentCreate) SetUserID(v uuid.UUID) *ProjectIssueCommentCreate {
|
|
_c.mutation.SetUserID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetIssueID sets the "issue_id" field.
|
|
func (_c *ProjectIssueCommentCreate) SetIssueID(v uuid.UUID) *ProjectIssueCommentCreate {
|
|
_c.mutation.SetIssueID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetParentID sets the "parent_id" field.
|
|
func (_c *ProjectIssueCommentCreate) SetParentID(v uuid.UUID) *ProjectIssueCommentCreate {
|
|
_c.mutation.SetParentID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableParentID sets the "parent_id" field if the given value is not nil.
|
|
func (_c *ProjectIssueCommentCreate) SetNillableParentID(v *uuid.UUID) *ProjectIssueCommentCreate {
|
|
if v != nil {
|
|
_c.SetParentID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetComment sets the "comment" field.
|
|
func (_c *ProjectIssueCommentCreate) SetComment(v string) *ProjectIssueCommentCreate {
|
|
_c.mutation.SetComment(v)
|
|
return _c
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_c *ProjectIssueCommentCreate) SetCreatedAt(v time.Time) *ProjectIssueCommentCreate {
|
|
_c.mutation.SetCreatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_c *ProjectIssueCommentCreate) SetNillableCreatedAt(v *time.Time) *ProjectIssueCommentCreate {
|
|
if v != nil {
|
|
_c.SetCreatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_c *ProjectIssueCommentCreate) SetUpdatedAt(v time.Time) *ProjectIssueCommentCreate {
|
|
_c.mutation.SetUpdatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_c *ProjectIssueCommentCreate) SetNillableUpdatedAt(v *time.Time) *ProjectIssueCommentCreate {
|
|
if v != nil {
|
|
_c.SetUpdatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetID sets the "id" field.
|
|
func (_c *ProjectIssueCommentCreate) SetID(v uuid.UUID) *ProjectIssueCommentCreate {
|
|
_c.mutation.SetID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetUser sets the "user" edge to the User entity.
|
|
func (_c *ProjectIssueCommentCreate) SetUser(v *User) *ProjectIssueCommentCreate {
|
|
return _c.SetUserID(v.ID)
|
|
}
|
|
|
|
// SetIssue sets the "issue" edge to the ProjectIssue entity.
|
|
func (_c *ProjectIssueCommentCreate) SetIssue(v *ProjectIssue) *ProjectIssueCommentCreate {
|
|
return _c.SetIssueID(v.ID)
|
|
}
|
|
|
|
// SetParent sets the "parent" edge to the ProjectIssueComment entity.
|
|
func (_c *ProjectIssueCommentCreate) SetParent(v *ProjectIssueComment) *ProjectIssueCommentCreate {
|
|
return _c.SetParentID(v.ID)
|
|
}
|
|
|
|
// AddReplyIDs adds the "replies" edge to the ProjectIssueComment entity by IDs.
|
|
func (_c *ProjectIssueCommentCreate) AddReplyIDs(ids ...uuid.UUID) *ProjectIssueCommentCreate {
|
|
_c.mutation.AddReplyIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddReplies adds the "replies" edges to the ProjectIssueComment entity.
|
|
func (_c *ProjectIssueCommentCreate) AddReplies(v ...*ProjectIssueComment) *ProjectIssueCommentCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddReplyIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the ProjectIssueCommentMutation object of the builder.
|
|
func (_c *ProjectIssueCommentCreate) Mutation() *ProjectIssueCommentMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the ProjectIssueComment in the database.
|
|
func (_c *ProjectIssueCommentCreate) Save(ctx context.Context) (*ProjectIssueComment, 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 *ProjectIssueCommentCreate) SaveX(ctx context.Context) *ProjectIssueComment {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *ProjectIssueCommentCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *ProjectIssueCommentCreate) 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 *ProjectIssueCommentCreate) defaults() error {
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
if projectissuecomment.DefaultCreatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized projectissuecomment.DefaultCreatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := projectissuecomment.DefaultCreatedAt()
|
|
_c.mutation.SetCreatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
if projectissuecomment.DefaultUpdatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized projectissuecomment.DefaultUpdatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := projectissuecomment.DefaultUpdatedAt()
|
|
_c.mutation.SetUpdatedAt(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *ProjectIssueCommentCreate) check() error {
|
|
if _, ok := _c.mutation.UserID(); !ok {
|
|
return &ValidationError{Name: "user_id", err: errors.New(`db: missing required field "ProjectIssueComment.user_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.IssueID(); !ok {
|
|
return &ValidationError{Name: "issue_id", err: errors.New(`db: missing required field "ProjectIssueComment.issue_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.Comment(); !ok {
|
|
return &ValidationError{Name: "comment", err: errors.New(`db: missing required field "ProjectIssueComment.comment"`)}
|
|
}
|
|
if v, ok := _c.mutation.Comment(); ok {
|
|
if err := projectissuecomment.CommentValidator(v); err != nil {
|
|
return &ValidationError{Name: "comment", err: fmt.Errorf(`db: validator failed for field "ProjectIssueComment.comment": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "ProjectIssueComment.created_at"`)}
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "ProjectIssueComment.updated_at"`)}
|
|
}
|
|
if len(_c.mutation.UserIDs()) == 0 {
|
|
return &ValidationError{Name: "user", err: errors.New(`db: missing required edge "ProjectIssueComment.user"`)}
|
|
}
|
|
if len(_c.mutation.IssueIDs()) == 0 {
|
|
return &ValidationError{Name: "issue", err: errors.New(`db: missing required edge "ProjectIssueComment.issue"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *ProjectIssueCommentCreate) sqlSave(ctx context.Context) (*ProjectIssueComment, 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 *ProjectIssueCommentCreate) createSpec() (*ProjectIssueComment, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &ProjectIssueComment{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(projectissuecomment.Table, sqlgraph.NewFieldSpec(projectissuecomment.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(projectissuecomment.FieldDeletedAt, field.TypeTime, value)
|
|
_node.DeletedAt = value
|
|
}
|
|
if value, ok := _c.mutation.Comment(); ok {
|
|
_spec.SetField(projectissuecomment.FieldComment, field.TypeString, value)
|
|
_node.Comment = value
|
|
}
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
|
_spec.SetField(projectissuecomment.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if value, ok := _c.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(projectissuecomment.FieldUpdatedAt, field.TypeTime, value)
|
|
_node.UpdatedAt = value
|
|
}
|
|
if nodes := _c.mutation.UserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectissuecomment.UserTable,
|
|
Columns: []string{projectissuecomment.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.IssueIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectissuecomment.IssueTable,
|
|
Columns: []string{projectissuecomment.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)
|
|
}
|
|
if nodes := _c.mutation.ParentIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: projectissuecomment.ParentTable,
|
|
Columns: []string{projectissuecomment.ParentColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projectissuecomment.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.ParentID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.RepliesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: projectissuecomment.RepliesTable,
|
|
Columns: []string{projectissuecomment.RepliesColumn},
|
|
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)
|
|
}
|
|
return _node, _spec
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.ProjectIssueComment.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.ProjectIssueCommentUpsert) {
|
|
// SetDeletedAt(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *ProjectIssueCommentCreate) OnConflict(opts ...sql.ConflictOption) *ProjectIssueCommentUpsertOne {
|
|
_c.conflict = opts
|
|
return &ProjectIssueCommentUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.ProjectIssueComment.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *ProjectIssueCommentCreate) OnConflictColumns(columns ...string) *ProjectIssueCommentUpsertOne {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &ProjectIssueCommentUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// ProjectIssueCommentUpsertOne is the builder for "upsert"-ing
|
|
// one ProjectIssueComment node.
|
|
ProjectIssueCommentUpsertOne struct {
|
|
create *ProjectIssueCommentCreate
|
|
}
|
|
|
|
// ProjectIssueCommentUpsert is the "OnConflict" setter.
|
|
ProjectIssueCommentUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *ProjectIssueCommentUpsert) SetDeletedAt(v time.Time) *ProjectIssueCommentUpsert {
|
|
u.Set(projectissuecomment.FieldDeletedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsert) UpdateDeletedAt() *ProjectIssueCommentUpsert {
|
|
u.SetExcluded(projectissuecomment.FieldDeletedAt)
|
|
return u
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *ProjectIssueCommentUpsert) ClearDeletedAt() *ProjectIssueCommentUpsert {
|
|
u.SetNull(projectissuecomment.FieldDeletedAt)
|
|
return u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *ProjectIssueCommentUpsert) SetUserID(v uuid.UUID) *ProjectIssueCommentUpsert {
|
|
u.Set(projectissuecomment.FieldUserID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsert) UpdateUserID() *ProjectIssueCommentUpsert {
|
|
u.SetExcluded(projectissuecomment.FieldUserID)
|
|
return u
|
|
}
|
|
|
|
// SetIssueID sets the "issue_id" field.
|
|
func (u *ProjectIssueCommentUpsert) SetIssueID(v uuid.UUID) *ProjectIssueCommentUpsert {
|
|
u.Set(projectissuecomment.FieldIssueID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateIssueID sets the "issue_id" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsert) UpdateIssueID() *ProjectIssueCommentUpsert {
|
|
u.SetExcluded(projectissuecomment.FieldIssueID)
|
|
return u
|
|
}
|
|
|
|
// SetParentID sets the "parent_id" field.
|
|
func (u *ProjectIssueCommentUpsert) SetParentID(v uuid.UUID) *ProjectIssueCommentUpsert {
|
|
u.Set(projectissuecomment.FieldParentID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateParentID sets the "parent_id" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsert) UpdateParentID() *ProjectIssueCommentUpsert {
|
|
u.SetExcluded(projectissuecomment.FieldParentID)
|
|
return u
|
|
}
|
|
|
|
// ClearParentID clears the value of the "parent_id" field.
|
|
func (u *ProjectIssueCommentUpsert) ClearParentID() *ProjectIssueCommentUpsert {
|
|
u.SetNull(projectissuecomment.FieldParentID)
|
|
return u
|
|
}
|
|
|
|
// SetComment sets the "comment" field.
|
|
func (u *ProjectIssueCommentUpsert) SetComment(v string) *ProjectIssueCommentUpsert {
|
|
u.Set(projectissuecomment.FieldComment, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateComment sets the "comment" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsert) UpdateComment() *ProjectIssueCommentUpsert {
|
|
u.SetExcluded(projectissuecomment.FieldComment)
|
|
return u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *ProjectIssueCommentUpsert) SetCreatedAt(v time.Time) *ProjectIssueCommentUpsert {
|
|
u.Set(projectissuecomment.FieldCreatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsert) UpdateCreatedAt() *ProjectIssueCommentUpsert {
|
|
u.SetExcluded(projectissuecomment.FieldCreatedAt)
|
|
return u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *ProjectIssueCommentUpsert) SetUpdatedAt(v time.Time) *ProjectIssueCommentUpsert {
|
|
u.Set(projectissuecomment.FieldUpdatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsert) UpdateUpdatedAt() *ProjectIssueCommentUpsert {
|
|
u.SetExcluded(projectissuecomment.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.ProjectIssueComment.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(projectissuecomment.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *ProjectIssueCommentUpsertOne) UpdateNewValues() *ProjectIssueCommentUpsertOne {
|
|
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(projectissuecomment.FieldID)
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.ProjectIssueComment.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *ProjectIssueCommentUpsertOne) Ignore() *ProjectIssueCommentUpsertOne {
|
|
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 *ProjectIssueCommentUpsertOne) DoNothing() *ProjectIssueCommentUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the ProjectIssueCommentCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *ProjectIssueCommentUpsertOne) Update(set func(*ProjectIssueCommentUpsert)) *ProjectIssueCommentUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&ProjectIssueCommentUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *ProjectIssueCommentUpsertOne) SetDeletedAt(v time.Time) *ProjectIssueCommentUpsertOne {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.SetDeletedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsertOne) UpdateDeletedAt() *ProjectIssueCommentUpsertOne {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.UpdateDeletedAt()
|
|
})
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *ProjectIssueCommentUpsertOne) ClearDeletedAt() *ProjectIssueCommentUpsertOne {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.ClearDeletedAt()
|
|
})
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *ProjectIssueCommentUpsertOne) SetUserID(v uuid.UUID) *ProjectIssueCommentUpsertOne {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.SetUserID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsertOne) UpdateUserID() *ProjectIssueCommentUpsertOne {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.UpdateUserID()
|
|
})
|
|
}
|
|
|
|
// SetIssueID sets the "issue_id" field.
|
|
func (u *ProjectIssueCommentUpsertOne) SetIssueID(v uuid.UUID) *ProjectIssueCommentUpsertOne {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.SetIssueID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIssueID sets the "issue_id" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsertOne) UpdateIssueID() *ProjectIssueCommentUpsertOne {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.UpdateIssueID()
|
|
})
|
|
}
|
|
|
|
// SetParentID sets the "parent_id" field.
|
|
func (u *ProjectIssueCommentUpsertOne) SetParentID(v uuid.UUID) *ProjectIssueCommentUpsertOne {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.SetParentID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateParentID sets the "parent_id" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsertOne) UpdateParentID() *ProjectIssueCommentUpsertOne {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.UpdateParentID()
|
|
})
|
|
}
|
|
|
|
// ClearParentID clears the value of the "parent_id" field.
|
|
func (u *ProjectIssueCommentUpsertOne) ClearParentID() *ProjectIssueCommentUpsertOne {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.ClearParentID()
|
|
})
|
|
}
|
|
|
|
// SetComment sets the "comment" field.
|
|
func (u *ProjectIssueCommentUpsertOne) SetComment(v string) *ProjectIssueCommentUpsertOne {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.SetComment(v)
|
|
})
|
|
}
|
|
|
|
// UpdateComment sets the "comment" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsertOne) UpdateComment() *ProjectIssueCommentUpsertOne {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.UpdateComment()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *ProjectIssueCommentUpsertOne) SetCreatedAt(v time.Time) *ProjectIssueCommentUpsertOne {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsertOne) UpdateCreatedAt() *ProjectIssueCommentUpsertOne {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *ProjectIssueCommentUpsertOne) SetUpdatedAt(v time.Time) *ProjectIssueCommentUpsertOne {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsertOne) UpdateUpdatedAt() *ProjectIssueCommentUpsertOne {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *ProjectIssueCommentUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for ProjectIssueCommentCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *ProjectIssueCommentUpsertOne) 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 *ProjectIssueCommentUpsertOne) 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: ProjectIssueCommentUpsertOne.ID is not supported by MySQL driver. Use ProjectIssueCommentUpsertOne.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 *ProjectIssueCommentUpsertOne) IDX(ctx context.Context) uuid.UUID {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// ProjectIssueCommentCreateBulk is the builder for creating many ProjectIssueComment entities in bulk.
|
|
type ProjectIssueCommentCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*ProjectIssueCommentCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the ProjectIssueComment entities in the database.
|
|
func (_c *ProjectIssueCommentCreateBulk) Save(ctx context.Context) ([]*ProjectIssueComment, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*ProjectIssueComment, 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.(*ProjectIssueCommentMutation)
|
|
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 *ProjectIssueCommentCreateBulk) SaveX(ctx context.Context) []*ProjectIssueComment {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *ProjectIssueCommentCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *ProjectIssueCommentCreateBulk) 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.ProjectIssueComment.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.ProjectIssueCommentUpsert) {
|
|
// SetDeletedAt(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *ProjectIssueCommentCreateBulk) OnConflict(opts ...sql.ConflictOption) *ProjectIssueCommentUpsertBulk {
|
|
_c.conflict = opts
|
|
return &ProjectIssueCommentUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.ProjectIssueComment.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *ProjectIssueCommentCreateBulk) OnConflictColumns(columns ...string) *ProjectIssueCommentUpsertBulk {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &ProjectIssueCommentUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// ProjectIssueCommentUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of ProjectIssueComment nodes.
|
|
type ProjectIssueCommentUpsertBulk struct {
|
|
create *ProjectIssueCommentCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.ProjectIssueComment.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(projectissuecomment.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *ProjectIssueCommentUpsertBulk) UpdateNewValues() *ProjectIssueCommentUpsertBulk {
|
|
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(projectissuecomment.FieldID)
|
|
}
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.ProjectIssueComment.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *ProjectIssueCommentUpsertBulk) Ignore() *ProjectIssueCommentUpsertBulk {
|
|
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 *ProjectIssueCommentUpsertBulk) DoNothing() *ProjectIssueCommentUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the ProjectIssueCommentCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *ProjectIssueCommentUpsertBulk) Update(set func(*ProjectIssueCommentUpsert)) *ProjectIssueCommentUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&ProjectIssueCommentUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *ProjectIssueCommentUpsertBulk) SetDeletedAt(v time.Time) *ProjectIssueCommentUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.SetDeletedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsertBulk) UpdateDeletedAt() *ProjectIssueCommentUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.UpdateDeletedAt()
|
|
})
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *ProjectIssueCommentUpsertBulk) ClearDeletedAt() *ProjectIssueCommentUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.ClearDeletedAt()
|
|
})
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *ProjectIssueCommentUpsertBulk) SetUserID(v uuid.UUID) *ProjectIssueCommentUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.SetUserID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsertBulk) UpdateUserID() *ProjectIssueCommentUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.UpdateUserID()
|
|
})
|
|
}
|
|
|
|
// SetIssueID sets the "issue_id" field.
|
|
func (u *ProjectIssueCommentUpsertBulk) SetIssueID(v uuid.UUID) *ProjectIssueCommentUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.SetIssueID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIssueID sets the "issue_id" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsertBulk) UpdateIssueID() *ProjectIssueCommentUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.UpdateIssueID()
|
|
})
|
|
}
|
|
|
|
// SetParentID sets the "parent_id" field.
|
|
func (u *ProjectIssueCommentUpsertBulk) SetParentID(v uuid.UUID) *ProjectIssueCommentUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.SetParentID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateParentID sets the "parent_id" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsertBulk) UpdateParentID() *ProjectIssueCommentUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.UpdateParentID()
|
|
})
|
|
}
|
|
|
|
// ClearParentID clears the value of the "parent_id" field.
|
|
func (u *ProjectIssueCommentUpsertBulk) ClearParentID() *ProjectIssueCommentUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.ClearParentID()
|
|
})
|
|
}
|
|
|
|
// SetComment sets the "comment" field.
|
|
func (u *ProjectIssueCommentUpsertBulk) SetComment(v string) *ProjectIssueCommentUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.SetComment(v)
|
|
})
|
|
}
|
|
|
|
// UpdateComment sets the "comment" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsertBulk) UpdateComment() *ProjectIssueCommentUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.UpdateComment()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *ProjectIssueCommentUpsertBulk) SetCreatedAt(v time.Time) *ProjectIssueCommentUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsertBulk) UpdateCreatedAt() *ProjectIssueCommentUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *ProjectIssueCommentUpsertBulk) SetUpdatedAt(v time.Time) *ProjectIssueCommentUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *ProjectIssueCommentUpsertBulk) UpdateUpdatedAt() *ProjectIssueCommentUpsertBulk {
|
|
return u.Update(func(s *ProjectIssueCommentUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *ProjectIssueCommentUpsertBulk) 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 ProjectIssueCommentCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for ProjectIssueCommentCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *ProjectIssueCommentUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|