// Code generated by ent, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"
	"time"
	"wechat-api/ent/labellog"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
)

// LabelLogCreate is the builder for creating a LabelLog entity.
type LabelLogCreate struct {
	config
	mutation *LabelLogMutation
	hooks    []Hook
	conflict []sql.ConflictOption
}

// SetCreatedAt sets the "created_at" field.
func (llc *LabelLogCreate) SetCreatedAt(t time.Time) *LabelLogCreate {
	llc.mutation.SetCreatedAt(t)
	return llc
}

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

// SetUpdatedAt sets the "updated_at" field.
func (llc *LabelLogCreate) SetUpdatedAt(t time.Time) *LabelLogCreate {
	llc.mutation.SetUpdatedAt(t)
	return llc
}

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

// SetLabelName sets the "label_name" field.
func (llc *LabelLogCreate) SetLabelName(s string) *LabelLogCreate {
	llc.mutation.SetLabelName(s)
	return llc
}

// SetNillableLabelName sets the "label_name" field if the given value is not nil.
func (llc *LabelLogCreate) SetNillableLabelName(s *string) *LabelLogCreate {
	if s != nil {
		llc.SetLabelName(*s)
	}
	return llc
}

// SetLabelID sets the "label_id" field.
func (llc *LabelLogCreate) SetLabelID(i int) *LabelLogCreate {
	llc.mutation.SetLabelID(i)
	return llc
}

// SetNillableLabelID sets the "label_id" field if the given value is not nil.
func (llc *LabelLogCreate) SetNillableLabelID(i *int) *LabelLogCreate {
	if i != nil {
		llc.SetLabelID(*i)
	}
	return llc
}

// SetWxID sets the "wx_id" field.
func (llc *LabelLogCreate) SetWxID(s string) *LabelLogCreate {
	llc.mutation.SetWxID(s)
	return llc
}

// SetNillableWxID sets the "wx_id" field if the given value is not nil.
func (llc *LabelLogCreate) SetNillableWxID(s *string) *LabelLogCreate {
	if s != nil {
		llc.SetWxID(*s)
	}
	return llc
}

// SetOrganizationID sets the "organization_id" field.
func (llc *LabelLogCreate) SetOrganizationID(u uint64) *LabelLogCreate {
	llc.mutation.SetOrganizationID(u)
	return llc
}

// SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
func (llc *LabelLogCreate) SetNillableOrganizationID(u *uint64) *LabelLogCreate {
	if u != nil {
		llc.SetOrganizationID(*u)
	}
	return llc
}

// SetID sets the "id" field.
func (llc *LabelLogCreate) SetID(u uint64) *LabelLogCreate {
	llc.mutation.SetID(u)
	return llc
}

// Mutation returns the LabelLogMutation object of the builder.
func (llc *LabelLogCreate) Mutation() *LabelLogMutation {
	return llc.mutation
}

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

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

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

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

// defaults sets the default values of the builder before save.
func (llc *LabelLogCreate) defaults() {
	if _, ok := llc.mutation.CreatedAt(); !ok {
		v := labellog.DefaultCreatedAt()
		llc.mutation.SetCreatedAt(v)
	}
	if _, ok := llc.mutation.UpdatedAt(); !ok {
		v := labellog.DefaultUpdatedAt()
		llc.mutation.SetUpdatedAt(v)
	}
	if _, ok := llc.mutation.LabelName(); !ok {
		v := labellog.DefaultLabelName
		llc.mutation.SetLabelName(v)
	}
	if _, ok := llc.mutation.LabelID(); !ok {
		v := labellog.DefaultLabelID
		llc.mutation.SetLabelID(v)
	}
	if _, ok := llc.mutation.WxID(); !ok {
		v := labellog.DefaultWxID
		llc.mutation.SetWxID(v)
	}
	if _, ok := llc.mutation.OrganizationID(); !ok {
		v := labellog.DefaultOrganizationID
		llc.mutation.SetOrganizationID(v)
	}
}

// check runs all checks and user-defined validators on the builder.
func (llc *LabelLogCreate) check() error {
	if _, ok := llc.mutation.CreatedAt(); !ok {
		return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "LabelLog.created_at"`)}
	}
	if _, ok := llc.mutation.UpdatedAt(); !ok {
		return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "LabelLog.updated_at"`)}
	}
	if _, ok := llc.mutation.LabelName(); !ok {
		return &ValidationError{Name: "label_name", err: errors.New(`ent: missing required field "LabelLog.label_name"`)}
	}
	if _, ok := llc.mutation.LabelID(); !ok {
		return &ValidationError{Name: "label_id", err: errors.New(`ent: missing required field "LabelLog.label_id"`)}
	}
	if _, ok := llc.mutation.WxID(); !ok {
		return &ValidationError{Name: "wx_id", err: errors.New(`ent: missing required field "LabelLog.wx_id"`)}
	}
	return nil
}

func (llc *LabelLogCreate) sqlSave(ctx context.Context) (*LabelLog, error) {
	if err := llc.check(); err != nil {
		return nil, err
	}
	_node, _spec := llc.createSpec()
	if err := sqlgraph.CreateNode(ctx, llc.driver, _spec); err != nil {
		if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	if _spec.ID.Value != _node.ID {
		id := _spec.ID.Value.(int64)
		_node.ID = uint64(id)
	}
	llc.mutation.id = &_node.ID
	llc.mutation.done = true
	return _node, nil
}

func (llc *LabelLogCreate) createSpec() (*LabelLog, *sqlgraph.CreateSpec) {
	var (
		_node = &LabelLog{config: llc.config}
		_spec = sqlgraph.NewCreateSpec(labellog.Table, sqlgraph.NewFieldSpec(labellog.FieldID, field.TypeUint64))
	)
	_spec.OnConflict = llc.conflict
	if id, ok := llc.mutation.ID(); ok {
		_node.ID = id
		_spec.ID.Value = id
	}
	if value, ok := llc.mutation.CreatedAt(); ok {
		_spec.SetField(labellog.FieldCreatedAt, field.TypeTime, value)
		_node.CreatedAt = value
	}
	if value, ok := llc.mutation.UpdatedAt(); ok {
		_spec.SetField(labellog.FieldUpdatedAt, field.TypeTime, value)
		_node.UpdatedAt = value
	}
	if value, ok := llc.mutation.LabelName(); ok {
		_spec.SetField(labellog.FieldLabelName, field.TypeString, value)
		_node.LabelName = value
	}
	if value, ok := llc.mutation.LabelID(); ok {
		_spec.SetField(labellog.FieldLabelID, field.TypeInt, value)
		_node.LabelID = value
	}
	if value, ok := llc.mutation.WxID(); ok {
		_spec.SetField(labellog.FieldWxID, field.TypeString, value)
		_node.WxID = value
	}
	if value, ok := llc.mutation.OrganizationID(); ok {
		_spec.SetField(labellog.FieldOrganizationID, field.TypeUint64, value)
		_node.OrganizationID = value
	}
	return _node, _spec
}

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.LabelLog.Create().
//		SetCreatedAt(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.LabelLogUpsert) {
//			SetCreatedAt(v+v).
//		}).
//		Exec(ctx)
func (llc *LabelLogCreate) OnConflict(opts ...sql.ConflictOption) *LabelLogUpsertOne {
	llc.conflict = opts
	return &LabelLogUpsertOne{
		create: llc,
	}
}

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

type (
	// LabelLogUpsertOne is the builder for "upsert"-ing
	//  one LabelLog node.
	LabelLogUpsertOne struct {
		create *LabelLogCreate
	}

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

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

// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *LabelLogUpsert) UpdateUpdatedAt() *LabelLogUpsert {
	u.SetExcluded(labellog.FieldUpdatedAt)
	return u
}

// SetLabelName sets the "label_name" field.
func (u *LabelLogUpsert) SetLabelName(v string) *LabelLogUpsert {
	u.Set(labellog.FieldLabelName, v)
	return u
}

// UpdateLabelName sets the "label_name" field to the value that was provided on create.
func (u *LabelLogUpsert) UpdateLabelName() *LabelLogUpsert {
	u.SetExcluded(labellog.FieldLabelName)
	return u
}

// SetLabelID sets the "label_id" field.
func (u *LabelLogUpsert) SetLabelID(v int) *LabelLogUpsert {
	u.Set(labellog.FieldLabelID, v)
	return u
}

// UpdateLabelID sets the "label_id" field to the value that was provided on create.
func (u *LabelLogUpsert) UpdateLabelID() *LabelLogUpsert {
	u.SetExcluded(labellog.FieldLabelID)
	return u
}

// AddLabelID adds v to the "label_id" field.
func (u *LabelLogUpsert) AddLabelID(v int) *LabelLogUpsert {
	u.Add(labellog.FieldLabelID, v)
	return u
}

// SetWxID sets the "wx_id" field.
func (u *LabelLogUpsert) SetWxID(v string) *LabelLogUpsert {
	u.Set(labellog.FieldWxID, v)
	return u
}

// UpdateWxID sets the "wx_id" field to the value that was provided on create.
func (u *LabelLogUpsert) UpdateWxID() *LabelLogUpsert {
	u.SetExcluded(labellog.FieldWxID)
	return u
}

// SetOrganizationID sets the "organization_id" field.
func (u *LabelLogUpsert) SetOrganizationID(v uint64) *LabelLogUpsert {
	u.Set(labellog.FieldOrganizationID, v)
	return u
}

// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
func (u *LabelLogUpsert) UpdateOrganizationID() *LabelLogUpsert {
	u.SetExcluded(labellog.FieldOrganizationID)
	return u
}

// AddOrganizationID adds v to the "organization_id" field.
func (u *LabelLogUpsert) AddOrganizationID(v uint64) *LabelLogUpsert {
	u.Add(labellog.FieldOrganizationID, v)
	return u
}

// ClearOrganizationID clears the value of the "organization_id" field.
func (u *LabelLogUpsert) ClearOrganizationID() *LabelLogUpsert {
	u.SetNull(labellog.FieldOrganizationID)
	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.LabelLog.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(labellog.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *LabelLogUpsertOne) UpdateNewValues() *LabelLogUpsertOne {
	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(labellog.FieldID)
		}
		if _, exists := u.create.mutation.CreatedAt(); exists {
			s.SetIgnore(labellog.FieldCreatedAt)
		}
	}))
	return u
}

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

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

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

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

// SetLabelName sets the "label_name" field.
func (u *LabelLogUpsertOne) SetLabelName(v string) *LabelLogUpsertOne {
	return u.Update(func(s *LabelLogUpsert) {
		s.SetLabelName(v)
	})
}

// UpdateLabelName sets the "label_name" field to the value that was provided on create.
func (u *LabelLogUpsertOne) UpdateLabelName() *LabelLogUpsertOne {
	return u.Update(func(s *LabelLogUpsert) {
		s.UpdateLabelName()
	})
}

// SetLabelID sets the "label_id" field.
func (u *LabelLogUpsertOne) SetLabelID(v int) *LabelLogUpsertOne {
	return u.Update(func(s *LabelLogUpsert) {
		s.SetLabelID(v)
	})
}

// AddLabelID adds v to the "label_id" field.
func (u *LabelLogUpsertOne) AddLabelID(v int) *LabelLogUpsertOne {
	return u.Update(func(s *LabelLogUpsert) {
		s.AddLabelID(v)
	})
}

// UpdateLabelID sets the "label_id" field to the value that was provided on create.
func (u *LabelLogUpsertOne) UpdateLabelID() *LabelLogUpsertOne {
	return u.Update(func(s *LabelLogUpsert) {
		s.UpdateLabelID()
	})
}

// SetWxID sets the "wx_id" field.
func (u *LabelLogUpsertOne) SetWxID(v string) *LabelLogUpsertOne {
	return u.Update(func(s *LabelLogUpsert) {
		s.SetWxID(v)
	})
}

// UpdateWxID sets the "wx_id" field to the value that was provided on create.
func (u *LabelLogUpsertOne) UpdateWxID() *LabelLogUpsertOne {
	return u.Update(func(s *LabelLogUpsert) {
		s.UpdateWxID()
	})
}

// SetOrganizationID sets the "organization_id" field.
func (u *LabelLogUpsertOne) SetOrganizationID(v uint64) *LabelLogUpsertOne {
	return u.Update(func(s *LabelLogUpsert) {
		s.SetOrganizationID(v)
	})
}

// AddOrganizationID adds v to the "organization_id" field.
func (u *LabelLogUpsertOne) AddOrganizationID(v uint64) *LabelLogUpsertOne {
	return u.Update(func(s *LabelLogUpsert) {
		s.AddOrganizationID(v)
	})
}

// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
func (u *LabelLogUpsertOne) UpdateOrganizationID() *LabelLogUpsertOne {
	return u.Update(func(s *LabelLogUpsert) {
		s.UpdateOrganizationID()
	})
}

// ClearOrganizationID clears the value of the "organization_id" field.
func (u *LabelLogUpsertOne) ClearOrganizationID() *LabelLogUpsertOne {
	return u.Update(func(s *LabelLogUpsert) {
		s.ClearOrganizationID()
	})
}

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

// ExecX is like Exec, but panics if an error occurs.
func (u *LabelLogUpsertOne) 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 *LabelLogUpsertOne) ID(ctx context.Context) (id uint64, err error) {
	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 *LabelLogUpsertOne) IDX(ctx context.Context) uint64 {
	id, err := u.ID(ctx)
	if err != nil {
		panic(err)
	}
	return id
}

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

// Save creates the LabelLog entities in the database.
func (llcb *LabelLogCreateBulk) Save(ctx context.Context) ([]*LabelLog, error) {
	if llcb.err != nil {
		return nil, llcb.err
	}
	specs := make([]*sqlgraph.CreateSpec, len(llcb.builders))
	nodes := make([]*LabelLog, len(llcb.builders))
	mutators := make([]Mutator, len(llcb.builders))
	for i := range llcb.builders {
		func(i int, root context.Context) {
			builder := llcb.builders[i]
			builder.defaults()
			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
				mutation, ok := m.(*LabelLogMutation)
				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, llcb.builders[i+1].mutation)
				} else {
					spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
					spec.OnConflict = llcb.conflict
					// Invoke the actual operation on the latest mutation in the chain.
					if err = sqlgraph.BatchCreate(ctx, llcb.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
				if specs[i].ID.Value != nil && nodes[i].ID == 0 {
					id := specs[i].ID.Value.(int64)
					nodes[i].ID = uint64(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, llcb.builders[0].mutation); err != nil {
			return nil, err
		}
	}
	return nodes, nil
}

// SaveX is like Save, but panics if an error occurs.
func (llcb *LabelLogCreateBulk) SaveX(ctx context.Context) []*LabelLog {
	v, err := llcb.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

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

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

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.LabelLog.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.LabelLogUpsert) {
//			SetCreatedAt(v+v).
//		}).
//		Exec(ctx)
func (llcb *LabelLogCreateBulk) OnConflict(opts ...sql.ConflictOption) *LabelLogUpsertBulk {
	llcb.conflict = opts
	return &LabelLogUpsertBulk{
		create: llcb,
	}
}

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

// LabelLogUpsertBulk is the builder for "upsert"-ing
// a bulk of LabelLog nodes.
type LabelLogUpsertBulk struct {
	create *LabelLogCreateBulk
}

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

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

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

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

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

// SetLabelName sets the "label_name" field.
func (u *LabelLogUpsertBulk) SetLabelName(v string) *LabelLogUpsertBulk {
	return u.Update(func(s *LabelLogUpsert) {
		s.SetLabelName(v)
	})
}

// UpdateLabelName sets the "label_name" field to the value that was provided on create.
func (u *LabelLogUpsertBulk) UpdateLabelName() *LabelLogUpsertBulk {
	return u.Update(func(s *LabelLogUpsert) {
		s.UpdateLabelName()
	})
}

// SetLabelID sets the "label_id" field.
func (u *LabelLogUpsertBulk) SetLabelID(v int) *LabelLogUpsertBulk {
	return u.Update(func(s *LabelLogUpsert) {
		s.SetLabelID(v)
	})
}

// AddLabelID adds v to the "label_id" field.
func (u *LabelLogUpsertBulk) AddLabelID(v int) *LabelLogUpsertBulk {
	return u.Update(func(s *LabelLogUpsert) {
		s.AddLabelID(v)
	})
}

// UpdateLabelID sets the "label_id" field to the value that was provided on create.
func (u *LabelLogUpsertBulk) UpdateLabelID() *LabelLogUpsertBulk {
	return u.Update(func(s *LabelLogUpsert) {
		s.UpdateLabelID()
	})
}

// SetWxID sets the "wx_id" field.
func (u *LabelLogUpsertBulk) SetWxID(v string) *LabelLogUpsertBulk {
	return u.Update(func(s *LabelLogUpsert) {
		s.SetWxID(v)
	})
}

// UpdateWxID sets the "wx_id" field to the value that was provided on create.
func (u *LabelLogUpsertBulk) UpdateWxID() *LabelLogUpsertBulk {
	return u.Update(func(s *LabelLogUpsert) {
		s.UpdateWxID()
	})
}

// SetOrganizationID sets the "organization_id" field.
func (u *LabelLogUpsertBulk) SetOrganizationID(v uint64) *LabelLogUpsertBulk {
	return u.Update(func(s *LabelLogUpsert) {
		s.SetOrganizationID(v)
	})
}

// AddOrganizationID adds v to the "organization_id" field.
func (u *LabelLogUpsertBulk) AddOrganizationID(v uint64) *LabelLogUpsertBulk {
	return u.Update(func(s *LabelLogUpsert) {
		s.AddOrganizationID(v)
	})
}

// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
func (u *LabelLogUpsertBulk) UpdateOrganizationID() *LabelLogUpsertBulk {
	return u.Update(func(s *LabelLogUpsert) {
		s.UpdateOrganizationID()
	})
}

// ClearOrganizationID clears the value of the "organization_id" field.
func (u *LabelLogUpsertBulk) ClearOrganizationID() *LabelLogUpsertBulk {
	return u.Update(func(s *LabelLogUpsert) {
		s.ClearOrganizationID()
	})
}

// Exec executes the query.
func (u *LabelLogUpsertBulk) 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 LabelLogCreateBulk instead", i)
		}
	}
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for LabelLogCreateBulk.OnConflict")
	}
	return u.create.Exec(ctx)
}

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