// Code generated by ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "schisandra-album-cloud-microservices/common/ent/predicate" "schisandra-album-cloud-microservices/common/ent/scaauthuser" "schisandra-album-cloud-microservices/common/ent/scaauthuserdevice" "schisandra-album-cloud-microservices/common/ent/scaauthusersocial" "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // ScaAuthUserUpdate is the builder for updating ScaAuthUser entities. type ScaAuthUserUpdate struct { config hooks []Hook mutation *ScaAuthUserMutation } // Where appends a list predicates to the ScaAuthUserUpdate builder. func (sauu *ScaAuthUserUpdate) Where(ps ...predicate.ScaAuthUser) *ScaAuthUserUpdate { sauu.mutation.Where(ps...) return sauu } // SetUID sets the "uid" field. func (sauu *ScaAuthUserUpdate) SetUID(s string) *ScaAuthUserUpdate { sauu.mutation.SetUID(s) return sauu } // SetNillableUID sets the "uid" field if the given value is not nil. func (sauu *ScaAuthUserUpdate) SetNillableUID(s *string) *ScaAuthUserUpdate { if s != nil { sauu.SetUID(*s) } return sauu } // SetUsername sets the "username" field. func (sauu *ScaAuthUserUpdate) SetUsername(s string) *ScaAuthUserUpdate { sauu.mutation.SetUsername(s) return sauu } // SetNillableUsername sets the "username" field if the given value is not nil. func (sauu *ScaAuthUserUpdate) SetNillableUsername(s *string) *ScaAuthUserUpdate { if s != nil { sauu.SetUsername(*s) } return sauu } // ClearUsername clears the value of the "username" field. func (sauu *ScaAuthUserUpdate) ClearUsername() *ScaAuthUserUpdate { sauu.mutation.ClearUsername() return sauu } // SetNickname sets the "nickname" field. func (sauu *ScaAuthUserUpdate) SetNickname(s string) *ScaAuthUserUpdate { sauu.mutation.SetNickname(s) return sauu } // SetNillableNickname sets the "nickname" field if the given value is not nil. func (sauu *ScaAuthUserUpdate) SetNillableNickname(s *string) *ScaAuthUserUpdate { if s != nil { sauu.SetNickname(*s) } return sauu } // ClearNickname clears the value of the "nickname" field. func (sauu *ScaAuthUserUpdate) ClearNickname() *ScaAuthUserUpdate { sauu.mutation.ClearNickname() return sauu } // SetEmail sets the "email" field. func (sauu *ScaAuthUserUpdate) SetEmail(s string) *ScaAuthUserUpdate { sauu.mutation.SetEmail(s) return sauu } // SetNillableEmail sets the "email" field if the given value is not nil. func (sauu *ScaAuthUserUpdate) SetNillableEmail(s *string) *ScaAuthUserUpdate { if s != nil { sauu.SetEmail(*s) } return sauu } // ClearEmail clears the value of the "email" field. func (sauu *ScaAuthUserUpdate) ClearEmail() *ScaAuthUserUpdate { sauu.mutation.ClearEmail() return sauu } // SetPhone sets the "phone" field. func (sauu *ScaAuthUserUpdate) SetPhone(s string) *ScaAuthUserUpdate { sauu.mutation.SetPhone(s) return sauu } // SetNillablePhone sets the "phone" field if the given value is not nil. func (sauu *ScaAuthUserUpdate) SetNillablePhone(s *string) *ScaAuthUserUpdate { if s != nil { sauu.SetPhone(*s) } return sauu } // ClearPhone clears the value of the "phone" field. func (sauu *ScaAuthUserUpdate) ClearPhone() *ScaAuthUserUpdate { sauu.mutation.ClearPhone() return sauu } // SetPassword sets the "password" field. func (sauu *ScaAuthUserUpdate) SetPassword(s string) *ScaAuthUserUpdate { sauu.mutation.SetPassword(s) return sauu } // SetNillablePassword sets the "password" field if the given value is not nil. func (sauu *ScaAuthUserUpdate) SetNillablePassword(s *string) *ScaAuthUserUpdate { if s != nil { sauu.SetPassword(*s) } return sauu } // ClearPassword clears the value of the "password" field. func (sauu *ScaAuthUserUpdate) ClearPassword() *ScaAuthUserUpdate { sauu.mutation.ClearPassword() return sauu } // SetGender sets the "gender" field. func (sauu *ScaAuthUserUpdate) SetGender(s string) *ScaAuthUserUpdate { sauu.mutation.SetGender(s) return sauu } // SetNillableGender sets the "gender" field if the given value is not nil. func (sauu *ScaAuthUserUpdate) SetNillableGender(s *string) *ScaAuthUserUpdate { if s != nil { sauu.SetGender(*s) } return sauu } // ClearGender clears the value of the "gender" field. func (sauu *ScaAuthUserUpdate) ClearGender() *ScaAuthUserUpdate { sauu.mutation.ClearGender() return sauu } // SetAvatar sets the "avatar" field. func (sauu *ScaAuthUserUpdate) SetAvatar(s string) *ScaAuthUserUpdate { sauu.mutation.SetAvatar(s) return sauu } // SetNillableAvatar sets the "avatar" field if the given value is not nil. func (sauu *ScaAuthUserUpdate) SetNillableAvatar(s *string) *ScaAuthUserUpdate { if s != nil { sauu.SetAvatar(*s) } return sauu } // ClearAvatar clears the value of the "avatar" field. func (sauu *ScaAuthUserUpdate) ClearAvatar() *ScaAuthUserUpdate { sauu.mutation.ClearAvatar() return sauu } // SetStatus sets the "status" field. func (sauu *ScaAuthUserUpdate) SetStatus(i int8) *ScaAuthUserUpdate { sauu.mutation.ResetStatus() sauu.mutation.SetStatus(i) return sauu } // SetNillableStatus sets the "status" field if the given value is not nil. func (sauu *ScaAuthUserUpdate) SetNillableStatus(i *int8) *ScaAuthUserUpdate { if i != nil { sauu.SetStatus(*i) } return sauu } // AddStatus adds i to the "status" field. func (sauu *ScaAuthUserUpdate) AddStatus(i int8) *ScaAuthUserUpdate { sauu.mutation.AddStatus(i) return sauu } // ClearStatus clears the value of the "status" field. func (sauu *ScaAuthUserUpdate) ClearStatus() *ScaAuthUserUpdate { sauu.mutation.ClearStatus() return sauu } // SetIntroduce sets the "introduce" field. func (sauu *ScaAuthUserUpdate) SetIntroduce(s string) *ScaAuthUserUpdate { sauu.mutation.SetIntroduce(s) return sauu } // SetNillableIntroduce sets the "introduce" field if the given value is not nil. func (sauu *ScaAuthUserUpdate) SetNillableIntroduce(s *string) *ScaAuthUserUpdate { if s != nil { sauu.SetIntroduce(*s) } return sauu } // ClearIntroduce clears the value of the "introduce" field. func (sauu *ScaAuthUserUpdate) ClearIntroduce() *ScaAuthUserUpdate { sauu.mutation.ClearIntroduce() return sauu } // SetUpdateAt sets the "update_at" field. func (sauu *ScaAuthUserUpdate) SetUpdateAt(t time.Time) *ScaAuthUserUpdate { sauu.mutation.SetUpdateAt(t) return sauu } // ClearUpdateAt clears the value of the "update_at" field. func (sauu *ScaAuthUserUpdate) ClearUpdateAt() *ScaAuthUserUpdate { sauu.mutation.ClearUpdateAt() return sauu } // SetDeleted sets the "deleted" field. func (sauu *ScaAuthUserUpdate) SetDeleted(i int8) *ScaAuthUserUpdate { sauu.mutation.ResetDeleted() sauu.mutation.SetDeleted(i) return sauu } // SetNillableDeleted sets the "deleted" field if the given value is not nil. func (sauu *ScaAuthUserUpdate) SetNillableDeleted(i *int8) *ScaAuthUserUpdate { if i != nil { sauu.SetDeleted(*i) } return sauu } // AddDeleted adds i to the "deleted" field. func (sauu *ScaAuthUserUpdate) AddDeleted(i int8) *ScaAuthUserUpdate { sauu.mutation.AddDeleted(i) return sauu } // SetBlog sets the "blog" field. func (sauu *ScaAuthUserUpdate) SetBlog(s string) *ScaAuthUserUpdate { sauu.mutation.SetBlog(s) return sauu } // SetNillableBlog sets the "blog" field if the given value is not nil. func (sauu *ScaAuthUserUpdate) SetNillableBlog(s *string) *ScaAuthUserUpdate { if s != nil { sauu.SetBlog(*s) } return sauu } // ClearBlog clears the value of the "blog" field. func (sauu *ScaAuthUserUpdate) ClearBlog() *ScaAuthUserUpdate { sauu.mutation.ClearBlog() return sauu } // SetLocation sets the "location" field. func (sauu *ScaAuthUserUpdate) SetLocation(s string) *ScaAuthUserUpdate { sauu.mutation.SetLocation(s) return sauu } // SetNillableLocation sets the "location" field if the given value is not nil. func (sauu *ScaAuthUserUpdate) SetNillableLocation(s *string) *ScaAuthUserUpdate { if s != nil { sauu.SetLocation(*s) } return sauu } // ClearLocation clears the value of the "location" field. func (sauu *ScaAuthUserUpdate) ClearLocation() *ScaAuthUserUpdate { sauu.mutation.ClearLocation() return sauu } // SetCompany sets the "company" field. func (sauu *ScaAuthUserUpdate) SetCompany(s string) *ScaAuthUserUpdate { sauu.mutation.SetCompany(s) return sauu } // SetNillableCompany sets the "company" field if the given value is not nil. func (sauu *ScaAuthUserUpdate) SetNillableCompany(s *string) *ScaAuthUserUpdate { if s != nil { sauu.SetCompany(*s) } return sauu } // ClearCompany clears the value of the "company" field. func (sauu *ScaAuthUserUpdate) ClearCompany() *ScaAuthUserUpdate { sauu.mutation.ClearCompany() return sauu } // AddScaAuthUserSocialIDs adds the "sca_auth_user_social" edge to the ScaAuthUserSocial entity by IDs. func (sauu *ScaAuthUserUpdate) AddScaAuthUserSocialIDs(ids ...int64) *ScaAuthUserUpdate { sauu.mutation.AddScaAuthUserSocialIDs(ids...) return sauu } // AddScaAuthUserSocial adds the "sca_auth_user_social" edges to the ScaAuthUserSocial entity. func (sauu *ScaAuthUserUpdate) AddScaAuthUserSocial(s ...*ScaAuthUserSocial) *ScaAuthUserUpdate { ids := make([]int64, len(s)) for i := range s { ids[i] = s[i].ID } return sauu.AddScaAuthUserSocialIDs(ids...) } // AddScaAuthUserDeviceIDs adds the "sca_auth_user_device" edge to the ScaAuthUserDevice entity by IDs. func (sauu *ScaAuthUserUpdate) AddScaAuthUserDeviceIDs(ids ...int64) *ScaAuthUserUpdate { sauu.mutation.AddScaAuthUserDeviceIDs(ids...) return sauu } // AddScaAuthUserDevice adds the "sca_auth_user_device" edges to the ScaAuthUserDevice entity. func (sauu *ScaAuthUserUpdate) AddScaAuthUserDevice(s ...*ScaAuthUserDevice) *ScaAuthUserUpdate { ids := make([]int64, len(s)) for i := range s { ids[i] = s[i].ID } return sauu.AddScaAuthUserDeviceIDs(ids...) } // Mutation returns the ScaAuthUserMutation object of the builder. func (sauu *ScaAuthUserUpdate) Mutation() *ScaAuthUserMutation { return sauu.mutation } // ClearScaAuthUserSocial clears all "sca_auth_user_social" edges to the ScaAuthUserSocial entity. func (sauu *ScaAuthUserUpdate) ClearScaAuthUserSocial() *ScaAuthUserUpdate { sauu.mutation.ClearScaAuthUserSocial() return sauu } // RemoveScaAuthUserSocialIDs removes the "sca_auth_user_social" edge to ScaAuthUserSocial entities by IDs. func (sauu *ScaAuthUserUpdate) RemoveScaAuthUserSocialIDs(ids ...int64) *ScaAuthUserUpdate { sauu.mutation.RemoveScaAuthUserSocialIDs(ids...) return sauu } // RemoveScaAuthUserSocial removes "sca_auth_user_social" edges to ScaAuthUserSocial entities. func (sauu *ScaAuthUserUpdate) RemoveScaAuthUserSocial(s ...*ScaAuthUserSocial) *ScaAuthUserUpdate { ids := make([]int64, len(s)) for i := range s { ids[i] = s[i].ID } return sauu.RemoveScaAuthUserSocialIDs(ids...) } // ClearScaAuthUserDevice clears all "sca_auth_user_device" edges to the ScaAuthUserDevice entity. func (sauu *ScaAuthUserUpdate) ClearScaAuthUserDevice() *ScaAuthUserUpdate { sauu.mutation.ClearScaAuthUserDevice() return sauu } // RemoveScaAuthUserDeviceIDs removes the "sca_auth_user_device" edge to ScaAuthUserDevice entities by IDs. func (sauu *ScaAuthUserUpdate) RemoveScaAuthUserDeviceIDs(ids ...int64) *ScaAuthUserUpdate { sauu.mutation.RemoveScaAuthUserDeviceIDs(ids...) return sauu } // RemoveScaAuthUserDevice removes "sca_auth_user_device" edges to ScaAuthUserDevice entities. func (sauu *ScaAuthUserUpdate) RemoveScaAuthUserDevice(s ...*ScaAuthUserDevice) *ScaAuthUserUpdate { ids := make([]int64, len(s)) for i := range s { ids[i] = s[i].ID } return sauu.RemoveScaAuthUserDeviceIDs(ids...) } // Save executes the query and returns the number of nodes affected by the update operation. func (sauu *ScaAuthUserUpdate) Save(ctx context.Context) (int, error) { sauu.defaults() return withHooks(ctx, sauu.sqlSave, sauu.mutation, sauu.hooks) } // SaveX is like Save, but panics if an error occurs. func (sauu *ScaAuthUserUpdate) SaveX(ctx context.Context) int { affected, err := sauu.Save(ctx) if err != nil { panic(err) } return affected } // Exec executes the query. func (sauu *ScaAuthUserUpdate) Exec(ctx context.Context) error { _, err := sauu.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (sauu *ScaAuthUserUpdate) ExecX(ctx context.Context) { if err := sauu.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. func (sauu *ScaAuthUserUpdate) defaults() { if _, ok := sauu.mutation.UpdateAt(); !ok && !sauu.mutation.UpdateAtCleared() { v := scaauthuser.UpdateDefaultUpdateAt() sauu.mutation.SetUpdateAt(v) } } // check runs all checks and user-defined validators on the builder. func (sauu *ScaAuthUserUpdate) check() error { if v, ok := sauu.mutation.UID(); ok { if err := scaauthuser.UIDValidator(v); err != nil { return &ValidationError{Name: "uid", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.uid": %w`, err)} } } if v, ok := sauu.mutation.Username(); ok { if err := scaauthuser.UsernameValidator(v); err != nil { return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.username": %w`, err)} } } if v, ok := sauu.mutation.Nickname(); ok { if err := scaauthuser.NicknameValidator(v); err != nil { return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.nickname": %w`, err)} } } if v, ok := sauu.mutation.Email(); ok { if err := scaauthuser.EmailValidator(v); err != nil { return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.email": %w`, err)} } } if v, ok := sauu.mutation.Phone(); ok { if err := scaauthuser.PhoneValidator(v); err != nil { return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.phone": %w`, err)} } } if v, ok := sauu.mutation.Password(); ok { if err := scaauthuser.PasswordValidator(v); err != nil { return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.password": %w`, err)} } } if v, ok := sauu.mutation.Gender(); ok { if err := scaauthuser.GenderValidator(v); err != nil { return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.gender": %w`, err)} } } if v, ok := sauu.mutation.Introduce(); ok { if err := scaauthuser.IntroduceValidator(v); err != nil { return &ValidationError{Name: "introduce", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.introduce": %w`, err)} } } if v, ok := sauu.mutation.Blog(); ok { if err := scaauthuser.BlogValidator(v); err != nil { return &ValidationError{Name: "blog", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.blog": %w`, err)} } } if v, ok := sauu.mutation.Location(); ok { if err := scaauthuser.LocationValidator(v); err != nil { return &ValidationError{Name: "location", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.location": %w`, err)} } } if v, ok := sauu.mutation.Company(); ok { if err := scaauthuser.CompanyValidator(v); err != nil { return &ValidationError{Name: "company", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.company": %w`, err)} } } return nil } func (sauu *ScaAuthUserUpdate) sqlSave(ctx context.Context) (n int, err error) { if err := sauu.check(); err != nil { return n, err } _spec := sqlgraph.NewUpdateSpec(scaauthuser.Table, scaauthuser.Columns, sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64)) if ps := sauu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if value, ok := sauu.mutation.UID(); ok { _spec.SetField(scaauthuser.FieldUID, field.TypeString, value) } if value, ok := sauu.mutation.Username(); ok { _spec.SetField(scaauthuser.FieldUsername, field.TypeString, value) } if sauu.mutation.UsernameCleared() { _spec.ClearField(scaauthuser.FieldUsername, field.TypeString) } if value, ok := sauu.mutation.Nickname(); ok { _spec.SetField(scaauthuser.FieldNickname, field.TypeString, value) } if sauu.mutation.NicknameCleared() { _spec.ClearField(scaauthuser.FieldNickname, field.TypeString) } if value, ok := sauu.mutation.Email(); ok { _spec.SetField(scaauthuser.FieldEmail, field.TypeString, value) } if sauu.mutation.EmailCleared() { _spec.ClearField(scaauthuser.FieldEmail, field.TypeString) } if value, ok := sauu.mutation.Phone(); ok { _spec.SetField(scaauthuser.FieldPhone, field.TypeString, value) } if sauu.mutation.PhoneCleared() { _spec.ClearField(scaauthuser.FieldPhone, field.TypeString) } if value, ok := sauu.mutation.Password(); ok { _spec.SetField(scaauthuser.FieldPassword, field.TypeString, value) } if sauu.mutation.PasswordCleared() { _spec.ClearField(scaauthuser.FieldPassword, field.TypeString) } if value, ok := sauu.mutation.Gender(); ok { _spec.SetField(scaauthuser.FieldGender, field.TypeString, value) } if sauu.mutation.GenderCleared() { _spec.ClearField(scaauthuser.FieldGender, field.TypeString) } if value, ok := sauu.mutation.Avatar(); ok { _spec.SetField(scaauthuser.FieldAvatar, field.TypeString, value) } if sauu.mutation.AvatarCleared() { _spec.ClearField(scaauthuser.FieldAvatar, field.TypeString) } if value, ok := sauu.mutation.Status(); ok { _spec.SetField(scaauthuser.FieldStatus, field.TypeInt8, value) } if value, ok := sauu.mutation.AddedStatus(); ok { _spec.AddField(scaauthuser.FieldStatus, field.TypeInt8, value) } if sauu.mutation.StatusCleared() { _spec.ClearField(scaauthuser.FieldStatus, field.TypeInt8) } if value, ok := sauu.mutation.Introduce(); ok { _spec.SetField(scaauthuser.FieldIntroduce, field.TypeString, value) } if sauu.mutation.IntroduceCleared() { _spec.ClearField(scaauthuser.FieldIntroduce, field.TypeString) } if value, ok := sauu.mutation.UpdateAt(); ok { _spec.SetField(scaauthuser.FieldUpdateAt, field.TypeTime, value) } if sauu.mutation.UpdateAtCleared() { _spec.ClearField(scaauthuser.FieldUpdateAt, field.TypeTime) } if value, ok := sauu.mutation.Deleted(); ok { _spec.SetField(scaauthuser.FieldDeleted, field.TypeInt8, value) } if value, ok := sauu.mutation.AddedDeleted(); ok { _spec.AddField(scaauthuser.FieldDeleted, field.TypeInt8, value) } if value, ok := sauu.mutation.Blog(); ok { _spec.SetField(scaauthuser.FieldBlog, field.TypeString, value) } if sauu.mutation.BlogCleared() { _spec.ClearField(scaauthuser.FieldBlog, field.TypeString) } if value, ok := sauu.mutation.Location(); ok { _spec.SetField(scaauthuser.FieldLocation, field.TypeString, value) } if sauu.mutation.LocationCleared() { _spec.ClearField(scaauthuser.FieldLocation, field.TypeString) } if value, ok := sauu.mutation.Company(); ok { _spec.SetField(scaauthuser.FieldCompany, field.TypeString, value) } if sauu.mutation.CompanyCleared() { _spec.ClearField(scaauthuser.FieldCompany, field.TypeString) } if sauu.mutation.ScaAuthUserSocialCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: scaauthuser.ScaAuthUserSocialTable, Columns: []string{scaauthuser.ScaAuthUserSocialColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := sauu.mutation.RemovedScaAuthUserSocialIDs(); len(nodes) > 0 && !sauu.mutation.ScaAuthUserSocialCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: scaauthuser.ScaAuthUserSocialTable, Columns: []string{scaauthuser.ScaAuthUserSocialColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := sauu.mutation.ScaAuthUserSocialIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: scaauthuser.ScaAuthUserSocialTable, Columns: []string{scaauthuser.ScaAuthUserSocialColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if sauu.mutation.ScaAuthUserDeviceCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: scaauthuser.ScaAuthUserDeviceTable, Columns: []string{scaauthuser.ScaAuthUserDeviceColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := sauu.mutation.RemovedScaAuthUserDeviceIDs(); len(nodes) > 0 && !sauu.mutation.ScaAuthUserDeviceCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: scaauthuser.ScaAuthUserDeviceTable, Columns: []string{scaauthuser.ScaAuthUserDeviceColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := sauu.mutation.ScaAuthUserDeviceIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: scaauthuser.ScaAuthUserDeviceTable, Columns: []string{scaauthuser.ScaAuthUserDeviceColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if n, err = sqlgraph.UpdateNodes(ctx, sauu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{scaauthuser.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return 0, err } sauu.mutation.done = true return n, nil } // ScaAuthUserUpdateOne is the builder for updating a single ScaAuthUser entity. type ScaAuthUserUpdateOne struct { config fields []string hooks []Hook mutation *ScaAuthUserMutation } // SetUID sets the "uid" field. func (sauuo *ScaAuthUserUpdateOne) SetUID(s string) *ScaAuthUserUpdateOne { sauuo.mutation.SetUID(s) return sauuo } // SetNillableUID sets the "uid" field if the given value is not nil. func (sauuo *ScaAuthUserUpdateOne) SetNillableUID(s *string) *ScaAuthUserUpdateOne { if s != nil { sauuo.SetUID(*s) } return sauuo } // SetUsername sets the "username" field. func (sauuo *ScaAuthUserUpdateOne) SetUsername(s string) *ScaAuthUserUpdateOne { sauuo.mutation.SetUsername(s) return sauuo } // SetNillableUsername sets the "username" field if the given value is not nil. func (sauuo *ScaAuthUserUpdateOne) SetNillableUsername(s *string) *ScaAuthUserUpdateOne { if s != nil { sauuo.SetUsername(*s) } return sauuo } // ClearUsername clears the value of the "username" field. func (sauuo *ScaAuthUserUpdateOne) ClearUsername() *ScaAuthUserUpdateOne { sauuo.mutation.ClearUsername() return sauuo } // SetNickname sets the "nickname" field. func (sauuo *ScaAuthUserUpdateOne) SetNickname(s string) *ScaAuthUserUpdateOne { sauuo.mutation.SetNickname(s) return sauuo } // SetNillableNickname sets the "nickname" field if the given value is not nil. func (sauuo *ScaAuthUserUpdateOne) SetNillableNickname(s *string) *ScaAuthUserUpdateOne { if s != nil { sauuo.SetNickname(*s) } return sauuo } // ClearNickname clears the value of the "nickname" field. func (sauuo *ScaAuthUserUpdateOne) ClearNickname() *ScaAuthUserUpdateOne { sauuo.mutation.ClearNickname() return sauuo } // SetEmail sets the "email" field. func (sauuo *ScaAuthUserUpdateOne) SetEmail(s string) *ScaAuthUserUpdateOne { sauuo.mutation.SetEmail(s) return sauuo } // SetNillableEmail sets the "email" field if the given value is not nil. func (sauuo *ScaAuthUserUpdateOne) SetNillableEmail(s *string) *ScaAuthUserUpdateOne { if s != nil { sauuo.SetEmail(*s) } return sauuo } // ClearEmail clears the value of the "email" field. func (sauuo *ScaAuthUserUpdateOne) ClearEmail() *ScaAuthUserUpdateOne { sauuo.mutation.ClearEmail() return sauuo } // SetPhone sets the "phone" field. func (sauuo *ScaAuthUserUpdateOne) SetPhone(s string) *ScaAuthUserUpdateOne { sauuo.mutation.SetPhone(s) return sauuo } // SetNillablePhone sets the "phone" field if the given value is not nil. func (sauuo *ScaAuthUserUpdateOne) SetNillablePhone(s *string) *ScaAuthUserUpdateOne { if s != nil { sauuo.SetPhone(*s) } return sauuo } // ClearPhone clears the value of the "phone" field. func (sauuo *ScaAuthUserUpdateOne) ClearPhone() *ScaAuthUserUpdateOne { sauuo.mutation.ClearPhone() return sauuo } // SetPassword sets the "password" field. func (sauuo *ScaAuthUserUpdateOne) SetPassword(s string) *ScaAuthUserUpdateOne { sauuo.mutation.SetPassword(s) return sauuo } // SetNillablePassword sets the "password" field if the given value is not nil. func (sauuo *ScaAuthUserUpdateOne) SetNillablePassword(s *string) *ScaAuthUserUpdateOne { if s != nil { sauuo.SetPassword(*s) } return sauuo } // ClearPassword clears the value of the "password" field. func (sauuo *ScaAuthUserUpdateOne) ClearPassword() *ScaAuthUserUpdateOne { sauuo.mutation.ClearPassword() return sauuo } // SetGender sets the "gender" field. func (sauuo *ScaAuthUserUpdateOne) SetGender(s string) *ScaAuthUserUpdateOne { sauuo.mutation.SetGender(s) return sauuo } // SetNillableGender sets the "gender" field if the given value is not nil. func (sauuo *ScaAuthUserUpdateOne) SetNillableGender(s *string) *ScaAuthUserUpdateOne { if s != nil { sauuo.SetGender(*s) } return sauuo } // ClearGender clears the value of the "gender" field. func (sauuo *ScaAuthUserUpdateOne) ClearGender() *ScaAuthUserUpdateOne { sauuo.mutation.ClearGender() return sauuo } // SetAvatar sets the "avatar" field. func (sauuo *ScaAuthUserUpdateOne) SetAvatar(s string) *ScaAuthUserUpdateOne { sauuo.mutation.SetAvatar(s) return sauuo } // SetNillableAvatar sets the "avatar" field if the given value is not nil. func (sauuo *ScaAuthUserUpdateOne) SetNillableAvatar(s *string) *ScaAuthUserUpdateOne { if s != nil { sauuo.SetAvatar(*s) } return sauuo } // ClearAvatar clears the value of the "avatar" field. func (sauuo *ScaAuthUserUpdateOne) ClearAvatar() *ScaAuthUserUpdateOne { sauuo.mutation.ClearAvatar() return sauuo } // SetStatus sets the "status" field. func (sauuo *ScaAuthUserUpdateOne) SetStatus(i int8) *ScaAuthUserUpdateOne { sauuo.mutation.ResetStatus() sauuo.mutation.SetStatus(i) return sauuo } // SetNillableStatus sets the "status" field if the given value is not nil. func (sauuo *ScaAuthUserUpdateOne) SetNillableStatus(i *int8) *ScaAuthUserUpdateOne { if i != nil { sauuo.SetStatus(*i) } return sauuo } // AddStatus adds i to the "status" field. func (sauuo *ScaAuthUserUpdateOne) AddStatus(i int8) *ScaAuthUserUpdateOne { sauuo.mutation.AddStatus(i) return sauuo } // ClearStatus clears the value of the "status" field. func (sauuo *ScaAuthUserUpdateOne) ClearStatus() *ScaAuthUserUpdateOne { sauuo.mutation.ClearStatus() return sauuo } // SetIntroduce sets the "introduce" field. func (sauuo *ScaAuthUserUpdateOne) SetIntroduce(s string) *ScaAuthUserUpdateOne { sauuo.mutation.SetIntroduce(s) return sauuo } // SetNillableIntroduce sets the "introduce" field if the given value is not nil. func (sauuo *ScaAuthUserUpdateOne) SetNillableIntroduce(s *string) *ScaAuthUserUpdateOne { if s != nil { sauuo.SetIntroduce(*s) } return sauuo } // ClearIntroduce clears the value of the "introduce" field. func (sauuo *ScaAuthUserUpdateOne) ClearIntroduce() *ScaAuthUserUpdateOne { sauuo.mutation.ClearIntroduce() return sauuo } // SetUpdateAt sets the "update_at" field. func (sauuo *ScaAuthUserUpdateOne) SetUpdateAt(t time.Time) *ScaAuthUserUpdateOne { sauuo.mutation.SetUpdateAt(t) return sauuo } // ClearUpdateAt clears the value of the "update_at" field. func (sauuo *ScaAuthUserUpdateOne) ClearUpdateAt() *ScaAuthUserUpdateOne { sauuo.mutation.ClearUpdateAt() return sauuo } // SetDeleted sets the "deleted" field. func (sauuo *ScaAuthUserUpdateOne) SetDeleted(i int8) *ScaAuthUserUpdateOne { sauuo.mutation.ResetDeleted() sauuo.mutation.SetDeleted(i) return sauuo } // SetNillableDeleted sets the "deleted" field if the given value is not nil. func (sauuo *ScaAuthUserUpdateOne) SetNillableDeleted(i *int8) *ScaAuthUserUpdateOne { if i != nil { sauuo.SetDeleted(*i) } return sauuo } // AddDeleted adds i to the "deleted" field. func (sauuo *ScaAuthUserUpdateOne) AddDeleted(i int8) *ScaAuthUserUpdateOne { sauuo.mutation.AddDeleted(i) return sauuo } // SetBlog sets the "blog" field. func (sauuo *ScaAuthUserUpdateOne) SetBlog(s string) *ScaAuthUserUpdateOne { sauuo.mutation.SetBlog(s) return sauuo } // SetNillableBlog sets the "blog" field if the given value is not nil. func (sauuo *ScaAuthUserUpdateOne) SetNillableBlog(s *string) *ScaAuthUserUpdateOne { if s != nil { sauuo.SetBlog(*s) } return sauuo } // ClearBlog clears the value of the "blog" field. func (sauuo *ScaAuthUserUpdateOne) ClearBlog() *ScaAuthUserUpdateOne { sauuo.mutation.ClearBlog() return sauuo } // SetLocation sets the "location" field. func (sauuo *ScaAuthUserUpdateOne) SetLocation(s string) *ScaAuthUserUpdateOne { sauuo.mutation.SetLocation(s) return sauuo } // SetNillableLocation sets the "location" field if the given value is not nil. func (sauuo *ScaAuthUserUpdateOne) SetNillableLocation(s *string) *ScaAuthUserUpdateOne { if s != nil { sauuo.SetLocation(*s) } return sauuo } // ClearLocation clears the value of the "location" field. func (sauuo *ScaAuthUserUpdateOne) ClearLocation() *ScaAuthUserUpdateOne { sauuo.mutation.ClearLocation() return sauuo } // SetCompany sets the "company" field. func (sauuo *ScaAuthUserUpdateOne) SetCompany(s string) *ScaAuthUserUpdateOne { sauuo.mutation.SetCompany(s) return sauuo } // SetNillableCompany sets the "company" field if the given value is not nil. func (sauuo *ScaAuthUserUpdateOne) SetNillableCompany(s *string) *ScaAuthUserUpdateOne { if s != nil { sauuo.SetCompany(*s) } return sauuo } // ClearCompany clears the value of the "company" field. func (sauuo *ScaAuthUserUpdateOne) ClearCompany() *ScaAuthUserUpdateOne { sauuo.mutation.ClearCompany() return sauuo } // AddScaAuthUserSocialIDs adds the "sca_auth_user_social" edge to the ScaAuthUserSocial entity by IDs. func (sauuo *ScaAuthUserUpdateOne) AddScaAuthUserSocialIDs(ids ...int64) *ScaAuthUserUpdateOne { sauuo.mutation.AddScaAuthUserSocialIDs(ids...) return sauuo } // AddScaAuthUserSocial adds the "sca_auth_user_social" edges to the ScaAuthUserSocial entity. func (sauuo *ScaAuthUserUpdateOne) AddScaAuthUserSocial(s ...*ScaAuthUserSocial) *ScaAuthUserUpdateOne { ids := make([]int64, len(s)) for i := range s { ids[i] = s[i].ID } return sauuo.AddScaAuthUserSocialIDs(ids...) } // AddScaAuthUserDeviceIDs adds the "sca_auth_user_device" edge to the ScaAuthUserDevice entity by IDs. func (sauuo *ScaAuthUserUpdateOne) AddScaAuthUserDeviceIDs(ids ...int64) *ScaAuthUserUpdateOne { sauuo.mutation.AddScaAuthUserDeviceIDs(ids...) return sauuo } // AddScaAuthUserDevice adds the "sca_auth_user_device" edges to the ScaAuthUserDevice entity. func (sauuo *ScaAuthUserUpdateOne) AddScaAuthUserDevice(s ...*ScaAuthUserDevice) *ScaAuthUserUpdateOne { ids := make([]int64, len(s)) for i := range s { ids[i] = s[i].ID } return sauuo.AddScaAuthUserDeviceIDs(ids...) } // Mutation returns the ScaAuthUserMutation object of the builder. func (sauuo *ScaAuthUserUpdateOne) Mutation() *ScaAuthUserMutation { return sauuo.mutation } // ClearScaAuthUserSocial clears all "sca_auth_user_social" edges to the ScaAuthUserSocial entity. func (sauuo *ScaAuthUserUpdateOne) ClearScaAuthUserSocial() *ScaAuthUserUpdateOne { sauuo.mutation.ClearScaAuthUserSocial() return sauuo } // RemoveScaAuthUserSocialIDs removes the "sca_auth_user_social" edge to ScaAuthUserSocial entities by IDs. func (sauuo *ScaAuthUserUpdateOne) RemoveScaAuthUserSocialIDs(ids ...int64) *ScaAuthUserUpdateOne { sauuo.mutation.RemoveScaAuthUserSocialIDs(ids...) return sauuo } // RemoveScaAuthUserSocial removes "sca_auth_user_social" edges to ScaAuthUserSocial entities. func (sauuo *ScaAuthUserUpdateOne) RemoveScaAuthUserSocial(s ...*ScaAuthUserSocial) *ScaAuthUserUpdateOne { ids := make([]int64, len(s)) for i := range s { ids[i] = s[i].ID } return sauuo.RemoveScaAuthUserSocialIDs(ids...) } // ClearScaAuthUserDevice clears all "sca_auth_user_device" edges to the ScaAuthUserDevice entity. func (sauuo *ScaAuthUserUpdateOne) ClearScaAuthUserDevice() *ScaAuthUserUpdateOne { sauuo.mutation.ClearScaAuthUserDevice() return sauuo } // RemoveScaAuthUserDeviceIDs removes the "sca_auth_user_device" edge to ScaAuthUserDevice entities by IDs. func (sauuo *ScaAuthUserUpdateOne) RemoveScaAuthUserDeviceIDs(ids ...int64) *ScaAuthUserUpdateOne { sauuo.mutation.RemoveScaAuthUserDeviceIDs(ids...) return sauuo } // RemoveScaAuthUserDevice removes "sca_auth_user_device" edges to ScaAuthUserDevice entities. func (sauuo *ScaAuthUserUpdateOne) RemoveScaAuthUserDevice(s ...*ScaAuthUserDevice) *ScaAuthUserUpdateOne { ids := make([]int64, len(s)) for i := range s { ids[i] = s[i].ID } return sauuo.RemoveScaAuthUserDeviceIDs(ids...) } // Where appends a list predicates to the ScaAuthUserUpdate builder. func (sauuo *ScaAuthUserUpdateOne) Where(ps ...predicate.ScaAuthUser) *ScaAuthUserUpdateOne { sauuo.mutation.Where(ps...) return sauuo } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. func (sauuo *ScaAuthUserUpdateOne) Select(field string, fields ...string) *ScaAuthUserUpdateOne { sauuo.fields = append([]string{field}, fields...) return sauuo } // Save executes the query and returns the updated ScaAuthUser entity. func (sauuo *ScaAuthUserUpdateOne) Save(ctx context.Context) (*ScaAuthUser, error) { sauuo.defaults() return withHooks(ctx, sauuo.sqlSave, sauuo.mutation, sauuo.hooks) } // SaveX is like Save, but panics if an error occurs. func (sauuo *ScaAuthUserUpdateOne) SaveX(ctx context.Context) *ScaAuthUser { node, err := sauuo.Save(ctx) if err != nil { panic(err) } return node } // Exec executes the query on the entity. func (sauuo *ScaAuthUserUpdateOne) Exec(ctx context.Context) error { _, err := sauuo.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (sauuo *ScaAuthUserUpdateOne) ExecX(ctx context.Context) { if err := sauuo.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. func (sauuo *ScaAuthUserUpdateOne) defaults() { if _, ok := sauuo.mutation.UpdateAt(); !ok && !sauuo.mutation.UpdateAtCleared() { v := scaauthuser.UpdateDefaultUpdateAt() sauuo.mutation.SetUpdateAt(v) } } // check runs all checks and user-defined validators on the builder. func (sauuo *ScaAuthUserUpdateOne) check() error { if v, ok := sauuo.mutation.UID(); ok { if err := scaauthuser.UIDValidator(v); err != nil { return &ValidationError{Name: "uid", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.uid": %w`, err)} } } if v, ok := sauuo.mutation.Username(); ok { if err := scaauthuser.UsernameValidator(v); err != nil { return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.username": %w`, err)} } } if v, ok := sauuo.mutation.Nickname(); ok { if err := scaauthuser.NicknameValidator(v); err != nil { return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.nickname": %w`, err)} } } if v, ok := sauuo.mutation.Email(); ok { if err := scaauthuser.EmailValidator(v); err != nil { return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.email": %w`, err)} } } if v, ok := sauuo.mutation.Phone(); ok { if err := scaauthuser.PhoneValidator(v); err != nil { return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.phone": %w`, err)} } } if v, ok := sauuo.mutation.Password(); ok { if err := scaauthuser.PasswordValidator(v); err != nil { return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.password": %w`, err)} } } if v, ok := sauuo.mutation.Gender(); ok { if err := scaauthuser.GenderValidator(v); err != nil { return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.gender": %w`, err)} } } if v, ok := sauuo.mutation.Introduce(); ok { if err := scaauthuser.IntroduceValidator(v); err != nil { return &ValidationError{Name: "introduce", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.introduce": %w`, err)} } } if v, ok := sauuo.mutation.Blog(); ok { if err := scaauthuser.BlogValidator(v); err != nil { return &ValidationError{Name: "blog", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.blog": %w`, err)} } } if v, ok := sauuo.mutation.Location(); ok { if err := scaauthuser.LocationValidator(v); err != nil { return &ValidationError{Name: "location", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.location": %w`, err)} } } if v, ok := sauuo.mutation.Company(); ok { if err := scaauthuser.CompanyValidator(v); err != nil { return &ValidationError{Name: "company", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.company": %w`, err)} } } return nil } func (sauuo *ScaAuthUserUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthUser, err error) { if err := sauuo.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(scaauthuser.Table, scaauthuser.Columns, sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64)) id, ok := sauuo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ScaAuthUser.id" for update`)} } _spec.Node.ID.Value = id if fields := sauuo.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, scaauthuser.FieldID) for _, f := range fields { if !scaauthuser.ValidColumn(f) { return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } if f != scaauthuser.FieldID { _spec.Node.Columns = append(_spec.Node.Columns, f) } } } if ps := sauuo.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if value, ok := sauuo.mutation.UID(); ok { _spec.SetField(scaauthuser.FieldUID, field.TypeString, value) } if value, ok := sauuo.mutation.Username(); ok { _spec.SetField(scaauthuser.FieldUsername, field.TypeString, value) } if sauuo.mutation.UsernameCleared() { _spec.ClearField(scaauthuser.FieldUsername, field.TypeString) } if value, ok := sauuo.mutation.Nickname(); ok { _spec.SetField(scaauthuser.FieldNickname, field.TypeString, value) } if sauuo.mutation.NicknameCleared() { _spec.ClearField(scaauthuser.FieldNickname, field.TypeString) } if value, ok := sauuo.mutation.Email(); ok { _spec.SetField(scaauthuser.FieldEmail, field.TypeString, value) } if sauuo.mutation.EmailCleared() { _spec.ClearField(scaauthuser.FieldEmail, field.TypeString) } if value, ok := sauuo.mutation.Phone(); ok { _spec.SetField(scaauthuser.FieldPhone, field.TypeString, value) } if sauuo.mutation.PhoneCleared() { _spec.ClearField(scaauthuser.FieldPhone, field.TypeString) } if value, ok := sauuo.mutation.Password(); ok { _spec.SetField(scaauthuser.FieldPassword, field.TypeString, value) } if sauuo.mutation.PasswordCleared() { _spec.ClearField(scaauthuser.FieldPassword, field.TypeString) } if value, ok := sauuo.mutation.Gender(); ok { _spec.SetField(scaauthuser.FieldGender, field.TypeString, value) } if sauuo.mutation.GenderCleared() { _spec.ClearField(scaauthuser.FieldGender, field.TypeString) } if value, ok := sauuo.mutation.Avatar(); ok { _spec.SetField(scaauthuser.FieldAvatar, field.TypeString, value) } if sauuo.mutation.AvatarCleared() { _spec.ClearField(scaauthuser.FieldAvatar, field.TypeString) } if value, ok := sauuo.mutation.Status(); ok { _spec.SetField(scaauthuser.FieldStatus, field.TypeInt8, value) } if value, ok := sauuo.mutation.AddedStatus(); ok { _spec.AddField(scaauthuser.FieldStatus, field.TypeInt8, value) } if sauuo.mutation.StatusCleared() { _spec.ClearField(scaauthuser.FieldStatus, field.TypeInt8) } if value, ok := sauuo.mutation.Introduce(); ok { _spec.SetField(scaauthuser.FieldIntroduce, field.TypeString, value) } if sauuo.mutation.IntroduceCleared() { _spec.ClearField(scaauthuser.FieldIntroduce, field.TypeString) } if value, ok := sauuo.mutation.UpdateAt(); ok { _spec.SetField(scaauthuser.FieldUpdateAt, field.TypeTime, value) } if sauuo.mutation.UpdateAtCleared() { _spec.ClearField(scaauthuser.FieldUpdateAt, field.TypeTime) } if value, ok := sauuo.mutation.Deleted(); ok { _spec.SetField(scaauthuser.FieldDeleted, field.TypeInt8, value) } if value, ok := sauuo.mutation.AddedDeleted(); ok { _spec.AddField(scaauthuser.FieldDeleted, field.TypeInt8, value) } if value, ok := sauuo.mutation.Blog(); ok { _spec.SetField(scaauthuser.FieldBlog, field.TypeString, value) } if sauuo.mutation.BlogCleared() { _spec.ClearField(scaauthuser.FieldBlog, field.TypeString) } if value, ok := sauuo.mutation.Location(); ok { _spec.SetField(scaauthuser.FieldLocation, field.TypeString, value) } if sauuo.mutation.LocationCleared() { _spec.ClearField(scaauthuser.FieldLocation, field.TypeString) } if value, ok := sauuo.mutation.Company(); ok { _spec.SetField(scaauthuser.FieldCompany, field.TypeString, value) } if sauuo.mutation.CompanyCleared() { _spec.ClearField(scaauthuser.FieldCompany, field.TypeString) } if sauuo.mutation.ScaAuthUserSocialCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: scaauthuser.ScaAuthUserSocialTable, Columns: []string{scaauthuser.ScaAuthUserSocialColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := sauuo.mutation.RemovedScaAuthUserSocialIDs(); len(nodes) > 0 && !sauuo.mutation.ScaAuthUserSocialCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: scaauthuser.ScaAuthUserSocialTable, Columns: []string{scaauthuser.ScaAuthUserSocialColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := sauuo.mutation.ScaAuthUserSocialIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: scaauthuser.ScaAuthUserSocialTable, Columns: []string{scaauthuser.ScaAuthUserSocialColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if sauuo.mutation.ScaAuthUserDeviceCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: scaauthuser.ScaAuthUserDeviceTable, Columns: []string{scaauthuser.ScaAuthUserDeviceColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := sauuo.mutation.RemovedScaAuthUserDeviceIDs(); len(nodes) > 0 && !sauuo.mutation.ScaAuthUserDeviceCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: scaauthuser.ScaAuthUserDeviceTable, Columns: []string{scaauthuser.ScaAuthUserDeviceColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := sauuo.mutation.ScaAuthUserDeviceIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: scaauthuser.ScaAuthUserDeviceTable, Columns: []string{scaauthuser.ScaAuthUserDeviceColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } _node = &ScaAuthUser{config: sauuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues if err = sqlgraph.UpdateNode(ctx, sauuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{scaauthuser.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return nil, err } sauuo.mutation.done = true return _node, nil }