// Code generated by ent, DO NOT EDIT.

package ent

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/AvengeMedia/dankcalendar/core/ent/account"
	"github.com/AvengeMedia/dankcalendar/core/ent/calendar"
	"github.com/AvengeMedia/dankcalendar/core/ent/event"
	"github.com/AvengeMedia/dankcalendar/core/ent/task"
	"github.com/AvengeMedia/dankcalendar/core/internal/settings"
)

// CalendarCreate is the builder for creating a Calendar entity.
type CalendarCreate struct {
	config
	mutation *CalendarMutation
	hooks    []Hook
	conflict []sql.ConflictOption
}

// SetRemoteID sets the "remote_id" field.
func (_c *CalendarCreate) SetRemoteID(v string) *CalendarCreate {
	_c.mutation.SetRemoteID(v)
	return _c
}

// SetName sets the "name" field.
func (_c *CalendarCreate) SetName(v string) *CalendarCreate {
	_c.mutation.SetName(v)
	return _c
}

// SetNameOverride sets the "name_override" field.
func (_c *CalendarCreate) SetNameOverride(v string) *CalendarCreate {
	_c.mutation.SetNameOverride(v)
	return _c
}

// SetNillableNameOverride sets the "name_override" field if the given value is not nil.
func (_c *CalendarCreate) SetNillableNameOverride(v *string) *CalendarCreate {
	if v != nil {
		_c.SetNameOverride(*v)
	}
	return _c
}

// SetDescription sets the "description" field.
func (_c *CalendarCreate) SetDescription(v string) *CalendarCreate {
	_c.mutation.SetDescription(v)
	return _c
}

// SetNillableDescription sets the "description" field if the given value is not nil.
func (_c *CalendarCreate) SetNillableDescription(v *string) *CalendarCreate {
	if v != nil {
		_c.SetDescription(*v)
	}
	return _c
}

// SetColor sets the "color" field.
func (_c *CalendarCreate) SetColor(v string) *CalendarCreate {
	_c.mutation.SetColor(v)
	return _c
}

// SetNillableColor sets the "color" field if the given value is not nil.
func (_c *CalendarCreate) SetNillableColor(v *string) *CalendarCreate {
	if v != nil {
		_c.SetColor(*v)
	}
	return _c
}

// SetTimeZone sets the "time_zone" field.
func (_c *CalendarCreate) SetTimeZone(v string) *CalendarCreate {
	_c.mutation.SetTimeZone(v)
	return _c
}

// SetNillableTimeZone sets the "time_zone" field if the given value is not nil.
func (_c *CalendarCreate) SetNillableTimeZone(v *string) *CalendarCreate {
	if v != nil {
		_c.SetTimeZone(*v)
	}
	return _c
}

// SetReadOnly sets the "read_only" field.
func (_c *CalendarCreate) SetReadOnly(v bool) *CalendarCreate {
	_c.mutation.SetReadOnly(v)
	return _c
}

// SetNillableReadOnly sets the "read_only" field if the given value is not nil.
func (_c *CalendarCreate) SetNillableReadOnly(v *bool) *CalendarCreate {
	if v != nil {
		_c.SetReadOnly(*v)
	}
	return _c
}

// SetHidden sets the "hidden" field.
func (_c *CalendarCreate) SetHidden(v bool) *CalendarCreate {
	_c.mutation.SetHidden(v)
	return _c
}

// SetNillableHidden sets the "hidden" field if the given value is not nil.
func (_c *CalendarCreate) SetNillableHidden(v *bool) *CalendarCreate {
	if v != nil {
		_c.SetHidden(*v)
	}
	return _c
}

// SetSyncDisabled sets the "sync_disabled" field.
func (_c *CalendarCreate) SetSyncDisabled(v bool) *CalendarCreate {
	_c.mutation.SetSyncDisabled(v)
	return _c
}

// SetNillableSyncDisabled sets the "sync_disabled" field if the given value is not nil.
func (_c *CalendarCreate) SetNillableSyncDisabled(v *bool) *CalendarCreate {
	if v != nil {
		_c.SetSyncDisabled(*v)
	}
	return _c
}

// SetReminderOverrides sets the "reminder_overrides" field.
func (_c *CalendarCreate) SetReminderOverrides(v *settings.ReminderOverride) *CalendarCreate {
	_c.mutation.SetReminderOverrides(v)
	return _c
}

// SetSyncToken sets the "sync_token" field.
func (_c *CalendarCreate) SetSyncToken(v string) *CalendarCreate {
	_c.mutation.SetSyncToken(v)
	return _c
}

// SetNillableSyncToken sets the "sync_token" field if the given value is not nil.
func (_c *CalendarCreate) SetNillableSyncToken(v *string) *CalendarCreate {
	if v != nil {
		_c.SetSyncToken(*v)
	}
	return _c
}

// SetSupportedComponents sets the "supported_components" field.
func (_c *CalendarCreate) SetSupportedComponents(v []string) *CalendarCreate {
	_c.mutation.SetSupportedComponents(v)
	return _c
}

// SetCreatedAt sets the "created_at" field.
func (_c *CalendarCreate) SetCreatedAt(v time.Time) *CalendarCreate {
	_c.mutation.SetCreatedAt(v)
	return _c
}

// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *CalendarCreate) SetNillableCreatedAt(v *time.Time) *CalendarCreate {
	if v != nil {
		_c.SetCreatedAt(*v)
	}
	return _c
}

// SetUpdatedAt sets the "updated_at" field.
func (_c *CalendarCreate) SetUpdatedAt(v time.Time) *CalendarCreate {
	_c.mutation.SetUpdatedAt(v)
	return _c
}

// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (_c *CalendarCreate) SetNillableUpdatedAt(v *time.Time) *CalendarCreate {
	if v != nil {
		_c.SetUpdatedAt(*v)
	}
	return _c
}

// SetID sets the "id" field.
func (_c *CalendarCreate) SetID(v string) *CalendarCreate {
	_c.mutation.SetID(v)
	return _c
}

// SetAccountID sets the "account" edge to the Account entity by ID.
func (_c *CalendarCreate) SetAccountID(id string) *CalendarCreate {
	_c.mutation.SetAccountID(id)
	return _c
}

// SetAccount sets the "account" edge to the Account entity.
func (_c *CalendarCreate) SetAccount(v *Account) *CalendarCreate {
	return _c.SetAccountID(v.ID)
}

// AddEventIDs adds the "events" edge to the Event entity by IDs.
func (_c *CalendarCreate) AddEventIDs(ids ...string) *CalendarCreate {
	_c.mutation.AddEventIDs(ids...)
	return _c
}

// AddEvents adds the "events" edges to the Event entity.
func (_c *CalendarCreate) AddEvents(v ...*Event) *CalendarCreate {
	ids := make([]string, len(v))
	for i := range v {
		ids[i] = v[i].ID
	}
	return _c.AddEventIDs(ids...)
}

// AddTaskIDs adds the "tasks" edge to the Task entity by IDs.
func (_c *CalendarCreate) AddTaskIDs(ids ...string) *CalendarCreate {
	_c.mutation.AddTaskIDs(ids...)
	return _c
}

// AddTasks adds the "tasks" edges to the Task entity.
func (_c *CalendarCreate) AddTasks(v ...*Task) *CalendarCreate {
	ids := make([]string, len(v))
	for i := range v {
		ids[i] = v[i].ID
	}
	return _c.AddTaskIDs(ids...)
}

// Mutation returns the CalendarMutation object of the builder.
func (_c *CalendarCreate) Mutation() *CalendarMutation {
	return _c.mutation
}

// Save creates the Calendar in the database.
func (_c *CalendarCreate) Save(ctx context.Context) (*Calendar, error) {
	_c.defaults()
	return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}

// SaveX calls Save and panics if Save returns an error.
func (_c *CalendarCreate) SaveX(ctx context.Context) *Calendar {
	v, err := _c.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

// Exec executes the query.
func (_c *CalendarCreate) Exec(ctx context.Context) error {
	_, err := _c.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (_c *CalendarCreate) 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 *CalendarCreate) defaults() {
	if _, ok := _c.mutation.ReadOnly(); !ok {
		v := calendar.DefaultReadOnly
		_c.mutation.SetReadOnly(v)
	}
	if _, ok := _c.mutation.Hidden(); !ok {
		v := calendar.DefaultHidden
		_c.mutation.SetHidden(v)
	}
	if _, ok := _c.mutation.SyncDisabled(); !ok {
		v := calendar.DefaultSyncDisabled
		_c.mutation.SetSyncDisabled(v)
	}
	if _, ok := _c.mutation.CreatedAt(); !ok {
		v := calendar.DefaultCreatedAt()
		_c.mutation.SetCreatedAt(v)
	}
	if _, ok := _c.mutation.UpdatedAt(); !ok {
		v := calendar.DefaultUpdatedAt()
		_c.mutation.SetUpdatedAt(v)
	}
}

// check runs all checks and user-defined validators on the builder.
func (_c *CalendarCreate) check() error {
	if _, ok := _c.mutation.RemoteID(); !ok {
		return &ValidationError{Name: "remote_id", err: errors.New(`ent: missing required field "Calendar.remote_id"`)}
	}
	if v, ok := _c.mutation.RemoteID(); ok {
		if err := calendar.RemoteIDValidator(v); err != nil {
			return &ValidationError{Name: "remote_id", err: fmt.Errorf(`ent: validator failed for field "Calendar.remote_id": %w`, err)}
		}
	}
	if _, ok := _c.mutation.Name(); !ok {
		return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Calendar.name"`)}
	}
	if v, ok := _c.mutation.Name(); ok {
		if err := calendar.NameValidator(v); err != nil {
			return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Calendar.name": %w`, err)}
		}
	}
	if _, ok := _c.mutation.ReadOnly(); !ok {
		return &ValidationError{Name: "read_only", err: errors.New(`ent: missing required field "Calendar.read_only"`)}
	}
	if _, ok := _c.mutation.Hidden(); !ok {
		return &ValidationError{Name: "hidden", err: errors.New(`ent: missing required field "Calendar.hidden"`)}
	}
	if _, ok := _c.mutation.SyncDisabled(); !ok {
		return &ValidationError{Name: "sync_disabled", err: errors.New(`ent: missing required field "Calendar.sync_disabled"`)}
	}
	if _, ok := _c.mutation.CreatedAt(); !ok {
		return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Calendar.created_at"`)}
	}
	if _, ok := _c.mutation.UpdatedAt(); !ok {
		return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Calendar.updated_at"`)}
	}
	if v, ok := _c.mutation.ID(); ok {
		if err := calendar.IDValidator(v); err != nil {
			return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "Calendar.id": %w`, err)}
		}
	}
	if len(_c.mutation.AccountIDs()) == 0 {
		return &ValidationError{Name: "account", err: errors.New(`ent: missing required edge "Calendar.account"`)}
	}
	return nil
}

func (_c *CalendarCreate) sqlSave(ctx context.Context) (*Calendar, 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.(string); ok {
			_node.ID = id
		} else {
			return nil, fmt.Errorf("unexpected Calendar.ID type: %T", _spec.ID.Value)
		}
	}
	_c.mutation.id = &_node.ID
	_c.mutation.done = true
	return _node, nil
}

func (_c *CalendarCreate) createSpec() (*Calendar, *sqlgraph.CreateSpec) {
	var (
		_node = &Calendar{config: _c.config}
		_spec = sqlgraph.NewCreateSpec(calendar.Table, sqlgraph.NewFieldSpec(calendar.FieldID, field.TypeString))
	)
	_spec.OnConflict = _c.conflict
	if id, ok := _c.mutation.ID(); ok {
		_node.ID = id
		_spec.ID.Value = id
	}
	if value, ok := _c.mutation.RemoteID(); ok {
		_spec.SetField(calendar.FieldRemoteID, field.TypeString, value)
		_node.RemoteID = value
	}
	if value, ok := _c.mutation.Name(); ok {
		_spec.SetField(calendar.FieldName, field.TypeString, value)
		_node.Name = value
	}
	if value, ok := _c.mutation.NameOverride(); ok {
		_spec.SetField(calendar.FieldNameOverride, field.TypeString, value)
		_node.NameOverride = value
	}
	if value, ok := _c.mutation.Description(); ok {
		_spec.SetField(calendar.FieldDescription, field.TypeString, value)
		_node.Description = value
	}
	if value, ok := _c.mutation.Color(); ok {
		_spec.SetField(calendar.FieldColor, field.TypeString, value)
		_node.Color = value
	}
	if value, ok := _c.mutation.TimeZone(); ok {
		_spec.SetField(calendar.FieldTimeZone, field.TypeString, value)
		_node.TimeZone = value
	}
	if value, ok := _c.mutation.ReadOnly(); ok {
		_spec.SetField(calendar.FieldReadOnly, field.TypeBool, value)
		_node.ReadOnly = value
	}
	if value, ok := _c.mutation.Hidden(); ok {
		_spec.SetField(calendar.FieldHidden, field.TypeBool, value)
		_node.Hidden = value
	}
	if value, ok := _c.mutation.SyncDisabled(); ok {
		_spec.SetField(calendar.FieldSyncDisabled, field.TypeBool, value)
		_node.SyncDisabled = value
	}
	if value, ok := _c.mutation.ReminderOverrides(); ok {
		_spec.SetField(calendar.FieldReminderOverrides, field.TypeJSON, value)
		_node.ReminderOverrides = value
	}
	if value, ok := _c.mutation.SyncToken(); ok {
		_spec.SetField(calendar.FieldSyncToken, field.TypeString, value)
		_node.SyncToken = value
	}
	if value, ok := _c.mutation.SupportedComponents(); ok {
		_spec.SetField(calendar.FieldSupportedComponents, field.TypeJSON, value)
		_node.SupportedComponents = value
	}
	if value, ok := _c.mutation.CreatedAt(); ok {
		_spec.SetField(calendar.FieldCreatedAt, field.TypeTime, value)
		_node.CreatedAt = value
	}
	if value, ok := _c.mutation.UpdatedAt(); ok {
		_spec.SetField(calendar.FieldUpdatedAt, field.TypeTime, value)
		_node.UpdatedAt = value
	}
	if nodes := _c.mutation.AccountIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   calendar.AccountTable,
			Columns: []string{calendar.AccountColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_node.account_calendars = &nodes[0]
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := _c.mutation.EventsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   calendar.EventsTable,
			Columns: []string{calendar.EventsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(event.FieldID, field.TypeString),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := _c.mutation.TasksIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   calendar.TasksTable,
			Columns: []string{calendar.TasksColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeString),
			},
		}
		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.Calendar.Create().
//		SetRemoteID(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.CalendarUpsert) {
//			SetRemoteID(v+v).
//		}).
//		Exec(ctx)
func (_c *CalendarCreate) OnConflict(opts ...sql.ConflictOption) *CalendarUpsertOne {
	_c.conflict = opts
	return &CalendarUpsertOne{
		create: _c,
	}
}

// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
//	client.Calendar.Create().
//		OnConflict(sql.ConflictColumns(columns...)).
//		Exec(ctx)
func (_c *CalendarCreate) OnConflictColumns(columns ...string) *CalendarUpsertOne {
	_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
	return &CalendarUpsertOne{
		create: _c,
	}
}

type (
	// CalendarUpsertOne is the builder for "upsert"-ing
	//  one Calendar node.
	CalendarUpsertOne struct {
		create *CalendarCreate
	}

	// CalendarUpsert is the "OnConflict" setter.
	CalendarUpsert struct {
		*sql.UpdateSet
	}
)

// SetRemoteID sets the "remote_id" field.
func (u *CalendarUpsert) SetRemoteID(v string) *CalendarUpsert {
	u.Set(calendar.FieldRemoteID, v)
	return u
}

// UpdateRemoteID sets the "remote_id" field to the value that was provided on create.
func (u *CalendarUpsert) UpdateRemoteID() *CalendarUpsert {
	u.SetExcluded(calendar.FieldRemoteID)
	return u
}

// SetName sets the "name" field.
func (u *CalendarUpsert) SetName(v string) *CalendarUpsert {
	u.Set(calendar.FieldName, v)
	return u
}

// UpdateName sets the "name" field to the value that was provided on create.
func (u *CalendarUpsert) UpdateName() *CalendarUpsert {
	u.SetExcluded(calendar.FieldName)
	return u
}

// SetNameOverride sets the "name_override" field.
func (u *CalendarUpsert) SetNameOverride(v string) *CalendarUpsert {
	u.Set(calendar.FieldNameOverride, v)
	return u
}

// UpdateNameOverride sets the "name_override" field to the value that was provided on create.
func (u *CalendarUpsert) UpdateNameOverride() *CalendarUpsert {
	u.SetExcluded(calendar.FieldNameOverride)
	return u
}

// ClearNameOverride clears the value of the "name_override" field.
func (u *CalendarUpsert) ClearNameOverride() *CalendarUpsert {
	u.SetNull(calendar.FieldNameOverride)
	return u
}

// SetDescription sets the "description" field.
func (u *CalendarUpsert) SetDescription(v string) *CalendarUpsert {
	u.Set(calendar.FieldDescription, v)
	return u
}

// UpdateDescription sets the "description" field to the value that was provided on create.
func (u *CalendarUpsert) UpdateDescription() *CalendarUpsert {
	u.SetExcluded(calendar.FieldDescription)
	return u
}

// ClearDescription clears the value of the "description" field.
func (u *CalendarUpsert) ClearDescription() *CalendarUpsert {
	u.SetNull(calendar.FieldDescription)
	return u
}

// SetColor sets the "color" field.
func (u *CalendarUpsert) SetColor(v string) *CalendarUpsert {
	u.Set(calendar.FieldColor, v)
	return u
}

// UpdateColor sets the "color" field to the value that was provided on create.
func (u *CalendarUpsert) UpdateColor() *CalendarUpsert {
	u.SetExcluded(calendar.FieldColor)
	return u
}

// ClearColor clears the value of the "color" field.
func (u *CalendarUpsert) ClearColor() *CalendarUpsert {
	u.SetNull(calendar.FieldColor)
	return u
}

// SetTimeZone sets the "time_zone" field.
func (u *CalendarUpsert) SetTimeZone(v string) *CalendarUpsert {
	u.Set(calendar.FieldTimeZone, v)
	return u
}

// UpdateTimeZone sets the "time_zone" field to the value that was provided on create.
func (u *CalendarUpsert) UpdateTimeZone() *CalendarUpsert {
	u.SetExcluded(calendar.FieldTimeZone)
	return u
}

// ClearTimeZone clears the value of the "time_zone" field.
func (u *CalendarUpsert) ClearTimeZone() *CalendarUpsert {
	u.SetNull(calendar.FieldTimeZone)
	return u
}

// SetReadOnly sets the "read_only" field.
func (u *CalendarUpsert) SetReadOnly(v bool) *CalendarUpsert {
	u.Set(calendar.FieldReadOnly, v)
	return u
}

// UpdateReadOnly sets the "read_only" field to the value that was provided on create.
func (u *CalendarUpsert) UpdateReadOnly() *CalendarUpsert {
	u.SetExcluded(calendar.FieldReadOnly)
	return u
}

// SetHidden sets the "hidden" field.
func (u *CalendarUpsert) SetHidden(v bool) *CalendarUpsert {
	u.Set(calendar.FieldHidden, v)
	return u
}

// UpdateHidden sets the "hidden" field to the value that was provided on create.
func (u *CalendarUpsert) UpdateHidden() *CalendarUpsert {
	u.SetExcluded(calendar.FieldHidden)
	return u
}

// SetSyncDisabled sets the "sync_disabled" field.
func (u *CalendarUpsert) SetSyncDisabled(v bool) *CalendarUpsert {
	u.Set(calendar.FieldSyncDisabled, v)
	return u
}

// UpdateSyncDisabled sets the "sync_disabled" field to the value that was provided on create.
func (u *CalendarUpsert) UpdateSyncDisabled() *CalendarUpsert {
	u.SetExcluded(calendar.FieldSyncDisabled)
	return u
}

// SetReminderOverrides sets the "reminder_overrides" field.
func (u *CalendarUpsert) SetReminderOverrides(v *settings.ReminderOverride) *CalendarUpsert {
	u.Set(calendar.FieldReminderOverrides, v)
	return u
}

// UpdateReminderOverrides sets the "reminder_overrides" field to the value that was provided on create.
func (u *CalendarUpsert) UpdateReminderOverrides() *CalendarUpsert {
	u.SetExcluded(calendar.FieldReminderOverrides)
	return u
}

// ClearReminderOverrides clears the value of the "reminder_overrides" field.
func (u *CalendarUpsert) ClearReminderOverrides() *CalendarUpsert {
	u.SetNull(calendar.FieldReminderOverrides)
	return u
}

// SetSyncToken sets the "sync_token" field.
func (u *CalendarUpsert) SetSyncToken(v string) *CalendarUpsert {
	u.Set(calendar.FieldSyncToken, v)
	return u
}

// UpdateSyncToken sets the "sync_token" field to the value that was provided on create.
func (u *CalendarUpsert) UpdateSyncToken() *CalendarUpsert {
	u.SetExcluded(calendar.FieldSyncToken)
	return u
}

// ClearSyncToken clears the value of the "sync_token" field.
func (u *CalendarUpsert) ClearSyncToken() *CalendarUpsert {
	u.SetNull(calendar.FieldSyncToken)
	return u
}

// SetSupportedComponents sets the "supported_components" field.
func (u *CalendarUpsert) SetSupportedComponents(v []string) *CalendarUpsert {
	u.Set(calendar.FieldSupportedComponents, v)
	return u
}

// UpdateSupportedComponents sets the "supported_components" field to the value that was provided on create.
func (u *CalendarUpsert) UpdateSupportedComponents() *CalendarUpsert {
	u.SetExcluded(calendar.FieldSupportedComponents)
	return u
}

// ClearSupportedComponents clears the value of the "supported_components" field.
func (u *CalendarUpsert) ClearSupportedComponents() *CalendarUpsert {
	u.SetNull(calendar.FieldSupportedComponents)
	return u
}

// SetUpdatedAt sets the "updated_at" field.
func (u *CalendarUpsert) SetUpdatedAt(v time.Time) *CalendarUpsert {
	u.Set(calendar.FieldUpdatedAt, v)
	return u
}

// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *CalendarUpsert) UpdateUpdatedAt() *CalendarUpsert {
	u.SetExcluded(calendar.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.Calendar.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(calendar.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *CalendarUpsertOne) UpdateNewValues() *CalendarUpsertOne {
	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(calendar.FieldID)
		}
		if _, exists := u.create.mutation.CreatedAt(); exists {
			s.SetIgnore(calendar.FieldCreatedAt)
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.Calendar.Create().
//	    OnConflict(sql.ResolveWithIgnore()).
//	    Exec(ctx)
func (u *CalendarUpsertOne) Ignore() *CalendarUpsertOne {
	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 *CalendarUpsertOne) DoNothing() *CalendarUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

// Update allows overriding fields `UPDATE` values. See the CalendarCreate.OnConflict
// documentation for more info.
func (u *CalendarUpsertOne) Update(set func(*CalendarUpsert)) *CalendarUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
		set(&CalendarUpsert{UpdateSet: update})
	}))
	return u
}

// SetRemoteID sets the "remote_id" field.
func (u *CalendarUpsertOne) SetRemoteID(v string) *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.SetRemoteID(v)
	})
}

// UpdateRemoteID sets the "remote_id" field to the value that was provided on create.
func (u *CalendarUpsertOne) UpdateRemoteID() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateRemoteID()
	})
}

// SetName sets the "name" field.
func (u *CalendarUpsertOne) SetName(v string) *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.SetName(v)
	})
}

// UpdateName sets the "name" field to the value that was provided on create.
func (u *CalendarUpsertOne) UpdateName() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateName()
	})
}

// SetNameOverride sets the "name_override" field.
func (u *CalendarUpsertOne) SetNameOverride(v string) *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.SetNameOverride(v)
	})
}

// UpdateNameOverride sets the "name_override" field to the value that was provided on create.
func (u *CalendarUpsertOne) UpdateNameOverride() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateNameOverride()
	})
}

// ClearNameOverride clears the value of the "name_override" field.
func (u *CalendarUpsertOne) ClearNameOverride() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.ClearNameOverride()
	})
}

// SetDescription sets the "description" field.
func (u *CalendarUpsertOne) SetDescription(v string) *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.SetDescription(v)
	})
}

// UpdateDescription sets the "description" field to the value that was provided on create.
func (u *CalendarUpsertOne) UpdateDescription() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateDescription()
	})
}

// ClearDescription clears the value of the "description" field.
func (u *CalendarUpsertOne) ClearDescription() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.ClearDescription()
	})
}

// SetColor sets the "color" field.
func (u *CalendarUpsertOne) SetColor(v string) *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.SetColor(v)
	})
}

// UpdateColor sets the "color" field to the value that was provided on create.
func (u *CalendarUpsertOne) UpdateColor() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateColor()
	})
}

// ClearColor clears the value of the "color" field.
func (u *CalendarUpsertOne) ClearColor() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.ClearColor()
	})
}

// SetTimeZone sets the "time_zone" field.
func (u *CalendarUpsertOne) SetTimeZone(v string) *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.SetTimeZone(v)
	})
}

// UpdateTimeZone sets the "time_zone" field to the value that was provided on create.
func (u *CalendarUpsertOne) UpdateTimeZone() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateTimeZone()
	})
}

// ClearTimeZone clears the value of the "time_zone" field.
func (u *CalendarUpsertOne) ClearTimeZone() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.ClearTimeZone()
	})
}

// SetReadOnly sets the "read_only" field.
func (u *CalendarUpsertOne) SetReadOnly(v bool) *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.SetReadOnly(v)
	})
}

// UpdateReadOnly sets the "read_only" field to the value that was provided on create.
func (u *CalendarUpsertOne) UpdateReadOnly() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateReadOnly()
	})
}

// SetHidden sets the "hidden" field.
func (u *CalendarUpsertOne) SetHidden(v bool) *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.SetHidden(v)
	})
}

// UpdateHidden sets the "hidden" field to the value that was provided on create.
func (u *CalendarUpsertOne) UpdateHidden() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateHidden()
	})
}

// SetSyncDisabled sets the "sync_disabled" field.
func (u *CalendarUpsertOne) SetSyncDisabled(v bool) *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.SetSyncDisabled(v)
	})
}

// UpdateSyncDisabled sets the "sync_disabled" field to the value that was provided on create.
func (u *CalendarUpsertOne) UpdateSyncDisabled() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateSyncDisabled()
	})
}

// SetReminderOverrides sets the "reminder_overrides" field.
func (u *CalendarUpsertOne) SetReminderOverrides(v *settings.ReminderOverride) *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.SetReminderOverrides(v)
	})
}

// UpdateReminderOverrides sets the "reminder_overrides" field to the value that was provided on create.
func (u *CalendarUpsertOne) UpdateReminderOverrides() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateReminderOverrides()
	})
}

// ClearReminderOverrides clears the value of the "reminder_overrides" field.
func (u *CalendarUpsertOne) ClearReminderOverrides() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.ClearReminderOverrides()
	})
}

// SetSyncToken sets the "sync_token" field.
func (u *CalendarUpsertOne) SetSyncToken(v string) *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.SetSyncToken(v)
	})
}

// UpdateSyncToken sets the "sync_token" field to the value that was provided on create.
func (u *CalendarUpsertOne) UpdateSyncToken() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateSyncToken()
	})
}

// ClearSyncToken clears the value of the "sync_token" field.
func (u *CalendarUpsertOne) ClearSyncToken() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.ClearSyncToken()
	})
}

// SetSupportedComponents sets the "supported_components" field.
func (u *CalendarUpsertOne) SetSupportedComponents(v []string) *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.SetSupportedComponents(v)
	})
}

// UpdateSupportedComponents sets the "supported_components" field to the value that was provided on create.
func (u *CalendarUpsertOne) UpdateSupportedComponents() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateSupportedComponents()
	})
}

// ClearSupportedComponents clears the value of the "supported_components" field.
func (u *CalendarUpsertOne) ClearSupportedComponents() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.ClearSupportedComponents()
	})
}

// SetUpdatedAt sets the "updated_at" field.
func (u *CalendarUpsertOne) SetUpdatedAt(v time.Time) *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.SetUpdatedAt(v)
	})
}

// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *CalendarUpsertOne) UpdateUpdatedAt() *CalendarUpsertOne {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateUpdatedAt()
	})
}

// Exec executes the query.
func (u *CalendarUpsertOne) Exec(ctx context.Context) error {
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for CalendarCreate.OnConflict")
	}
	return u.create.Exec(ctx)
}

// ExecX is like Exec, but panics if an error occurs.
func (u *CalendarUpsertOne) 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 *CalendarUpsertOne) ID(ctx context.Context) (id string, 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("ent: CalendarUpsertOne.ID is not supported by MySQL driver. Use CalendarUpsertOne.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 *CalendarUpsertOne) IDX(ctx context.Context) string {
	id, err := u.ID(ctx)
	if err != nil {
		panic(err)
	}
	return id
}

// CalendarCreateBulk is the builder for creating many Calendar entities in bulk.
type CalendarCreateBulk struct {
	config
	err      error
	builders []*CalendarCreate
	conflict []sql.ConflictOption
}

// Save creates the Calendar entities in the database.
func (_c *CalendarCreateBulk) Save(ctx context.Context) ([]*Calendar, error) {
	if _c.err != nil {
		return nil, _c.err
	}
	specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
	nodes := make([]*Calendar, 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.(*CalendarMutation)
				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 *CalendarCreateBulk) SaveX(ctx context.Context) []*Calendar {
	v, err := _c.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

// Exec executes the query.
func (_c *CalendarCreateBulk) Exec(ctx context.Context) error {
	_, err := _c.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (_c *CalendarCreateBulk) 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.Calendar.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.CalendarUpsert) {
//			SetRemoteID(v+v).
//		}).
//		Exec(ctx)
func (_c *CalendarCreateBulk) OnConflict(opts ...sql.ConflictOption) *CalendarUpsertBulk {
	_c.conflict = opts
	return &CalendarUpsertBulk{
		create: _c,
	}
}

// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
//	client.Calendar.Create().
//		OnConflict(sql.ConflictColumns(columns...)).
//		Exec(ctx)
func (_c *CalendarCreateBulk) OnConflictColumns(columns ...string) *CalendarUpsertBulk {
	_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
	return &CalendarUpsertBulk{
		create: _c,
	}
}

// CalendarUpsertBulk is the builder for "upsert"-ing
// a bulk of Calendar nodes.
type CalendarUpsertBulk struct {
	create *CalendarCreateBulk
}

// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
//	client.Calendar.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(calendar.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *CalendarUpsertBulk) UpdateNewValues() *CalendarUpsertBulk {
	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(calendar.FieldID)
			}
			if _, exists := b.mutation.CreatedAt(); exists {
				s.SetIgnore(calendar.FieldCreatedAt)
			}
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.Calendar.Create().
//		OnConflict(sql.ResolveWithIgnore()).
//		Exec(ctx)
func (u *CalendarUpsertBulk) Ignore() *CalendarUpsertBulk {
	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 *CalendarUpsertBulk) DoNothing() *CalendarUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

// Update allows overriding fields `UPDATE` values. See the CalendarCreateBulk.OnConflict
// documentation for more info.
func (u *CalendarUpsertBulk) Update(set func(*CalendarUpsert)) *CalendarUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
		set(&CalendarUpsert{UpdateSet: update})
	}))
	return u
}

// SetRemoteID sets the "remote_id" field.
func (u *CalendarUpsertBulk) SetRemoteID(v string) *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.SetRemoteID(v)
	})
}

// UpdateRemoteID sets the "remote_id" field to the value that was provided on create.
func (u *CalendarUpsertBulk) UpdateRemoteID() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateRemoteID()
	})
}

// SetName sets the "name" field.
func (u *CalendarUpsertBulk) SetName(v string) *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.SetName(v)
	})
}

// UpdateName sets the "name" field to the value that was provided on create.
func (u *CalendarUpsertBulk) UpdateName() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateName()
	})
}

// SetNameOverride sets the "name_override" field.
func (u *CalendarUpsertBulk) SetNameOverride(v string) *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.SetNameOverride(v)
	})
}

// UpdateNameOverride sets the "name_override" field to the value that was provided on create.
func (u *CalendarUpsertBulk) UpdateNameOverride() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateNameOverride()
	})
}

// ClearNameOverride clears the value of the "name_override" field.
func (u *CalendarUpsertBulk) ClearNameOverride() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.ClearNameOverride()
	})
}

// SetDescription sets the "description" field.
func (u *CalendarUpsertBulk) SetDescription(v string) *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.SetDescription(v)
	})
}

// UpdateDescription sets the "description" field to the value that was provided on create.
func (u *CalendarUpsertBulk) UpdateDescription() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateDescription()
	})
}

// ClearDescription clears the value of the "description" field.
func (u *CalendarUpsertBulk) ClearDescription() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.ClearDescription()
	})
}

// SetColor sets the "color" field.
func (u *CalendarUpsertBulk) SetColor(v string) *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.SetColor(v)
	})
}

// UpdateColor sets the "color" field to the value that was provided on create.
func (u *CalendarUpsertBulk) UpdateColor() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateColor()
	})
}

// ClearColor clears the value of the "color" field.
func (u *CalendarUpsertBulk) ClearColor() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.ClearColor()
	})
}

// SetTimeZone sets the "time_zone" field.
func (u *CalendarUpsertBulk) SetTimeZone(v string) *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.SetTimeZone(v)
	})
}

// UpdateTimeZone sets the "time_zone" field to the value that was provided on create.
func (u *CalendarUpsertBulk) UpdateTimeZone() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateTimeZone()
	})
}

// ClearTimeZone clears the value of the "time_zone" field.
func (u *CalendarUpsertBulk) ClearTimeZone() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.ClearTimeZone()
	})
}

// SetReadOnly sets the "read_only" field.
func (u *CalendarUpsertBulk) SetReadOnly(v bool) *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.SetReadOnly(v)
	})
}

// UpdateReadOnly sets the "read_only" field to the value that was provided on create.
func (u *CalendarUpsertBulk) UpdateReadOnly() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateReadOnly()
	})
}

// SetHidden sets the "hidden" field.
func (u *CalendarUpsertBulk) SetHidden(v bool) *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.SetHidden(v)
	})
}

// UpdateHidden sets the "hidden" field to the value that was provided on create.
func (u *CalendarUpsertBulk) UpdateHidden() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateHidden()
	})
}

// SetSyncDisabled sets the "sync_disabled" field.
func (u *CalendarUpsertBulk) SetSyncDisabled(v bool) *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.SetSyncDisabled(v)
	})
}

// UpdateSyncDisabled sets the "sync_disabled" field to the value that was provided on create.
func (u *CalendarUpsertBulk) UpdateSyncDisabled() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateSyncDisabled()
	})
}

// SetReminderOverrides sets the "reminder_overrides" field.
func (u *CalendarUpsertBulk) SetReminderOverrides(v *settings.ReminderOverride) *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.SetReminderOverrides(v)
	})
}

// UpdateReminderOverrides sets the "reminder_overrides" field to the value that was provided on create.
func (u *CalendarUpsertBulk) UpdateReminderOverrides() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateReminderOverrides()
	})
}

// ClearReminderOverrides clears the value of the "reminder_overrides" field.
func (u *CalendarUpsertBulk) ClearReminderOverrides() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.ClearReminderOverrides()
	})
}

// SetSyncToken sets the "sync_token" field.
func (u *CalendarUpsertBulk) SetSyncToken(v string) *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.SetSyncToken(v)
	})
}

// UpdateSyncToken sets the "sync_token" field to the value that was provided on create.
func (u *CalendarUpsertBulk) UpdateSyncToken() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateSyncToken()
	})
}

// ClearSyncToken clears the value of the "sync_token" field.
func (u *CalendarUpsertBulk) ClearSyncToken() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.ClearSyncToken()
	})
}

// SetSupportedComponents sets the "supported_components" field.
func (u *CalendarUpsertBulk) SetSupportedComponents(v []string) *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.SetSupportedComponents(v)
	})
}

// UpdateSupportedComponents sets the "supported_components" field to the value that was provided on create.
func (u *CalendarUpsertBulk) UpdateSupportedComponents() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateSupportedComponents()
	})
}

// ClearSupportedComponents clears the value of the "supported_components" field.
func (u *CalendarUpsertBulk) ClearSupportedComponents() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.ClearSupportedComponents()
	})
}

// SetUpdatedAt sets the "updated_at" field.
func (u *CalendarUpsertBulk) SetUpdatedAt(v time.Time) *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.SetUpdatedAt(v)
	})
}

// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *CalendarUpsertBulk) UpdateUpdatedAt() *CalendarUpsertBulk {
	return u.Update(func(s *CalendarUpsert) {
		s.UpdateUpdatedAt()
	})
}

// Exec executes the query.
func (u *CalendarUpsertBulk) 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("ent: OnConflict was set for builder %d. Set it on the CalendarCreateBulk instead", i)
		}
	}
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for CalendarCreateBulk.OnConflict")
	}
	return u.create.Exec(ctx)
}

// ExecX is like Exec, but panics if an error occurs.
func (u *CalendarUpsertBulk) ExecX(ctx context.Context) {
	if err := u.create.Exec(ctx); err != nil {
		panic(err)
	}
}
