mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-30 08:37:12 +08:00
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1370 lines
42 KiB
Go
1370 lines
42 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/agentsyncjob"
|
|
"github.com/chaitin/MonkeyCode/backend/ent/types"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// AgentSyncJobCreate is the builder for creating a AgentSyncJob entity.
|
|
type AgentSyncJobCreate struct {
|
|
config
|
|
mutation *AgentSyncJobMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetResourceKind sets the "resource_kind" field.
|
|
func (_c *AgentSyncJobCreate) SetResourceKind(v agentsyncjob.ResourceKind) *AgentSyncJobCreate {
|
|
_c.mutation.SetResourceKind(v)
|
|
return _c
|
|
}
|
|
|
|
// SetRuleID sets the "rule_id" field.
|
|
func (_c *AgentSyncJobCreate) SetRuleID(v uuid.UUID) *AgentSyncJobCreate {
|
|
_c.mutation.SetRuleID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableRuleID sets the "rule_id" field if the given value is not nil.
|
|
func (_c *AgentSyncJobCreate) SetNillableRuleID(v *uuid.UUID) *AgentSyncJobCreate {
|
|
if v != nil {
|
|
_c.SetRuleID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetRepoID sets the "repo_id" field.
|
|
func (_c *AgentSyncJobCreate) SetRepoID(v uuid.UUID) *AgentSyncJobCreate {
|
|
_c.mutation.SetRepoID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableRepoID sets the "repo_id" field if the given value is not nil.
|
|
func (_c *AgentSyncJobCreate) SetNillableRepoID(v *uuid.UUID) *AgentSyncJobCreate {
|
|
if v != nil {
|
|
_c.SetRepoID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetSourceType sets the "source_type" field.
|
|
func (_c *AgentSyncJobCreate) SetSourceType(v agentsyncjob.SourceType) *AgentSyncJobCreate {
|
|
_c.mutation.SetSourceType(v)
|
|
return _c
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_c *AgentSyncJobCreate) SetStatus(v agentsyncjob.Status) *AgentSyncJobCreate {
|
|
_c.mutation.SetStatus(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_c *AgentSyncJobCreate) SetNillableStatus(v *agentsyncjob.Status) *AgentSyncJobCreate {
|
|
if v != nil {
|
|
_c.SetStatus(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetTriggerType sets the "trigger_type" field.
|
|
func (_c *AgentSyncJobCreate) SetTriggerType(v agentsyncjob.TriggerType) *AgentSyncJobCreate {
|
|
_c.mutation.SetTriggerType(v)
|
|
return _c
|
|
}
|
|
|
|
// SetTriggeredBy sets the "triggered_by" field.
|
|
func (_c *AgentSyncJobCreate) SetTriggeredBy(v uuid.UUID) *AgentSyncJobCreate {
|
|
_c.mutation.SetTriggeredBy(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableTriggeredBy sets the "triggered_by" field if the given value is not nil.
|
|
func (_c *AgentSyncJobCreate) SetNillableTriggeredBy(v *uuid.UUID) *AgentSyncJobCreate {
|
|
if v != nil {
|
|
_c.SetTriggeredBy(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetStartedAt sets the "started_at" field.
|
|
func (_c *AgentSyncJobCreate) SetStartedAt(v time.Time) *AgentSyncJobCreate {
|
|
_c.mutation.SetStartedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableStartedAt sets the "started_at" field if the given value is not nil.
|
|
func (_c *AgentSyncJobCreate) SetNillableStartedAt(v *time.Time) *AgentSyncJobCreate {
|
|
if v != nil {
|
|
_c.SetStartedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetFinishedAt sets the "finished_at" field.
|
|
func (_c *AgentSyncJobCreate) SetFinishedAt(v time.Time) *AgentSyncJobCreate {
|
|
_c.mutation.SetFinishedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableFinishedAt sets the "finished_at" field if the given value is not nil.
|
|
func (_c *AgentSyncJobCreate) SetNillableFinishedAt(v *time.Time) *AgentSyncJobCreate {
|
|
if v != nil {
|
|
_c.SetFinishedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetErrors sets the "errors" field.
|
|
func (_c *AgentSyncJobCreate) SetErrors(v types.SyncJobErrors) *AgentSyncJobCreate {
|
|
_c.mutation.SetErrors(v)
|
|
return _c
|
|
}
|
|
|
|
// SetResultSummary sets the "result_summary" field.
|
|
func (_c *AgentSyncJobCreate) SetResultSummary(v types.SyncJobResultSummary) *AgentSyncJobCreate {
|
|
_c.mutation.SetResultSummary(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableResultSummary sets the "result_summary" field if the given value is not nil.
|
|
func (_c *AgentSyncJobCreate) SetNillableResultSummary(v *types.SyncJobResultSummary) *AgentSyncJobCreate {
|
|
if v != nil {
|
|
_c.SetResultSummary(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_c *AgentSyncJobCreate) SetCreatedAt(v time.Time) *AgentSyncJobCreate {
|
|
_c.mutation.SetCreatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_c *AgentSyncJobCreate) SetNillableCreatedAt(v *time.Time) *AgentSyncJobCreate {
|
|
if v != nil {
|
|
_c.SetCreatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_c *AgentSyncJobCreate) SetUpdatedAt(v time.Time) *AgentSyncJobCreate {
|
|
_c.mutation.SetUpdatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_c *AgentSyncJobCreate) SetNillableUpdatedAt(v *time.Time) *AgentSyncJobCreate {
|
|
if v != nil {
|
|
_c.SetUpdatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetID sets the "id" field.
|
|
func (_c *AgentSyncJobCreate) SetID(v uuid.UUID) *AgentSyncJobCreate {
|
|
_c.mutation.SetID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableID sets the "id" field if the given value is not nil.
|
|
func (_c *AgentSyncJobCreate) SetNillableID(v *uuid.UUID) *AgentSyncJobCreate {
|
|
if v != nil {
|
|
_c.SetID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// Mutation returns the AgentSyncJobMutation object of the builder.
|
|
func (_c *AgentSyncJobCreate) Mutation() *AgentSyncJobMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the AgentSyncJob in the database.
|
|
func (_c *AgentSyncJobCreate) Save(ctx context.Context) (*AgentSyncJob, error) {
|
|
_c.defaults()
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *AgentSyncJobCreate) SaveX(ctx context.Context) *AgentSyncJob {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *AgentSyncJobCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *AgentSyncJobCreate) 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 *AgentSyncJobCreate) defaults() {
|
|
if _, ok := _c.mutation.Status(); !ok {
|
|
v := agentsyncjob.DefaultStatus
|
|
_c.mutation.SetStatus(v)
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
v := agentsyncjob.DefaultCreatedAt()
|
|
_c.mutation.SetCreatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
v := agentsyncjob.DefaultUpdatedAt()
|
|
_c.mutation.SetUpdatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.ID(); !ok {
|
|
v := agentsyncjob.DefaultID()
|
|
_c.mutation.SetID(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *AgentSyncJobCreate) check() error {
|
|
if _, ok := _c.mutation.ResourceKind(); !ok {
|
|
return &ValidationError{Name: "resource_kind", err: errors.New(`db: missing required field "AgentSyncJob.resource_kind"`)}
|
|
}
|
|
if v, ok := _c.mutation.ResourceKind(); ok {
|
|
if err := agentsyncjob.ResourceKindValidator(v); err != nil {
|
|
return &ValidationError{Name: "resource_kind", err: fmt.Errorf(`db: validator failed for field "AgentSyncJob.resource_kind": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.SourceType(); !ok {
|
|
return &ValidationError{Name: "source_type", err: errors.New(`db: missing required field "AgentSyncJob.source_type"`)}
|
|
}
|
|
if v, ok := _c.mutation.SourceType(); ok {
|
|
if err := agentsyncjob.SourceTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "source_type", err: fmt.Errorf(`db: validator failed for field "AgentSyncJob.source_type": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.Status(); !ok {
|
|
return &ValidationError{Name: "status", err: errors.New(`db: missing required field "AgentSyncJob.status"`)}
|
|
}
|
|
if v, ok := _c.mutation.Status(); ok {
|
|
if err := agentsyncjob.StatusValidator(v); err != nil {
|
|
return &ValidationError{Name: "status", err: fmt.Errorf(`db: validator failed for field "AgentSyncJob.status": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.TriggerType(); !ok {
|
|
return &ValidationError{Name: "trigger_type", err: errors.New(`db: missing required field "AgentSyncJob.trigger_type"`)}
|
|
}
|
|
if v, ok := _c.mutation.TriggerType(); ok {
|
|
if err := agentsyncjob.TriggerTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "trigger_type", err: fmt.Errorf(`db: validator failed for field "AgentSyncJob.trigger_type": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "AgentSyncJob.created_at"`)}
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "AgentSyncJob.updated_at"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *AgentSyncJobCreate) sqlSave(ctx context.Context) (*AgentSyncJob, 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 *AgentSyncJobCreate) createSpec() (*AgentSyncJob, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &AgentSyncJob{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(agentsyncjob.Table, sqlgraph.NewFieldSpec(agentsyncjob.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.ResourceKind(); ok {
|
|
_spec.SetField(agentsyncjob.FieldResourceKind, field.TypeEnum, value)
|
|
_node.ResourceKind = value
|
|
}
|
|
if value, ok := _c.mutation.RuleID(); ok {
|
|
_spec.SetField(agentsyncjob.FieldRuleID, field.TypeUUID, value)
|
|
_node.RuleID = &value
|
|
}
|
|
if value, ok := _c.mutation.RepoID(); ok {
|
|
_spec.SetField(agentsyncjob.FieldRepoID, field.TypeUUID, value)
|
|
_node.RepoID = &value
|
|
}
|
|
if value, ok := _c.mutation.SourceType(); ok {
|
|
_spec.SetField(agentsyncjob.FieldSourceType, field.TypeEnum, value)
|
|
_node.SourceType = value
|
|
}
|
|
if value, ok := _c.mutation.Status(); ok {
|
|
_spec.SetField(agentsyncjob.FieldStatus, field.TypeEnum, value)
|
|
_node.Status = value
|
|
}
|
|
if value, ok := _c.mutation.TriggerType(); ok {
|
|
_spec.SetField(agentsyncjob.FieldTriggerType, field.TypeEnum, value)
|
|
_node.TriggerType = value
|
|
}
|
|
if value, ok := _c.mutation.TriggeredBy(); ok {
|
|
_spec.SetField(agentsyncjob.FieldTriggeredBy, field.TypeUUID, value)
|
|
_node.TriggeredBy = &value
|
|
}
|
|
if value, ok := _c.mutation.StartedAt(); ok {
|
|
_spec.SetField(agentsyncjob.FieldStartedAt, field.TypeTime, value)
|
|
_node.StartedAt = &value
|
|
}
|
|
if value, ok := _c.mutation.FinishedAt(); ok {
|
|
_spec.SetField(agentsyncjob.FieldFinishedAt, field.TypeTime, value)
|
|
_node.FinishedAt = &value
|
|
}
|
|
if value, ok := _c.mutation.Errors(); ok {
|
|
_spec.SetField(agentsyncjob.FieldErrors, field.TypeJSON, value)
|
|
_node.Errors = value
|
|
}
|
|
if value, ok := _c.mutation.ResultSummary(); ok {
|
|
_spec.SetField(agentsyncjob.FieldResultSummary, field.TypeJSON, value)
|
|
_node.ResultSummary = value
|
|
}
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
|
_spec.SetField(agentsyncjob.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if value, ok := _c.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(agentsyncjob.FieldUpdatedAt, field.TypeTime, value)
|
|
_node.UpdatedAt = value
|
|
}
|
|
return _node, _spec
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.AgentSyncJob.Create().
|
|
// SetResourceKind(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.AgentSyncJobUpsert) {
|
|
// SetResourceKind(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *AgentSyncJobCreate) OnConflict(opts ...sql.ConflictOption) *AgentSyncJobUpsertOne {
|
|
_c.conflict = opts
|
|
return &AgentSyncJobUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.AgentSyncJob.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *AgentSyncJobCreate) OnConflictColumns(columns ...string) *AgentSyncJobUpsertOne {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &AgentSyncJobUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// AgentSyncJobUpsertOne is the builder for "upsert"-ing
|
|
// one AgentSyncJob node.
|
|
AgentSyncJobUpsertOne struct {
|
|
create *AgentSyncJobCreate
|
|
}
|
|
|
|
// AgentSyncJobUpsert is the "OnConflict" setter.
|
|
AgentSyncJobUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetResourceKind sets the "resource_kind" field.
|
|
func (u *AgentSyncJobUpsert) SetResourceKind(v agentsyncjob.ResourceKind) *AgentSyncJobUpsert {
|
|
u.Set(agentsyncjob.FieldResourceKind, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateResourceKind sets the "resource_kind" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsert) UpdateResourceKind() *AgentSyncJobUpsert {
|
|
u.SetExcluded(agentsyncjob.FieldResourceKind)
|
|
return u
|
|
}
|
|
|
|
// SetRuleID sets the "rule_id" field.
|
|
func (u *AgentSyncJobUpsert) SetRuleID(v uuid.UUID) *AgentSyncJobUpsert {
|
|
u.Set(agentsyncjob.FieldRuleID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateRuleID sets the "rule_id" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsert) UpdateRuleID() *AgentSyncJobUpsert {
|
|
u.SetExcluded(agentsyncjob.FieldRuleID)
|
|
return u
|
|
}
|
|
|
|
// ClearRuleID clears the value of the "rule_id" field.
|
|
func (u *AgentSyncJobUpsert) ClearRuleID() *AgentSyncJobUpsert {
|
|
u.SetNull(agentsyncjob.FieldRuleID)
|
|
return u
|
|
}
|
|
|
|
// SetRepoID sets the "repo_id" field.
|
|
func (u *AgentSyncJobUpsert) SetRepoID(v uuid.UUID) *AgentSyncJobUpsert {
|
|
u.Set(agentsyncjob.FieldRepoID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateRepoID sets the "repo_id" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsert) UpdateRepoID() *AgentSyncJobUpsert {
|
|
u.SetExcluded(agentsyncjob.FieldRepoID)
|
|
return u
|
|
}
|
|
|
|
// ClearRepoID clears the value of the "repo_id" field.
|
|
func (u *AgentSyncJobUpsert) ClearRepoID() *AgentSyncJobUpsert {
|
|
u.SetNull(agentsyncjob.FieldRepoID)
|
|
return u
|
|
}
|
|
|
|
// SetSourceType sets the "source_type" field.
|
|
func (u *AgentSyncJobUpsert) SetSourceType(v agentsyncjob.SourceType) *AgentSyncJobUpsert {
|
|
u.Set(agentsyncjob.FieldSourceType, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateSourceType sets the "source_type" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsert) UpdateSourceType() *AgentSyncJobUpsert {
|
|
u.SetExcluded(agentsyncjob.FieldSourceType)
|
|
return u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (u *AgentSyncJobUpsert) SetStatus(v agentsyncjob.Status) *AgentSyncJobUpsert {
|
|
u.Set(agentsyncjob.FieldStatus, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsert) UpdateStatus() *AgentSyncJobUpsert {
|
|
u.SetExcluded(agentsyncjob.FieldStatus)
|
|
return u
|
|
}
|
|
|
|
// SetTriggerType sets the "trigger_type" field.
|
|
func (u *AgentSyncJobUpsert) SetTriggerType(v agentsyncjob.TriggerType) *AgentSyncJobUpsert {
|
|
u.Set(agentsyncjob.FieldTriggerType, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateTriggerType sets the "trigger_type" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsert) UpdateTriggerType() *AgentSyncJobUpsert {
|
|
u.SetExcluded(agentsyncjob.FieldTriggerType)
|
|
return u
|
|
}
|
|
|
|
// SetTriggeredBy sets the "triggered_by" field.
|
|
func (u *AgentSyncJobUpsert) SetTriggeredBy(v uuid.UUID) *AgentSyncJobUpsert {
|
|
u.Set(agentsyncjob.FieldTriggeredBy, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateTriggeredBy sets the "triggered_by" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsert) UpdateTriggeredBy() *AgentSyncJobUpsert {
|
|
u.SetExcluded(agentsyncjob.FieldTriggeredBy)
|
|
return u
|
|
}
|
|
|
|
// ClearTriggeredBy clears the value of the "triggered_by" field.
|
|
func (u *AgentSyncJobUpsert) ClearTriggeredBy() *AgentSyncJobUpsert {
|
|
u.SetNull(agentsyncjob.FieldTriggeredBy)
|
|
return u
|
|
}
|
|
|
|
// SetStartedAt sets the "started_at" field.
|
|
func (u *AgentSyncJobUpsert) SetStartedAt(v time.Time) *AgentSyncJobUpsert {
|
|
u.Set(agentsyncjob.FieldStartedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateStartedAt sets the "started_at" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsert) UpdateStartedAt() *AgentSyncJobUpsert {
|
|
u.SetExcluded(agentsyncjob.FieldStartedAt)
|
|
return u
|
|
}
|
|
|
|
// ClearStartedAt clears the value of the "started_at" field.
|
|
func (u *AgentSyncJobUpsert) ClearStartedAt() *AgentSyncJobUpsert {
|
|
u.SetNull(agentsyncjob.FieldStartedAt)
|
|
return u
|
|
}
|
|
|
|
// SetFinishedAt sets the "finished_at" field.
|
|
func (u *AgentSyncJobUpsert) SetFinishedAt(v time.Time) *AgentSyncJobUpsert {
|
|
u.Set(agentsyncjob.FieldFinishedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateFinishedAt sets the "finished_at" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsert) UpdateFinishedAt() *AgentSyncJobUpsert {
|
|
u.SetExcluded(agentsyncjob.FieldFinishedAt)
|
|
return u
|
|
}
|
|
|
|
// ClearFinishedAt clears the value of the "finished_at" field.
|
|
func (u *AgentSyncJobUpsert) ClearFinishedAt() *AgentSyncJobUpsert {
|
|
u.SetNull(agentsyncjob.FieldFinishedAt)
|
|
return u
|
|
}
|
|
|
|
// SetErrors sets the "errors" field.
|
|
func (u *AgentSyncJobUpsert) SetErrors(v types.SyncJobErrors) *AgentSyncJobUpsert {
|
|
u.Set(agentsyncjob.FieldErrors, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateErrors sets the "errors" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsert) UpdateErrors() *AgentSyncJobUpsert {
|
|
u.SetExcluded(agentsyncjob.FieldErrors)
|
|
return u
|
|
}
|
|
|
|
// ClearErrors clears the value of the "errors" field.
|
|
func (u *AgentSyncJobUpsert) ClearErrors() *AgentSyncJobUpsert {
|
|
u.SetNull(agentsyncjob.FieldErrors)
|
|
return u
|
|
}
|
|
|
|
// SetResultSummary sets the "result_summary" field.
|
|
func (u *AgentSyncJobUpsert) SetResultSummary(v types.SyncJobResultSummary) *AgentSyncJobUpsert {
|
|
u.Set(agentsyncjob.FieldResultSummary, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateResultSummary sets the "result_summary" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsert) UpdateResultSummary() *AgentSyncJobUpsert {
|
|
u.SetExcluded(agentsyncjob.FieldResultSummary)
|
|
return u
|
|
}
|
|
|
|
// ClearResultSummary clears the value of the "result_summary" field.
|
|
func (u *AgentSyncJobUpsert) ClearResultSummary() *AgentSyncJobUpsert {
|
|
u.SetNull(agentsyncjob.FieldResultSummary)
|
|
return u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *AgentSyncJobUpsert) SetCreatedAt(v time.Time) *AgentSyncJobUpsert {
|
|
u.Set(agentsyncjob.FieldCreatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsert) UpdateCreatedAt() *AgentSyncJobUpsert {
|
|
u.SetExcluded(agentsyncjob.FieldCreatedAt)
|
|
return u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *AgentSyncJobUpsert) SetUpdatedAt(v time.Time) *AgentSyncJobUpsert {
|
|
u.Set(agentsyncjob.FieldUpdatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsert) UpdateUpdatedAt() *AgentSyncJobUpsert {
|
|
u.SetExcluded(agentsyncjob.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.AgentSyncJob.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(agentsyncjob.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *AgentSyncJobUpsertOne) UpdateNewValues() *AgentSyncJobUpsertOne {
|
|
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(agentsyncjob.FieldID)
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.AgentSyncJob.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *AgentSyncJobUpsertOne) Ignore() *AgentSyncJobUpsertOne {
|
|
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 *AgentSyncJobUpsertOne) DoNothing() *AgentSyncJobUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the AgentSyncJobCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *AgentSyncJobUpsertOne) Update(set func(*AgentSyncJobUpsert)) *AgentSyncJobUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&AgentSyncJobUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetResourceKind sets the "resource_kind" field.
|
|
func (u *AgentSyncJobUpsertOne) SetResourceKind(v agentsyncjob.ResourceKind) *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetResourceKind(v)
|
|
})
|
|
}
|
|
|
|
// UpdateResourceKind sets the "resource_kind" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertOne) UpdateResourceKind() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateResourceKind()
|
|
})
|
|
}
|
|
|
|
// SetRuleID sets the "rule_id" field.
|
|
func (u *AgentSyncJobUpsertOne) SetRuleID(v uuid.UUID) *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetRuleID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRuleID sets the "rule_id" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertOne) UpdateRuleID() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateRuleID()
|
|
})
|
|
}
|
|
|
|
// ClearRuleID clears the value of the "rule_id" field.
|
|
func (u *AgentSyncJobUpsertOne) ClearRuleID() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.ClearRuleID()
|
|
})
|
|
}
|
|
|
|
// SetRepoID sets the "repo_id" field.
|
|
func (u *AgentSyncJobUpsertOne) SetRepoID(v uuid.UUID) *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetRepoID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRepoID sets the "repo_id" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertOne) UpdateRepoID() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateRepoID()
|
|
})
|
|
}
|
|
|
|
// ClearRepoID clears the value of the "repo_id" field.
|
|
func (u *AgentSyncJobUpsertOne) ClearRepoID() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.ClearRepoID()
|
|
})
|
|
}
|
|
|
|
// SetSourceType sets the "source_type" field.
|
|
func (u *AgentSyncJobUpsertOne) SetSourceType(v agentsyncjob.SourceType) *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetSourceType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateSourceType sets the "source_type" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertOne) UpdateSourceType() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateSourceType()
|
|
})
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (u *AgentSyncJobUpsertOne) SetStatus(v agentsyncjob.Status) *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetStatus(v)
|
|
})
|
|
}
|
|
|
|
// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertOne) UpdateStatus() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateStatus()
|
|
})
|
|
}
|
|
|
|
// SetTriggerType sets the "trigger_type" field.
|
|
func (u *AgentSyncJobUpsertOne) SetTriggerType(v agentsyncjob.TriggerType) *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetTriggerType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTriggerType sets the "trigger_type" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertOne) UpdateTriggerType() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateTriggerType()
|
|
})
|
|
}
|
|
|
|
// SetTriggeredBy sets the "triggered_by" field.
|
|
func (u *AgentSyncJobUpsertOne) SetTriggeredBy(v uuid.UUID) *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetTriggeredBy(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTriggeredBy sets the "triggered_by" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertOne) UpdateTriggeredBy() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateTriggeredBy()
|
|
})
|
|
}
|
|
|
|
// ClearTriggeredBy clears the value of the "triggered_by" field.
|
|
func (u *AgentSyncJobUpsertOne) ClearTriggeredBy() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.ClearTriggeredBy()
|
|
})
|
|
}
|
|
|
|
// SetStartedAt sets the "started_at" field.
|
|
func (u *AgentSyncJobUpsertOne) SetStartedAt(v time.Time) *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetStartedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateStartedAt sets the "started_at" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertOne) UpdateStartedAt() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateStartedAt()
|
|
})
|
|
}
|
|
|
|
// ClearStartedAt clears the value of the "started_at" field.
|
|
func (u *AgentSyncJobUpsertOne) ClearStartedAt() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.ClearStartedAt()
|
|
})
|
|
}
|
|
|
|
// SetFinishedAt sets the "finished_at" field.
|
|
func (u *AgentSyncJobUpsertOne) SetFinishedAt(v time.Time) *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetFinishedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateFinishedAt sets the "finished_at" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertOne) UpdateFinishedAt() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateFinishedAt()
|
|
})
|
|
}
|
|
|
|
// ClearFinishedAt clears the value of the "finished_at" field.
|
|
func (u *AgentSyncJobUpsertOne) ClearFinishedAt() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.ClearFinishedAt()
|
|
})
|
|
}
|
|
|
|
// SetErrors sets the "errors" field.
|
|
func (u *AgentSyncJobUpsertOne) SetErrors(v types.SyncJobErrors) *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetErrors(v)
|
|
})
|
|
}
|
|
|
|
// UpdateErrors sets the "errors" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertOne) UpdateErrors() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateErrors()
|
|
})
|
|
}
|
|
|
|
// ClearErrors clears the value of the "errors" field.
|
|
func (u *AgentSyncJobUpsertOne) ClearErrors() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.ClearErrors()
|
|
})
|
|
}
|
|
|
|
// SetResultSummary sets the "result_summary" field.
|
|
func (u *AgentSyncJobUpsertOne) SetResultSummary(v types.SyncJobResultSummary) *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetResultSummary(v)
|
|
})
|
|
}
|
|
|
|
// UpdateResultSummary sets the "result_summary" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertOne) UpdateResultSummary() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateResultSummary()
|
|
})
|
|
}
|
|
|
|
// ClearResultSummary clears the value of the "result_summary" field.
|
|
func (u *AgentSyncJobUpsertOne) ClearResultSummary() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.ClearResultSummary()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *AgentSyncJobUpsertOne) SetCreatedAt(v time.Time) *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertOne) UpdateCreatedAt() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *AgentSyncJobUpsertOne) SetUpdatedAt(v time.Time) *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertOne) UpdateUpdatedAt() *AgentSyncJobUpsertOne {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *AgentSyncJobUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for AgentSyncJobCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *AgentSyncJobUpsertOne) 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 *AgentSyncJobUpsertOne) 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: AgentSyncJobUpsertOne.ID is not supported by MySQL driver. Use AgentSyncJobUpsertOne.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 *AgentSyncJobUpsertOne) IDX(ctx context.Context) uuid.UUID {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// AgentSyncJobCreateBulk is the builder for creating many AgentSyncJob entities in bulk.
|
|
type AgentSyncJobCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*AgentSyncJobCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the AgentSyncJob entities in the database.
|
|
func (_c *AgentSyncJobCreateBulk) Save(ctx context.Context) ([]*AgentSyncJob, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*AgentSyncJob, 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.(*AgentSyncJobMutation)
|
|
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 *AgentSyncJobCreateBulk) SaveX(ctx context.Context) []*AgentSyncJob {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *AgentSyncJobCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *AgentSyncJobCreateBulk) 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.AgentSyncJob.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.AgentSyncJobUpsert) {
|
|
// SetResourceKind(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *AgentSyncJobCreateBulk) OnConflict(opts ...sql.ConflictOption) *AgentSyncJobUpsertBulk {
|
|
_c.conflict = opts
|
|
return &AgentSyncJobUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.AgentSyncJob.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *AgentSyncJobCreateBulk) OnConflictColumns(columns ...string) *AgentSyncJobUpsertBulk {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &AgentSyncJobUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// AgentSyncJobUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of AgentSyncJob nodes.
|
|
type AgentSyncJobUpsertBulk struct {
|
|
create *AgentSyncJobCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.AgentSyncJob.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(agentsyncjob.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *AgentSyncJobUpsertBulk) UpdateNewValues() *AgentSyncJobUpsertBulk {
|
|
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(agentsyncjob.FieldID)
|
|
}
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.AgentSyncJob.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *AgentSyncJobUpsertBulk) Ignore() *AgentSyncJobUpsertBulk {
|
|
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 *AgentSyncJobUpsertBulk) DoNothing() *AgentSyncJobUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the AgentSyncJobCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *AgentSyncJobUpsertBulk) Update(set func(*AgentSyncJobUpsert)) *AgentSyncJobUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&AgentSyncJobUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetResourceKind sets the "resource_kind" field.
|
|
func (u *AgentSyncJobUpsertBulk) SetResourceKind(v agentsyncjob.ResourceKind) *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetResourceKind(v)
|
|
})
|
|
}
|
|
|
|
// UpdateResourceKind sets the "resource_kind" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertBulk) UpdateResourceKind() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateResourceKind()
|
|
})
|
|
}
|
|
|
|
// SetRuleID sets the "rule_id" field.
|
|
func (u *AgentSyncJobUpsertBulk) SetRuleID(v uuid.UUID) *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetRuleID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRuleID sets the "rule_id" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertBulk) UpdateRuleID() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateRuleID()
|
|
})
|
|
}
|
|
|
|
// ClearRuleID clears the value of the "rule_id" field.
|
|
func (u *AgentSyncJobUpsertBulk) ClearRuleID() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.ClearRuleID()
|
|
})
|
|
}
|
|
|
|
// SetRepoID sets the "repo_id" field.
|
|
func (u *AgentSyncJobUpsertBulk) SetRepoID(v uuid.UUID) *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetRepoID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRepoID sets the "repo_id" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertBulk) UpdateRepoID() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateRepoID()
|
|
})
|
|
}
|
|
|
|
// ClearRepoID clears the value of the "repo_id" field.
|
|
func (u *AgentSyncJobUpsertBulk) ClearRepoID() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.ClearRepoID()
|
|
})
|
|
}
|
|
|
|
// SetSourceType sets the "source_type" field.
|
|
func (u *AgentSyncJobUpsertBulk) SetSourceType(v agentsyncjob.SourceType) *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetSourceType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateSourceType sets the "source_type" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertBulk) UpdateSourceType() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateSourceType()
|
|
})
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (u *AgentSyncJobUpsertBulk) SetStatus(v agentsyncjob.Status) *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetStatus(v)
|
|
})
|
|
}
|
|
|
|
// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertBulk) UpdateStatus() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateStatus()
|
|
})
|
|
}
|
|
|
|
// SetTriggerType sets the "trigger_type" field.
|
|
func (u *AgentSyncJobUpsertBulk) SetTriggerType(v agentsyncjob.TriggerType) *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetTriggerType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTriggerType sets the "trigger_type" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertBulk) UpdateTriggerType() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateTriggerType()
|
|
})
|
|
}
|
|
|
|
// SetTriggeredBy sets the "triggered_by" field.
|
|
func (u *AgentSyncJobUpsertBulk) SetTriggeredBy(v uuid.UUID) *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetTriggeredBy(v)
|
|
})
|
|
}
|
|
|
|
// UpdateTriggeredBy sets the "triggered_by" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertBulk) UpdateTriggeredBy() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateTriggeredBy()
|
|
})
|
|
}
|
|
|
|
// ClearTriggeredBy clears the value of the "triggered_by" field.
|
|
func (u *AgentSyncJobUpsertBulk) ClearTriggeredBy() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.ClearTriggeredBy()
|
|
})
|
|
}
|
|
|
|
// SetStartedAt sets the "started_at" field.
|
|
func (u *AgentSyncJobUpsertBulk) SetStartedAt(v time.Time) *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetStartedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateStartedAt sets the "started_at" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertBulk) UpdateStartedAt() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateStartedAt()
|
|
})
|
|
}
|
|
|
|
// ClearStartedAt clears the value of the "started_at" field.
|
|
func (u *AgentSyncJobUpsertBulk) ClearStartedAt() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.ClearStartedAt()
|
|
})
|
|
}
|
|
|
|
// SetFinishedAt sets the "finished_at" field.
|
|
func (u *AgentSyncJobUpsertBulk) SetFinishedAt(v time.Time) *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetFinishedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateFinishedAt sets the "finished_at" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertBulk) UpdateFinishedAt() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateFinishedAt()
|
|
})
|
|
}
|
|
|
|
// ClearFinishedAt clears the value of the "finished_at" field.
|
|
func (u *AgentSyncJobUpsertBulk) ClearFinishedAt() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.ClearFinishedAt()
|
|
})
|
|
}
|
|
|
|
// SetErrors sets the "errors" field.
|
|
func (u *AgentSyncJobUpsertBulk) SetErrors(v types.SyncJobErrors) *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetErrors(v)
|
|
})
|
|
}
|
|
|
|
// UpdateErrors sets the "errors" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertBulk) UpdateErrors() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateErrors()
|
|
})
|
|
}
|
|
|
|
// ClearErrors clears the value of the "errors" field.
|
|
func (u *AgentSyncJobUpsertBulk) ClearErrors() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.ClearErrors()
|
|
})
|
|
}
|
|
|
|
// SetResultSummary sets the "result_summary" field.
|
|
func (u *AgentSyncJobUpsertBulk) SetResultSummary(v types.SyncJobResultSummary) *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetResultSummary(v)
|
|
})
|
|
}
|
|
|
|
// UpdateResultSummary sets the "result_summary" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertBulk) UpdateResultSummary() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateResultSummary()
|
|
})
|
|
}
|
|
|
|
// ClearResultSummary clears the value of the "result_summary" field.
|
|
func (u *AgentSyncJobUpsertBulk) ClearResultSummary() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.ClearResultSummary()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *AgentSyncJobUpsertBulk) SetCreatedAt(v time.Time) *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertBulk) UpdateCreatedAt() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *AgentSyncJobUpsertBulk) SetUpdatedAt(v time.Time) *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *AgentSyncJobUpsertBulk) UpdateUpdatedAt() *AgentSyncJobUpsertBulk {
|
|
return u.Update(func(s *AgentSyncJobUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *AgentSyncJobUpsertBulk) 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 AgentSyncJobCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for AgentSyncJobCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *AgentSyncJobUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|