// Code generated by ent, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"
	"time"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/dialect/sql/sqljson"
	"entgo.io/ent/schema/field"
	"github.com/AvengeMedia/dankcalendar/core/ent/calendar"
	"github.com/AvengeMedia/dankcalendar/core/ent/event"
	"github.com/AvengeMedia/dankcalendar/core/ent/predicate"
)

// EventUpdate is the builder for updating Event entities.
type EventUpdate struct {
	config
	hooks     []Hook
	mutation  *EventMutation
	modifiers []func(*sql.UpdateBuilder)
}

// Where appends a list predicates to the EventUpdate builder.
func (_u *EventUpdate) Where(ps ...predicate.Event) *EventUpdate {
	_u.mutation.Where(ps...)
	return _u
}

// SetUID sets the "uid" field.
func (_u *EventUpdate) SetUID(v string) *EventUpdate {
	_u.mutation.SetUID(v)
	return _u
}

// SetNillableUID sets the "uid" field if the given value is not nil.
func (_u *EventUpdate) SetNillableUID(v *string) *EventUpdate {
	if v != nil {
		_u.SetUID(*v)
	}
	return _u
}

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

// SetNillableRemoteID sets the "remote_id" field if the given value is not nil.
func (_u *EventUpdate) SetNillableRemoteID(v *string) *EventUpdate {
	if v != nil {
		_u.SetRemoteID(*v)
	}
	return _u
}

// ClearRemoteID clears the value of the "remote_id" field.
func (_u *EventUpdate) ClearRemoteID() *EventUpdate {
	_u.mutation.ClearRemoteID()
	return _u
}

// SetEtag sets the "etag" field.
func (_u *EventUpdate) SetEtag(v string) *EventUpdate {
	_u.mutation.SetEtag(v)
	return _u
}

// SetNillableEtag sets the "etag" field if the given value is not nil.
func (_u *EventUpdate) SetNillableEtag(v *string) *EventUpdate {
	if v != nil {
		_u.SetEtag(*v)
	}
	return _u
}

// ClearEtag clears the value of the "etag" field.
func (_u *EventUpdate) ClearEtag() *EventUpdate {
	_u.mutation.ClearEtag()
	return _u
}

// SetSummary sets the "summary" field.
func (_u *EventUpdate) SetSummary(v string) *EventUpdate {
	_u.mutation.SetSummary(v)
	return _u
}

// SetNillableSummary sets the "summary" field if the given value is not nil.
func (_u *EventUpdate) SetNillableSummary(v *string) *EventUpdate {
	if v != nil {
		_u.SetSummary(*v)
	}
	return _u
}

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

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

// ClearDescription clears the value of the "description" field.
func (_u *EventUpdate) ClearDescription() *EventUpdate {
	_u.mutation.ClearDescription()
	return _u
}

// SetLocation sets the "location" field.
func (_u *EventUpdate) SetLocation(v string) *EventUpdate {
	_u.mutation.SetLocation(v)
	return _u
}

// SetNillableLocation sets the "location" field if the given value is not nil.
func (_u *EventUpdate) SetNillableLocation(v *string) *EventUpdate {
	if v != nil {
		_u.SetLocation(*v)
	}
	return _u
}

// ClearLocation clears the value of the "location" field.
func (_u *EventUpdate) ClearLocation() *EventUpdate {
	_u.mutation.ClearLocation()
	return _u
}

// SetURL sets the "url" field.
func (_u *EventUpdate) SetURL(v string) *EventUpdate {
	_u.mutation.SetURL(v)
	return _u
}

// SetNillableURL sets the "url" field if the given value is not nil.
func (_u *EventUpdate) SetNillableURL(v *string) *EventUpdate {
	if v != nil {
		_u.SetURL(*v)
	}
	return _u
}

// ClearURL clears the value of the "url" field.
func (_u *EventUpdate) ClearURL() *EventUpdate {
	_u.mutation.ClearURL()
	return _u
}

// SetMeetingURL sets the "meeting_url" field.
func (_u *EventUpdate) SetMeetingURL(v string) *EventUpdate {
	_u.mutation.SetMeetingURL(v)
	return _u
}

// SetNillableMeetingURL sets the "meeting_url" field if the given value is not nil.
func (_u *EventUpdate) SetNillableMeetingURL(v *string) *EventUpdate {
	if v != nil {
		_u.SetMeetingURL(*v)
	}
	return _u
}

// ClearMeetingURL clears the value of the "meeting_url" field.
func (_u *EventUpdate) ClearMeetingURL() *EventUpdate {
	_u.mutation.ClearMeetingURL()
	return _u
}

// SetStatus sets the "status" field.
func (_u *EventUpdate) SetStatus(v event.Status) *EventUpdate {
	_u.mutation.SetStatus(v)
	return _u
}

// SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *EventUpdate) SetNillableStatus(v *event.Status) *EventUpdate {
	if v != nil {
		_u.SetStatus(*v)
	}
	return _u
}

// SetStart sets the "start" field.
func (_u *EventUpdate) SetStart(v time.Time) *EventUpdate {
	_u.mutation.SetStart(v)
	return _u
}

// SetNillableStart sets the "start" field if the given value is not nil.
func (_u *EventUpdate) SetNillableStart(v *time.Time) *EventUpdate {
	if v != nil {
		_u.SetStart(*v)
	}
	return _u
}

// SetEnd sets the "end" field.
func (_u *EventUpdate) SetEnd(v time.Time) *EventUpdate {
	_u.mutation.SetEnd(v)
	return _u
}

// SetNillableEnd sets the "end" field if the given value is not nil.
func (_u *EventUpdate) SetNillableEnd(v *time.Time) *EventUpdate {
	if v != nil {
		_u.SetEnd(*v)
	}
	return _u
}

// SetAllDay sets the "all_day" field.
func (_u *EventUpdate) SetAllDay(v bool) *EventUpdate {
	_u.mutation.SetAllDay(v)
	return _u
}

// SetNillableAllDay sets the "all_day" field if the given value is not nil.
func (_u *EventUpdate) SetNillableAllDay(v *bool) *EventUpdate {
	if v != nil {
		_u.SetAllDay(*v)
	}
	return _u
}

// SetStartTz sets the "start_tz" field.
func (_u *EventUpdate) SetStartTz(v string) *EventUpdate {
	_u.mutation.SetStartTz(v)
	return _u
}

// SetNillableStartTz sets the "start_tz" field if the given value is not nil.
func (_u *EventUpdate) SetNillableStartTz(v *string) *EventUpdate {
	if v != nil {
		_u.SetStartTz(*v)
	}
	return _u
}

// ClearStartTz clears the value of the "start_tz" field.
func (_u *EventUpdate) ClearStartTz() *EventUpdate {
	_u.mutation.ClearStartTz()
	return _u
}

// SetEndTz sets the "end_tz" field.
func (_u *EventUpdate) SetEndTz(v string) *EventUpdate {
	_u.mutation.SetEndTz(v)
	return _u
}

// SetNillableEndTz sets the "end_tz" field if the given value is not nil.
func (_u *EventUpdate) SetNillableEndTz(v *string) *EventUpdate {
	if v != nil {
		_u.SetEndTz(*v)
	}
	return _u
}

// ClearEndTz clears the value of the "end_tz" field.
func (_u *EventUpdate) ClearEndTz() *EventUpdate {
	_u.mutation.ClearEndTz()
	return _u
}

// SetRecurrence sets the "recurrence" field.
func (_u *EventUpdate) SetRecurrence(v map[string]interface{}) *EventUpdate {
	_u.mutation.SetRecurrence(v)
	return _u
}

// ClearRecurrence clears the value of the "recurrence" field.
func (_u *EventUpdate) ClearRecurrence() *EventUpdate {
	_u.mutation.ClearRecurrence()
	return _u
}

// SetRecurringID sets the "recurring_id" field.
func (_u *EventUpdate) SetRecurringID(v string) *EventUpdate {
	_u.mutation.SetRecurringID(v)
	return _u
}

// SetNillableRecurringID sets the "recurring_id" field if the given value is not nil.
func (_u *EventUpdate) SetNillableRecurringID(v *string) *EventUpdate {
	if v != nil {
		_u.SetRecurringID(*v)
	}
	return _u
}

// ClearRecurringID clears the value of the "recurring_id" field.
func (_u *EventUpdate) ClearRecurringID() *EventUpdate {
	_u.mutation.ClearRecurringID()
	return _u
}

// SetOriginalStart sets the "original_start" field.
func (_u *EventUpdate) SetOriginalStart(v time.Time) *EventUpdate {
	_u.mutation.SetOriginalStart(v)
	return _u
}

// SetNillableOriginalStart sets the "original_start" field if the given value is not nil.
func (_u *EventUpdate) SetNillableOriginalStart(v *time.Time) *EventUpdate {
	if v != nil {
		_u.SetOriginalStart(*v)
	}
	return _u
}

// ClearOriginalStart clears the value of the "original_start" field.
func (_u *EventUpdate) ClearOriginalStart() *EventUpdate {
	_u.mutation.ClearOriginalStart()
	return _u
}

// SetOrganizer sets the "organizer" field.
func (_u *EventUpdate) SetOrganizer(v map[string]interface{}) *EventUpdate {
	_u.mutation.SetOrganizer(v)
	return _u
}

// ClearOrganizer clears the value of the "organizer" field.
func (_u *EventUpdate) ClearOrganizer() *EventUpdate {
	_u.mutation.ClearOrganizer()
	return _u
}

// SetAttendees sets the "attendees" field.
func (_u *EventUpdate) SetAttendees(v []map[string]interface{}) *EventUpdate {
	_u.mutation.SetAttendees(v)
	return _u
}

// AppendAttendees appends value to the "attendees" field.
func (_u *EventUpdate) AppendAttendees(v []map[string]interface{}) *EventUpdate {
	_u.mutation.AppendAttendees(v)
	return _u
}

// ClearAttendees clears the value of the "attendees" field.
func (_u *EventUpdate) ClearAttendees() *EventUpdate {
	_u.mutation.ClearAttendees()
	return _u
}

// SetReminders sets the "reminders" field.
func (_u *EventUpdate) SetReminders(v []map[string]interface{}) *EventUpdate {
	_u.mutation.SetReminders(v)
	return _u
}

// AppendReminders appends value to the "reminders" field.
func (_u *EventUpdate) AppendReminders(v []map[string]interface{}) *EventUpdate {
	_u.mutation.AppendReminders(v)
	return _u
}

// ClearReminders clears the value of the "reminders" field.
func (_u *EventUpdate) ClearReminders() *EventUpdate {
	_u.mutation.ClearReminders()
	return _u
}

// SetCategories sets the "categories" field.
func (_u *EventUpdate) SetCategories(v []string) *EventUpdate {
	_u.mutation.SetCategories(v)
	return _u
}

// AppendCategories appends value to the "categories" field.
func (_u *EventUpdate) AppendCategories(v []string) *EventUpdate {
	_u.mutation.AppendCategories(v)
	return _u
}

// ClearCategories clears the value of the "categories" field.
func (_u *EventUpdate) ClearCategories() *EventUpdate {
	_u.mutation.ClearCategories()
	return _u
}

// SetTransparency sets the "transparency" field.
func (_u *EventUpdate) SetTransparency(v string) *EventUpdate {
	_u.mutation.SetTransparency(v)
	return _u
}

// SetNillableTransparency sets the "transparency" field if the given value is not nil.
func (_u *EventUpdate) SetNillableTransparency(v *string) *EventUpdate {
	if v != nil {
		_u.SetTransparency(*v)
	}
	return _u
}

// ClearTransparency clears the value of the "transparency" field.
func (_u *EventUpdate) ClearTransparency() *EventUpdate {
	_u.mutation.ClearTransparency()
	return _u
}

// SetVisibility sets the "visibility" field.
func (_u *EventUpdate) SetVisibility(v string) *EventUpdate {
	_u.mutation.SetVisibility(v)
	return _u
}

// SetNillableVisibility sets the "visibility" field if the given value is not nil.
func (_u *EventUpdate) SetNillableVisibility(v *string) *EventUpdate {
	if v != nil {
		_u.SetVisibility(*v)
	}
	return _u
}

// ClearVisibility clears the value of the "visibility" field.
func (_u *EventUpdate) ClearVisibility() *EventUpdate {
	_u.mutation.ClearVisibility()
	return _u
}

// SetRawIcs sets the "raw_ics" field.
func (_u *EventUpdate) SetRawIcs(v string) *EventUpdate {
	_u.mutation.SetRawIcs(v)
	return _u
}

// SetNillableRawIcs sets the "raw_ics" field if the given value is not nil.
func (_u *EventUpdate) SetNillableRawIcs(v *string) *EventUpdate {
	if v != nil {
		_u.SetRawIcs(*v)
	}
	return _u
}

// ClearRawIcs clears the value of the "raw_ics" field.
func (_u *EventUpdate) ClearRawIcs() *EventUpdate {
	_u.mutation.ClearRawIcs()
	return _u
}

// SetCreated sets the "created" field.
func (_u *EventUpdate) SetCreated(v time.Time) *EventUpdate {
	_u.mutation.SetCreated(v)
	return _u
}

// SetNillableCreated sets the "created" field if the given value is not nil.
func (_u *EventUpdate) SetNillableCreated(v *time.Time) *EventUpdate {
	if v != nil {
		_u.SetCreated(*v)
	}
	return _u
}

// SetUpdated sets the "updated" field.
func (_u *EventUpdate) SetUpdated(v time.Time) *EventUpdate {
	_u.mutation.SetUpdated(v)
	return _u
}

// SetCalendarID sets the "calendar" edge to the Calendar entity by ID.
func (_u *EventUpdate) SetCalendarID(id string) *EventUpdate {
	_u.mutation.SetCalendarID(id)
	return _u
}

// SetCalendar sets the "calendar" edge to the Calendar entity.
func (_u *EventUpdate) SetCalendar(v *Calendar) *EventUpdate {
	return _u.SetCalendarID(v.ID)
}

// Mutation returns the EventMutation object of the builder.
func (_u *EventUpdate) Mutation() *EventMutation {
	return _u.mutation
}

// ClearCalendar clears the "calendar" edge to the Calendar entity.
func (_u *EventUpdate) ClearCalendar() *EventUpdate {
	_u.mutation.ClearCalendar()
	return _u
}

// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *EventUpdate) Save(ctx context.Context) (int, error) {
	_u.defaults()
	return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}

// SaveX is like Save, but panics if an error occurs.
func (_u *EventUpdate) SaveX(ctx context.Context) int {
	affected, err := _u.Save(ctx)
	if err != nil {
		panic(err)
	}
	return affected
}

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

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

// defaults sets the default values of the builder before save.
func (_u *EventUpdate) defaults() {
	if _, ok := _u.mutation.Updated(); !ok {
		v := event.UpdateDefaultUpdated()
		_u.mutation.SetUpdated(v)
	}
}

// check runs all checks and user-defined validators on the builder.
func (_u *EventUpdate) check() error {
	if v, ok := _u.mutation.UID(); ok {
		if err := event.UIDValidator(v); err != nil {
			return &ValidationError{Name: "uid", err: fmt.Errorf(`ent: validator failed for field "Event.uid": %w`, err)}
		}
	}
	if v, ok := _u.mutation.Status(); ok {
		if err := event.StatusValidator(v); err != nil {
			return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Event.status": %w`, err)}
		}
	}
	if _u.mutation.CalendarCleared() && len(_u.mutation.CalendarIDs()) > 0 {
		return errors.New(`ent: clearing a required unique edge "Event.calendar"`)
	}
	return nil
}

// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (_u *EventUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EventUpdate {
	_u.modifiers = append(_u.modifiers, modifiers...)
	return _u
}

func (_u *EventUpdate) sqlSave(ctx context.Context) (_node int, err error) {
	if err := _u.check(); err != nil {
		return _node, err
	}
	_spec := sqlgraph.NewUpdateSpec(event.Table, event.Columns, sqlgraph.NewFieldSpec(event.FieldID, field.TypeString))
	if ps := _u.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := _u.mutation.UID(); ok {
		_spec.SetField(event.FieldUID, field.TypeString, value)
	}
	if value, ok := _u.mutation.RemoteID(); ok {
		_spec.SetField(event.FieldRemoteID, field.TypeString, value)
	}
	if _u.mutation.RemoteIDCleared() {
		_spec.ClearField(event.FieldRemoteID, field.TypeString)
	}
	if value, ok := _u.mutation.Etag(); ok {
		_spec.SetField(event.FieldEtag, field.TypeString, value)
	}
	if _u.mutation.EtagCleared() {
		_spec.ClearField(event.FieldEtag, field.TypeString)
	}
	if value, ok := _u.mutation.Summary(); ok {
		_spec.SetField(event.FieldSummary, field.TypeString, value)
	}
	if value, ok := _u.mutation.Description(); ok {
		_spec.SetField(event.FieldDescription, field.TypeString, value)
	}
	if _u.mutation.DescriptionCleared() {
		_spec.ClearField(event.FieldDescription, field.TypeString)
	}
	if value, ok := _u.mutation.Location(); ok {
		_spec.SetField(event.FieldLocation, field.TypeString, value)
	}
	if _u.mutation.LocationCleared() {
		_spec.ClearField(event.FieldLocation, field.TypeString)
	}
	if value, ok := _u.mutation.URL(); ok {
		_spec.SetField(event.FieldURL, field.TypeString, value)
	}
	if _u.mutation.URLCleared() {
		_spec.ClearField(event.FieldURL, field.TypeString)
	}
	if value, ok := _u.mutation.MeetingURL(); ok {
		_spec.SetField(event.FieldMeetingURL, field.TypeString, value)
	}
	if _u.mutation.MeetingURLCleared() {
		_spec.ClearField(event.FieldMeetingURL, field.TypeString)
	}
	if value, ok := _u.mutation.Status(); ok {
		_spec.SetField(event.FieldStatus, field.TypeEnum, value)
	}
	if value, ok := _u.mutation.Start(); ok {
		_spec.SetField(event.FieldStart, field.TypeTime, value)
	}
	if value, ok := _u.mutation.End(); ok {
		_spec.SetField(event.FieldEnd, field.TypeTime, value)
	}
	if value, ok := _u.mutation.AllDay(); ok {
		_spec.SetField(event.FieldAllDay, field.TypeBool, value)
	}
	if value, ok := _u.mutation.StartTz(); ok {
		_spec.SetField(event.FieldStartTz, field.TypeString, value)
	}
	if _u.mutation.StartTzCleared() {
		_spec.ClearField(event.FieldStartTz, field.TypeString)
	}
	if value, ok := _u.mutation.EndTz(); ok {
		_spec.SetField(event.FieldEndTz, field.TypeString, value)
	}
	if _u.mutation.EndTzCleared() {
		_spec.ClearField(event.FieldEndTz, field.TypeString)
	}
	if value, ok := _u.mutation.Recurrence(); ok {
		_spec.SetField(event.FieldRecurrence, field.TypeJSON, value)
	}
	if _u.mutation.RecurrenceCleared() {
		_spec.ClearField(event.FieldRecurrence, field.TypeJSON)
	}
	if value, ok := _u.mutation.RecurringID(); ok {
		_spec.SetField(event.FieldRecurringID, field.TypeString, value)
	}
	if _u.mutation.RecurringIDCleared() {
		_spec.ClearField(event.FieldRecurringID, field.TypeString)
	}
	if value, ok := _u.mutation.OriginalStart(); ok {
		_spec.SetField(event.FieldOriginalStart, field.TypeTime, value)
	}
	if _u.mutation.OriginalStartCleared() {
		_spec.ClearField(event.FieldOriginalStart, field.TypeTime)
	}
	if value, ok := _u.mutation.Organizer(); ok {
		_spec.SetField(event.FieldOrganizer, field.TypeJSON, value)
	}
	if _u.mutation.OrganizerCleared() {
		_spec.ClearField(event.FieldOrganizer, field.TypeJSON)
	}
	if value, ok := _u.mutation.Attendees(); ok {
		_spec.SetField(event.FieldAttendees, field.TypeJSON, value)
	}
	if value, ok := _u.mutation.AppendedAttendees(); ok {
		_spec.AddModifier(func(u *sql.UpdateBuilder) {
			sqljson.Append(u, event.FieldAttendees, value)
		})
	}
	if _u.mutation.AttendeesCleared() {
		_spec.ClearField(event.FieldAttendees, field.TypeJSON)
	}
	if value, ok := _u.mutation.Reminders(); ok {
		_spec.SetField(event.FieldReminders, field.TypeJSON, value)
	}
	if value, ok := _u.mutation.AppendedReminders(); ok {
		_spec.AddModifier(func(u *sql.UpdateBuilder) {
			sqljson.Append(u, event.FieldReminders, value)
		})
	}
	if _u.mutation.RemindersCleared() {
		_spec.ClearField(event.FieldReminders, field.TypeJSON)
	}
	if value, ok := _u.mutation.Categories(); ok {
		_spec.SetField(event.FieldCategories, field.TypeJSON, value)
	}
	if value, ok := _u.mutation.AppendedCategories(); ok {
		_spec.AddModifier(func(u *sql.UpdateBuilder) {
			sqljson.Append(u, event.FieldCategories, value)
		})
	}
	if _u.mutation.CategoriesCleared() {
		_spec.ClearField(event.FieldCategories, field.TypeJSON)
	}
	if value, ok := _u.mutation.Transparency(); ok {
		_spec.SetField(event.FieldTransparency, field.TypeString, value)
	}
	if _u.mutation.TransparencyCleared() {
		_spec.ClearField(event.FieldTransparency, field.TypeString)
	}
	if value, ok := _u.mutation.Visibility(); ok {
		_spec.SetField(event.FieldVisibility, field.TypeString, value)
	}
	if _u.mutation.VisibilityCleared() {
		_spec.ClearField(event.FieldVisibility, field.TypeString)
	}
	if value, ok := _u.mutation.RawIcs(); ok {
		_spec.SetField(event.FieldRawIcs, field.TypeString, value)
	}
	if _u.mutation.RawIcsCleared() {
		_spec.ClearField(event.FieldRawIcs, field.TypeString)
	}
	if value, ok := _u.mutation.Created(); ok {
		_spec.SetField(event.FieldCreated, field.TypeTime, value)
	}
	if value, ok := _u.mutation.Updated(); ok {
		_spec.SetField(event.FieldUpdated, field.TypeTime, value)
	}
	if _u.mutation.CalendarCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   event.CalendarTable,
			Columns: []string{event.CalendarColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(calendar.FieldID, field.TypeString),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := _u.mutation.CalendarIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   event.CalendarTable,
			Columns: []string{event.CalendarColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(calendar.FieldID, field.TypeString),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	_spec.AddModifiers(_u.modifiers...)
	if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{event.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return 0, err
	}
	_u.mutation.done = true
	return _node, nil
}

// EventUpdateOne is the builder for updating a single Event entity.
type EventUpdateOne struct {
	config
	fields    []string
	hooks     []Hook
	mutation  *EventMutation
	modifiers []func(*sql.UpdateBuilder)
}

// SetUID sets the "uid" field.
func (_u *EventUpdateOne) SetUID(v string) *EventUpdateOne {
	_u.mutation.SetUID(v)
	return _u
}

// SetNillableUID sets the "uid" field if the given value is not nil.
func (_u *EventUpdateOne) SetNillableUID(v *string) *EventUpdateOne {
	if v != nil {
		_u.SetUID(*v)
	}
	return _u
}

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

// SetNillableRemoteID sets the "remote_id" field if the given value is not nil.
func (_u *EventUpdateOne) SetNillableRemoteID(v *string) *EventUpdateOne {
	if v != nil {
		_u.SetRemoteID(*v)
	}
	return _u
}

// ClearRemoteID clears the value of the "remote_id" field.
func (_u *EventUpdateOne) ClearRemoteID() *EventUpdateOne {
	_u.mutation.ClearRemoteID()
	return _u
}

// SetEtag sets the "etag" field.
func (_u *EventUpdateOne) SetEtag(v string) *EventUpdateOne {
	_u.mutation.SetEtag(v)
	return _u
}

// SetNillableEtag sets the "etag" field if the given value is not nil.
func (_u *EventUpdateOne) SetNillableEtag(v *string) *EventUpdateOne {
	if v != nil {
		_u.SetEtag(*v)
	}
	return _u
}

// ClearEtag clears the value of the "etag" field.
func (_u *EventUpdateOne) ClearEtag() *EventUpdateOne {
	_u.mutation.ClearEtag()
	return _u
}

// SetSummary sets the "summary" field.
func (_u *EventUpdateOne) SetSummary(v string) *EventUpdateOne {
	_u.mutation.SetSummary(v)
	return _u
}

// SetNillableSummary sets the "summary" field if the given value is not nil.
func (_u *EventUpdateOne) SetNillableSummary(v *string) *EventUpdateOne {
	if v != nil {
		_u.SetSummary(*v)
	}
	return _u
}

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

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

// ClearDescription clears the value of the "description" field.
func (_u *EventUpdateOne) ClearDescription() *EventUpdateOne {
	_u.mutation.ClearDescription()
	return _u
}

// SetLocation sets the "location" field.
func (_u *EventUpdateOne) SetLocation(v string) *EventUpdateOne {
	_u.mutation.SetLocation(v)
	return _u
}

// SetNillableLocation sets the "location" field if the given value is not nil.
func (_u *EventUpdateOne) SetNillableLocation(v *string) *EventUpdateOne {
	if v != nil {
		_u.SetLocation(*v)
	}
	return _u
}

// ClearLocation clears the value of the "location" field.
func (_u *EventUpdateOne) ClearLocation() *EventUpdateOne {
	_u.mutation.ClearLocation()
	return _u
}

// SetURL sets the "url" field.
func (_u *EventUpdateOne) SetURL(v string) *EventUpdateOne {
	_u.mutation.SetURL(v)
	return _u
}

// SetNillableURL sets the "url" field if the given value is not nil.
func (_u *EventUpdateOne) SetNillableURL(v *string) *EventUpdateOne {
	if v != nil {
		_u.SetURL(*v)
	}
	return _u
}

// ClearURL clears the value of the "url" field.
func (_u *EventUpdateOne) ClearURL() *EventUpdateOne {
	_u.mutation.ClearURL()
	return _u
}

// SetMeetingURL sets the "meeting_url" field.
func (_u *EventUpdateOne) SetMeetingURL(v string) *EventUpdateOne {
	_u.mutation.SetMeetingURL(v)
	return _u
}

// SetNillableMeetingURL sets the "meeting_url" field if the given value is not nil.
func (_u *EventUpdateOne) SetNillableMeetingURL(v *string) *EventUpdateOne {
	if v != nil {
		_u.SetMeetingURL(*v)
	}
	return _u
}

// ClearMeetingURL clears the value of the "meeting_url" field.
func (_u *EventUpdateOne) ClearMeetingURL() *EventUpdateOne {
	_u.mutation.ClearMeetingURL()
	return _u
}

// SetStatus sets the "status" field.
func (_u *EventUpdateOne) SetStatus(v event.Status) *EventUpdateOne {
	_u.mutation.SetStatus(v)
	return _u
}

// SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *EventUpdateOne) SetNillableStatus(v *event.Status) *EventUpdateOne {
	if v != nil {
		_u.SetStatus(*v)
	}
	return _u
}

// SetStart sets the "start" field.
func (_u *EventUpdateOne) SetStart(v time.Time) *EventUpdateOne {
	_u.mutation.SetStart(v)
	return _u
}

// SetNillableStart sets the "start" field if the given value is not nil.
func (_u *EventUpdateOne) SetNillableStart(v *time.Time) *EventUpdateOne {
	if v != nil {
		_u.SetStart(*v)
	}
	return _u
}

// SetEnd sets the "end" field.
func (_u *EventUpdateOne) SetEnd(v time.Time) *EventUpdateOne {
	_u.mutation.SetEnd(v)
	return _u
}

// SetNillableEnd sets the "end" field if the given value is not nil.
func (_u *EventUpdateOne) SetNillableEnd(v *time.Time) *EventUpdateOne {
	if v != nil {
		_u.SetEnd(*v)
	}
	return _u
}

// SetAllDay sets the "all_day" field.
func (_u *EventUpdateOne) SetAllDay(v bool) *EventUpdateOne {
	_u.mutation.SetAllDay(v)
	return _u
}

// SetNillableAllDay sets the "all_day" field if the given value is not nil.
func (_u *EventUpdateOne) SetNillableAllDay(v *bool) *EventUpdateOne {
	if v != nil {
		_u.SetAllDay(*v)
	}
	return _u
}

// SetStartTz sets the "start_tz" field.
func (_u *EventUpdateOne) SetStartTz(v string) *EventUpdateOne {
	_u.mutation.SetStartTz(v)
	return _u
}

// SetNillableStartTz sets the "start_tz" field if the given value is not nil.
func (_u *EventUpdateOne) SetNillableStartTz(v *string) *EventUpdateOne {
	if v != nil {
		_u.SetStartTz(*v)
	}
	return _u
}

// ClearStartTz clears the value of the "start_tz" field.
func (_u *EventUpdateOne) ClearStartTz() *EventUpdateOne {
	_u.mutation.ClearStartTz()
	return _u
}

// SetEndTz sets the "end_tz" field.
func (_u *EventUpdateOne) SetEndTz(v string) *EventUpdateOne {
	_u.mutation.SetEndTz(v)
	return _u
}

// SetNillableEndTz sets the "end_tz" field if the given value is not nil.
func (_u *EventUpdateOne) SetNillableEndTz(v *string) *EventUpdateOne {
	if v != nil {
		_u.SetEndTz(*v)
	}
	return _u
}

// ClearEndTz clears the value of the "end_tz" field.
func (_u *EventUpdateOne) ClearEndTz() *EventUpdateOne {
	_u.mutation.ClearEndTz()
	return _u
}

// SetRecurrence sets the "recurrence" field.
func (_u *EventUpdateOne) SetRecurrence(v map[string]interface{}) *EventUpdateOne {
	_u.mutation.SetRecurrence(v)
	return _u
}

// ClearRecurrence clears the value of the "recurrence" field.
func (_u *EventUpdateOne) ClearRecurrence() *EventUpdateOne {
	_u.mutation.ClearRecurrence()
	return _u
}

// SetRecurringID sets the "recurring_id" field.
func (_u *EventUpdateOne) SetRecurringID(v string) *EventUpdateOne {
	_u.mutation.SetRecurringID(v)
	return _u
}

// SetNillableRecurringID sets the "recurring_id" field if the given value is not nil.
func (_u *EventUpdateOne) SetNillableRecurringID(v *string) *EventUpdateOne {
	if v != nil {
		_u.SetRecurringID(*v)
	}
	return _u
}

// ClearRecurringID clears the value of the "recurring_id" field.
func (_u *EventUpdateOne) ClearRecurringID() *EventUpdateOne {
	_u.mutation.ClearRecurringID()
	return _u
}

// SetOriginalStart sets the "original_start" field.
func (_u *EventUpdateOne) SetOriginalStart(v time.Time) *EventUpdateOne {
	_u.mutation.SetOriginalStart(v)
	return _u
}

// SetNillableOriginalStart sets the "original_start" field if the given value is not nil.
func (_u *EventUpdateOne) SetNillableOriginalStart(v *time.Time) *EventUpdateOne {
	if v != nil {
		_u.SetOriginalStart(*v)
	}
	return _u
}

// ClearOriginalStart clears the value of the "original_start" field.
func (_u *EventUpdateOne) ClearOriginalStart() *EventUpdateOne {
	_u.mutation.ClearOriginalStart()
	return _u
}

// SetOrganizer sets the "organizer" field.
func (_u *EventUpdateOne) SetOrganizer(v map[string]interface{}) *EventUpdateOne {
	_u.mutation.SetOrganizer(v)
	return _u
}

// ClearOrganizer clears the value of the "organizer" field.
func (_u *EventUpdateOne) ClearOrganizer() *EventUpdateOne {
	_u.mutation.ClearOrganizer()
	return _u
}

// SetAttendees sets the "attendees" field.
func (_u *EventUpdateOne) SetAttendees(v []map[string]interface{}) *EventUpdateOne {
	_u.mutation.SetAttendees(v)
	return _u
}

// AppendAttendees appends value to the "attendees" field.
func (_u *EventUpdateOne) AppendAttendees(v []map[string]interface{}) *EventUpdateOne {
	_u.mutation.AppendAttendees(v)
	return _u
}

// ClearAttendees clears the value of the "attendees" field.
func (_u *EventUpdateOne) ClearAttendees() *EventUpdateOne {
	_u.mutation.ClearAttendees()
	return _u
}

// SetReminders sets the "reminders" field.
func (_u *EventUpdateOne) SetReminders(v []map[string]interface{}) *EventUpdateOne {
	_u.mutation.SetReminders(v)
	return _u
}

// AppendReminders appends value to the "reminders" field.
func (_u *EventUpdateOne) AppendReminders(v []map[string]interface{}) *EventUpdateOne {
	_u.mutation.AppendReminders(v)
	return _u
}

// ClearReminders clears the value of the "reminders" field.
func (_u *EventUpdateOne) ClearReminders() *EventUpdateOne {
	_u.mutation.ClearReminders()
	return _u
}

// SetCategories sets the "categories" field.
func (_u *EventUpdateOne) SetCategories(v []string) *EventUpdateOne {
	_u.mutation.SetCategories(v)
	return _u
}

// AppendCategories appends value to the "categories" field.
func (_u *EventUpdateOne) AppendCategories(v []string) *EventUpdateOne {
	_u.mutation.AppendCategories(v)
	return _u
}

// ClearCategories clears the value of the "categories" field.
func (_u *EventUpdateOne) ClearCategories() *EventUpdateOne {
	_u.mutation.ClearCategories()
	return _u
}

// SetTransparency sets the "transparency" field.
func (_u *EventUpdateOne) SetTransparency(v string) *EventUpdateOne {
	_u.mutation.SetTransparency(v)
	return _u
}

// SetNillableTransparency sets the "transparency" field if the given value is not nil.
func (_u *EventUpdateOne) SetNillableTransparency(v *string) *EventUpdateOne {
	if v != nil {
		_u.SetTransparency(*v)
	}
	return _u
}

// ClearTransparency clears the value of the "transparency" field.
func (_u *EventUpdateOne) ClearTransparency() *EventUpdateOne {
	_u.mutation.ClearTransparency()
	return _u
}

// SetVisibility sets the "visibility" field.
func (_u *EventUpdateOne) SetVisibility(v string) *EventUpdateOne {
	_u.mutation.SetVisibility(v)
	return _u
}

// SetNillableVisibility sets the "visibility" field if the given value is not nil.
func (_u *EventUpdateOne) SetNillableVisibility(v *string) *EventUpdateOne {
	if v != nil {
		_u.SetVisibility(*v)
	}
	return _u
}

// ClearVisibility clears the value of the "visibility" field.
func (_u *EventUpdateOne) ClearVisibility() *EventUpdateOne {
	_u.mutation.ClearVisibility()
	return _u
}

// SetRawIcs sets the "raw_ics" field.
func (_u *EventUpdateOne) SetRawIcs(v string) *EventUpdateOne {
	_u.mutation.SetRawIcs(v)
	return _u
}

// SetNillableRawIcs sets the "raw_ics" field if the given value is not nil.
func (_u *EventUpdateOne) SetNillableRawIcs(v *string) *EventUpdateOne {
	if v != nil {
		_u.SetRawIcs(*v)
	}
	return _u
}

// ClearRawIcs clears the value of the "raw_ics" field.
func (_u *EventUpdateOne) ClearRawIcs() *EventUpdateOne {
	_u.mutation.ClearRawIcs()
	return _u
}

// SetCreated sets the "created" field.
func (_u *EventUpdateOne) SetCreated(v time.Time) *EventUpdateOne {
	_u.mutation.SetCreated(v)
	return _u
}

// SetNillableCreated sets the "created" field if the given value is not nil.
func (_u *EventUpdateOne) SetNillableCreated(v *time.Time) *EventUpdateOne {
	if v != nil {
		_u.SetCreated(*v)
	}
	return _u
}

// SetUpdated sets the "updated" field.
func (_u *EventUpdateOne) SetUpdated(v time.Time) *EventUpdateOne {
	_u.mutation.SetUpdated(v)
	return _u
}

// SetCalendarID sets the "calendar" edge to the Calendar entity by ID.
func (_u *EventUpdateOne) SetCalendarID(id string) *EventUpdateOne {
	_u.mutation.SetCalendarID(id)
	return _u
}

// SetCalendar sets the "calendar" edge to the Calendar entity.
func (_u *EventUpdateOne) SetCalendar(v *Calendar) *EventUpdateOne {
	return _u.SetCalendarID(v.ID)
}

// Mutation returns the EventMutation object of the builder.
func (_u *EventUpdateOne) Mutation() *EventMutation {
	return _u.mutation
}

// ClearCalendar clears the "calendar" edge to the Calendar entity.
func (_u *EventUpdateOne) ClearCalendar() *EventUpdateOne {
	_u.mutation.ClearCalendar()
	return _u
}

// Where appends a list predicates to the EventUpdate builder.
func (_u *EventUpdateOne) Where(ps ...predicate.Event) *EventUpdateOne {
	_u.mutation.Where(ps...)
	return _u
}

// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (_u *EventUpdateOne) Select(field string, fields ...string) *EventUpdateOne {
	_u.fields = append([]string{field}, fields...)
	return _u
}

// Save executes the query and returns the updated Event entity.
func (_u *EventUpdateOne) Save(ctx context.Context) (*Event, error) {
	_u.defaults()
	return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}

// SaveX is like Save, but panics if an error occurs.
func (_u *EventUpdateOne) SaveX(ctx context.Context) *Event {
	node, err := _u.Save(ctx)
	if err != nil {
		panic(err)
	}
	return node
}

// Exec executes the query on the entity.
func (_u *EventUpdateOne) Exec(ctx context.Context) error {
	_, err := _u.Save(ctx)
	return err
}

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

// defaults sets the default values of the builder before save.
func (_u *EventUpdateOne) defaults() {
	if _, ok := _u.mutation.Updated(); !ok {
		v := event.UpdateDefaultUpdated()
		_u.mutation.SetUpdated(v)
	}
}

// check runs all checks and user-defined validators on the builder.
func (_u *EventUpdateOne) check() error {
	if v, ok := _u.mutation.UID(); ok {
		if err := event.UIDValidator(v); err != nil {
			return &ValidationError{Name: "uid", err: fmt.Errorf(`ent: validator failed for field "Event.uid": %w`, err)}
		}
	}
	if v, ok := _u.mutation.Status(); ok {
		if err := event.StatusValidator(v); err != nil {
			return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Event.status": %w`, err)}
		}
	}
	if _u.mutation.CalendarCleared() && len(_u.mutation.CalendarIDs()) > 0 {
		return errors.New(`ent: clearing a required unique edge "Event.calendar"`)
	}
	return nil
}

// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (_u *EventUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EventUpdateOne {
	_u.modifiers = append(_u.modifiers, modifiers...)
	return _u
}

func (_u *EventUpdateOne) sqlSave(ctx context.Context) (_node *Event, err error) {
	if err := _u.check(); err != nil {
		return _node, err
	}
	_spec := sqlgraph.NewUpdateSpec(event.Table, event.Columns, sqlgraph.NewFieldSpec(event.FieldID, field.TypeString))
	id, ok := _u.mutation.ID()
	if !ok {
		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Event.id" for update`)}
	}
	_spec.Node.ID.Value = id
	if fields := _u.fields; len(fields) > 0 {
		_spec.Node.Columns = make([]string, 0, len(fields))
		_spec.Node.Columns = append(_spec.Node.Columns, event.FieldID)
		for _, f := range fields {
			if !event.ValidColumn(f) {
				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
			}
			if f != event.FieldID {
				_spec.Node.Columns = append(_spec.Node.Columns, f)
			}
		}
	}
	if ps := _u.mutation.predicates; len(ps) > 0 {
		_spec.Predicate = func(selector *sql.Selector) {
			for i := range ps {
				ps[i](selector)
			}
		}
	}
	if value, ok := _u.mutation.UID(); ok {
		_spec.SetField(event.FieldUID, field.TypeString, value)
	}
	if value, ok := _u.mutation.RemoteID(); ok {
		_spec.SetField(event.FieldRemoteID, field.TypeString, value)
	}
	if _u.mutation.RemoteIDCleared() {
		_spec.ClearField(event.FieldRemoteID, field.TypeString)
	}
	if value, ok := _u.mutation.Etag(); ok {
		_spec.SetField(event.FieldEtag, field.TypeString, value)
	}
	if _u.mutation.EtagCleared() {
		_spec.ClearField(event.FieldEtag, field.TypeString)
	}
	if value, ok := _u.mutation.Summary(); ok {
		_spec.SetField(event.FieldSummary, field.TypeString, value)
	}
	if value, ok := _u.mutation.Description(); ok {
		_spec.SetField(event.FieldDescription, field.TypeString, value)
	}
	if _u.mutation.DescriptionCleared() {
		_spec.ClearField(event.FieldDescription, field.TypeString)
	}
	if value, ok := _u.mutation.Location(); ok {
		_spec.SetField(event.FieldLocation, field.TypeString, value)
	}
	if _u.mutation.LocationCleared() {
		_spec.ClearField(event.FieldLocation, field.TypeString)
	}
	if value, ok := _u.mutation.URL(); ok {
		_spec.SetField(event.FieldURL, field.TypeString, value)
	}
	if _u.mutation.URLCleared() {
		_spec.ClearField(event.FieldURL, field.TypeString)
	}
	if value, ok := _u.mutation.MeetingURL(); ok {
		_spec.SetField(event.FieldMeetingURL, field.TypeString, value)
	}
	if _u.mutation.MeetingURLCleared() {
		_spec.ClearField(event.FieldMeetingURL, field.TypeString)
	}
	if value, ok := _u.mutation.Status(); ok {
		_spec.SetField(event.FieldStatus, field.TypeEnum, value)
	}
	if value, ok := _u.mutation.Start(); ok {
		_spec.SetField(event.FieldStart, field.TypeTime, value)
	}
	if value, ok := _u.mutation.End(); ok {
		_spec.SetField(event.FieldEnd, field.TypeTime, value)
	}
	if value, ok := _u.mutation.AllDay(); ok {
		_spec.SetField(event.FieldAllDay, field.TypeBool, value)
	}
	if value, ok := _u.mutation.StartTz(); ok {
		_spec.SetField(event.FieldStartTz, field.TypeString, value)
	}
	if _u.mutation.StartTzCleared() {
		_spec.ClearField(event.FieldStartTz, field.TypeString)
	}
	if value, ok := _u.mutation.EndTz(); ok {
		_spec.SetField(event.FieldEndTz, field.TypeString, value)
	}
	if _u.mutation.EndTzCleared() {
		_spec.ClearField(event.FieldEndTz, field.TypeString)
	}
	if value, ok := _u.mutation.Recurrence(); ok {
		_spec.SetField(event.FieldRecurrence, field.TypeJSON, value)
	}
	if _u.mutation.RecurrenceCleared() {
		_spec.ClearField(event.FieldRecurrence, field.TypeJSON)
	}
	if value, ok := _u.mutation.RecurringID(); ok {
		_spec.SetField(event.FieldRecurringID, field.TypeString, value)
	}
	if _u.mutation.RecurringIDCleared() {
		_spec.ClearField(event.FieldRecurringID, field.TypeString)
	}
	if value, ok := _u.mutation.OriginalStart(); ok {
		_spec.SetField(event.FieldOriginalStart, field.TypeTime, value)
	}
	if _u.mutation.OriginalStartCleared() {
		_spec.ClearField(event.FieldOriginalStart, field.TypeTime)
	}
	if value, ok := _u.mutation.Organizer(); ok {
		_spec.SetField(event.FieldOrganizer, field.TypeJSON, value)
	}
	if _u.mutation.OrganizerCleared() {
		_spec.ClearField(event.FieldOrganizer, field.TypeJSON)
	}
	if value, ok := _u.mutation.Attendees(); ok {
		_spec.SetField(event.FieldAttendees, field.TypeJSON, value)
	}
	if value, ok := _u.mutation.AppendedAttendees(); ok {
		_spec.AddModifier(func(u *sql.UpdateBuilder) {
			sqljson.Append(u, event.FieldAttendees, value)
		})
	}
	if _u.mutation.AttendeesCleared() {
		_spec.ClearField(event.FieldAttendees, field.TypeJSON)
	}
	if value, ok := _u.mutation.Reminders(); ok {
		_spec.SetField(event.FieldReminders, field.TypeJSON, value)
	}
	if value, ok := _u.mutation.AppendedReminders(); ok {
		_spec.AddModifier(func(u *sql.UpdateBuilder) {
			sqljson.Append(u, event.FieldReminders, value)
		})
	}
	if _u.mutation.RemindersCleared() {
		_spec.ClearField(event.FieldReminders, field.TypeJSON)
	}
	if value, ok := _u.mutation.Categories(); ok {
		_spec.SetField(event.FieldCategories, field.TypeJSON, value)
	}
	if value, ok := _u.mutation.AppendedCategories(); ok {
		_spec.AddModifier(func(u *sql.UpdateBuilder) {
			sqljson.Append(u, event.FieldCategories, value)
		})
	}
	if _u.mutation.CategoriesCleared() {
		_spec.ClearField(event.FieldCategories, field.TypeJSON)
	}
	if value, ok := _u.mutation.Transparency(); ok {
		_spec.SetField(event.FieldTransparency, field.TypeString, value)
	}
	if _u.mutation.TransparencyCleared() {
		_spec.ClearField(event.FieldTransparency, field.TypeString)
	}
	if value, ok := _u.mutation.Visibility(); ok {
		_spec.SetField(event.FieldVisibility, field.TypeString, value)
	}
	if _u.mutation.VisibilityCleared() {
		_spec.ClearField(event.FieldVisibility, field.TypeString)
	}
	if value, ok := _u.mutation.RawIcs(); ok {
		_spec.SetField(event.FieldRawIcs, field.TypeString, value)
	}
	if _u.mutation.RawIcsCleared() {
		_spec.ClearField(event.FieldRawIcs, field.TypeString)
	}
	if value, ok := _u.mutation.Created(); ok {
		_spec.SetField(event.FieldCreated, field.TypeTime, value)
	}
	if value, ok := _u.mutation.Updated(); ok {
		_spec.SetField(event.FieldUpdated, field.TypeTime, value)
	}
	if _u.mutation.CalendarCleared() {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   event.CalendarTable,
			Columns: []string{event.CalendarColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(calendar.FieldID, field.TypeString),
			},
		}
		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
	}
	if nodes := _u.mutation.CalendarIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   event.CalendarTable,
			Columns: []string{event.CalendarColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(calendar.FieldID, field.TypeString),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges.Add = append(_spec.Edges.Add, edge)
	}
	_spec.AddModifiers(_u.modifiers...)
	_node = &Event{config: _u.config}
	_spec.Assign = _node.assignValues
	_spec.ScanValues = _node.scanValues
	if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
		if _, ok := err.(*sqlgraph.NotFoundError); ok {
			err = &NotFoundError{event.Label}
		} else if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	_u.mutation.done = true
	return _node, nil
}
