mirror of https://github.com/dexidp/dex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
630 lines
20 KiB
630 lines
20 KiB
|
3 days ago
|
// Code generated by ent, DO NOT EDIT.
|
||
|
|
|
||
|
|
package db
|
||
|
|
|
||
|
|
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/dexidp/dex/storage/ent/db/predicate"
|
||
|
|
"github.com/dexidp/dex/storage/ent/db/useridentity"
|
||
|
|
)
|
||
|
|
|
||
|
|
// UserIdentityUpdate is the builder for updating UserIdentity entities.
|
||
|
|
type UserIdentityUpdate struct {
|
||
|
|
config
|
||
|
|
hooks []Hook
|
||
|
|
mutation *UserIdentityMutation
|
||
|
|
}
|
||
|
|
|
||
|
|
// Where appends a list predicates to the UserIdentityUpdate builder.
|
||
|
|
func (_u *UserIdentityUpdate) Where(ps ...predicate.UserIdentity) *UserIdentityUpdate {
|
||
|
|
_u.mutation.Where(ps...)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetUserID sets the "user_id" field.
|
||
|
|
func (_u *UserIdentityUpdate) SetUserID(v string) *UserIdentityUpdate {
|
||
|
|
_u.mutation.SetUserID(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdate) SetNillableUserID(v *string) *UserIdentityUpdate {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetUserID(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetConnectorID sets the "connector_id" field.
|
||
|
|
func (_u *UserIdentityUpdate) SetConnectorID(v string) *UserIdentityUpdate {
|
||
|
|
_u.mutation.SetConnectorID(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableConnectorID sets the "connector_id" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdate) SetNillableConnectorID(v *string) *UserIdentityUpdate {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetConnectorID(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetClaimsUserID sets the "claims_user_id" field.
|
||
|
|
func (_u *UserIdentityUpdate) SetClaimsUserID(v string) *UserIdentityUpdate {
|
||
|
|
_u.mutation.SetClaimsUserID(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableClaimsUserID sets the "claims_user_id" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdate) SetNillableClaimsUserID(v *string) *UserIdentityUpdate {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetClaimsUserID(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetClaimsUsername sets the "claims_username" field.
|
||
|
|
func (_u *UserIdentityUpdate) SetClaimsUsername(v string) *UserIdentityUpdate {
|
||
|
|
_u.mutation.SetClaimsUsername(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableClaimsUsername sets the "claims_username" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdate) SetNillableClaimsUsername(v *string) *UserIdentityUpdate {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetClaimsUsername(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetClaimsPreferredUsername sets the "claims_preferred_username" field.
|
||
|
|
func (_u *UserIdentityUpdate) SetClaimsPreferredUsername(v string) *UserIdentityUpdate {
|
||
|
|
_u.mutation.SetClaimsPreferredUsername(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableClaimsPreferredUsername sets the "claims_preferred_username" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdate) SetNillableClaimsPreferredUsername(v *string) *UserIdentityUpdate {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetClaimsPreferredUsername(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetClaimsEmail sets the "claims_email" field.
|
||
|
|
func (_u *UserIdentityUpdate) SetClaimsEmail(v string) *UserIdentityUpdate {
|
||
|
|
_u.mutation.SetClaimsEmail(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableClaimsEmail sets the "claims_email" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdate) SetNillableClaimsEmail(v *string) *UserIdentityUpdate {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetClaimsEmail(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetClaimsEmailVerified sets the "claims_email_verified" field.
|
||
|
|
func (_u *UserIdentityUpdate) SetClaimsEmailVerified(v bool) *UserIdentityUpdate {
|
||
|
|
_u.mutation.SetClaimsEmailVerified(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableClaimsEmailVerified sets the "claims_email_verified" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdate) SetNillableClaimsEmailVerified(v *bool) *UserIdentityUpdate {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetClaimsEmailVerified(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetClaimsGroups sets the "claims_groups" field.
|
||
|
|
func (_u *UserIdentityUpdate) SetClaimsGroups(v []string) *UserIdentityUpdate {
|
||
|
|
_u.mutation.SetClaimsGroups(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// AppendClaimsGroups appends value to the "claims_groups" field.
|
||
|
|
func (_u *UserIdentityUpdate) AppendClaimsGroups(v []string) *UserIdentityUpdate {
|
||
|
|
_u.mutation.AppendClaimsGroups(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// ClearClaimsGroups clears the value of the "claims_groups" field.
|
||
|
|
func (_u *UserIdentityUpdate) ClearClaimsGroups() *UserIdentityUpdate {
|
||
|
|
_u.mutation.ClearClaimsGroups()
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetConsents sets the "consents" field.
|
||
|
|
func (_u *UserIdentityUpdate) SetConsents(v []byte) *UserIdentityUpdate {
|
||
|
|
_u.mutation.SetConsents(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetCreatedAt sets the "created_at" field.
|
||
|
|
func (_u *UserIdentityUpdate) SetCreatedAt(v time.Time) *UserIdentityUpdate {
|
||
|
|
_u.mutation.SetCreatedAt(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdate) SetNillableCreatedAt(v *time.Time) *UserIdentityUpdate {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetCreatedAt(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetLastLogin sets the "last_login" field.
|
||
|
|
func (_u *UserIdentityUpdate) SetLastLogin(v time.Time) *UserIdentityUpdate {
|
||
|
|
_u.mutation.SetLastLogin(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableLastLogin sets the "last_login" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdate) SetNillableLastLogin(v *time.Time) *UserIdentityUpdate {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetLastLogin(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetBlockedUntil sets the "blocked_until" field.
|
||
|
|
func (_u *UserIdentityUpdate) SetBlockedUntil(v time.Time) *UserIdentityUpdate {
|
||
|
|
_u.mutation.SetBlockedUntil(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableBlockedUntil sets the "blocked_until" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdate) SetNillableBlockedUntil(v *time.Time) *UserIdentityUpdate {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetBlockedUntil(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// Mutation returns the UserIdentityMutation object of the builder.
|
||
|
|
func (_u *UserIdentityUpdate) Mutation() *UserIdentityMutation {
|
||
|
|
return _u.mutation
|
||
|
|
}
|
||
|
|
|
||
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
||
|
|
func (_u *UserIdentityUpdate) Save(ctx context.Context) (int, error) {
|
||
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SaveX is like Save, but panics if an error occurs.
|
||
|
|
func (_u *UserIdentityUpdate) SaveX(ctx context.Context) int {
|
||
|
|
affected, err := _u.Save(ctx)
|
||
|
|
if err != nil {
|
||
|
|
panic(err)
|
||
|
|
}
|
||
|
|
return affected
|
||
|
|
}
|
||
|
|
|
||
|
|
// Exec executes the query.
|
||
|
|
func (_u *UserIdentityUpdate) Exec(ctx context.Context) error {
|
||
|
|
_, err := _u.Save(ctx)
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
// ExecX is like Exec, but panics if an error occurs.
|
||
|
|
func (_u *UserIdentityUpdate) ExecX(ctx context.Context) {
|
||
|
|
if err := _u.Exec(ctx); err != nil {
|
||
|
|
panic(err)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// check runs all checks and user-defined validators on the builder.
|
||
|
|
func (_u *UserIdentityUpdate) check() error {
|
||
|
|
if v, ok := _u.mutation.UserID(); ok {
|
||
|
|
if err := useridentity.UserIDValidator(v); err != nil {
|
||
|
|
return &ValidationError{Name: "user_id", err: fmt.Errorf(`db: validator failed for field "UserIdentity.user_id": %w`, err)}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if v, ok := _u.mutation.ConnectorID(); ok {
|
||
|
|
if err := useridentity.ConnectorIDValidator(v); err != nil {
|
||
|
|
return &ValidationError{Name: "connector_id", err: fmt.Errorf(`db: validator failed for field "UserIdentity.connector_id": %w`, err)}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (_u *UserIdentityUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||
|
|
if err := _u.check(); err != nil {
|
||
|
|
return _node, err
|
||
|
|
}
|
||
|
|
_spec := sqlgraph.NewUpdateSpec(useridentity.Table, useridentity.Columns, sqlgraph.NewFieldSpec(useridentity.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.UserID(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldUserID, field.TypeString, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.ConnectorID(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldConnectorID, field.TypeString, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.ClaimsUserID(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldClaimsUserID, field.TypeString, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.ClaimsUsername(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldClaimsUsername, field.TypeString, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.ClaimsPreferredUsername(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldClaimsPreferredUsername, field.TypeString, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.ClaimsEmail(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldClaimsEmail, field.TypeString, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.ClaimsEmailVerified(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldClaimsEmailVerified, field.TypeBool, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.ClaimsGroups(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldClaimsGroups, field.TypeJSON, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.AppendedClaimsGroups(); ok {
|
||
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
||
|
|
sqljson.Append(u, useridentity.FieldClaimsGroups, value)
|
||
|
|
})
|
||
|
|
}
|
||
|
|
if _u.mutation.ClaimsGroupsCleared() {
|
||
|
|
_spec.ClearField(useridentity.FieldClaimsGroups, field.TypeJSON)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.Consents(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldConsents, field.TypeBytes, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldCreatedAt, field.TypeTime, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.LastLogin(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldLastLogin, field.TypeTime, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.BlockedUntil(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldBlockedUntil, field.TypeTime, value)
|
||
|
|
}
|
||
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||
|
|
err = &NotFoundError{useridentity.Label}
|
||
|
|
} else if sqlgraph.IsConstraintError(err) {
|
||
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||
|
|
}
|
||
|
|
return 0, err
|
||
|
|
}
|
||
|
|
_u.mutation.done = true
|
||
|
|
return _node, nil
|
||
|
|
}
|
||
|
|
|
||
|
|
// UserIdentityUpdateOne is the builder for updating a single UserIdentity entity.
|
||
|
|
type UserIdentityUpdateOne struct {
|
||
|
|
config
|
||
|
|
fields []string
|
||
|
|
hooks []Hook
|
||
|
|
mutation *UserIdentityMutation
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetUserID sets the "user_id" field.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetUserID(v string) *UserIdentityUpdateOne {
|
||
|
|
_u.mutation.SetUserID(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetNillableUserID(v *string) *UserIdentityUpdateOne {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetUserID(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetConnectorID sets the "connector_id" field.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetConnectorID(v string) *UserIdentityUpdateOne {
|
||
|
|
_u.mutation.SetConnectorID(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableConnectorID sets the "connector_id" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetNillableConnectorID(v *string) *UserIdentityUpdateOne {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetConnectorID(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetClaimsUserID sets the "claims_user_id" field.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetClaimsUserID(v string) *UserIdentityUpdateOne {
|
||
|
|
_u.mutation.SetClaimsUserID(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableClaimsUserID sets the "claims_user_id" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetNillableClaimsUserID(v *string) *UserIdentityUpdateOne {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetClaimsUserID(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetClaimsUsername sets the "claims_username" field.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetClaimsUsername(v string) *UserIdentityUpdateOne {
|
||
|
|
_u.mutation.SetClaimsUsername(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableClaimsUsername sets the "claims_username" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetNillableClaimsUsername(v *string) *UserIdentityUpdateOne {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetClaimsUsername(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetClaimsPreferredUsername sets the "claims_preferred_username" field.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetClaimsPreferredUsername(v string) *UserIdentityUpdateOne {
|
||
|
|
_u.mutation.SetClaimsPreferredUsername(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableClaimsPreferredUsername sets the "claims_preferred_username" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetNillableClaimsPreferredUsername(v *string) *UserIdentityUpdateOne {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetClaimsPreferredUsername(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetClaimsEmail sets the "claims_email" field.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetClaimsEmail(v string) *UserIdentityUpdateOne {
|
||
|
|
_u.mutation.SetClaimsEmail(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableClaimsEmail sets the "claims_email" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetNillableClaimsEmail(v *string) *UserIdentityUpdateOne {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetClaimsEmail(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetClaimsEmailVerified sets the "claims_email_verified" field.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetClaimsEmailVerified(v bool) *UserIdentityUpdateOne {
|
||
|
|
_u.mutation.SetClaimsEmailVerified(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableClaimsEmailVerified sets the "claims_email_verified" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetNillableClaimsEmailVerified(v *bool) *UserIdentityUpdateOne {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetClaimsEmailVerified(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetClaimsGroups sets the "claims_groups" field.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetClaimsGroups(v []string) *UserIdentityUpdateOne {
|
||
|
|
_u.mutation.SetClaimsGroups(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// AppendClaimsGroups appends value to the "claims_groups" field.
|
||
|
|
func (_u *UserIdentityUpdateOne) AppendClaimsGroups(v []string) *UserIdentityUpdateOne {
|
||
|
|
_u.mutation.AppendClaimsGroups(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// ClearClaimsGroups clears the value of the "claims_groups" field.
|
||
|
|
func (_u *UserIdentityUpdateOne) ClearClaimsGroups() *UserIdentityUpdateOne {
|
||
|
|
_u.mutation.ClearClaimsGroups()
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetConsents sets the "consents" field.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetConsents(v []byte) *UserIdentityUpdateOne {
|
||
|
|
_u.mutation.SetConsents(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetCreatedAt sets the "created_at" field.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetCreatedAt(v time.Time) *UserIdentityUpdateOne {
|
||
|
|
_u.mutation.SetCreatedAt(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetNillableCreatedAt(v *time.Time) *UserIdentityUpdateOne {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetCreatedAt(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetLastLogin sets the "last_login" field.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetLastLogin(v time.Time) *UserIdentityUpdateOne {
|
||
|
|
_u.mutation.SetLastLogin(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableLastLogin sets the "last_login" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetNillableLastLogin(v *time.Time) *UserIdentityUpdateOne {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetLastLogin(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetBlockedUntil sets the "blocked_until" field.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetBlockedUntil(v time.Time) *UserIdentityUpdateOne {
|
||
|
|
_u.mutation.SetBlockedUntil(v)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNillableBlockedUntil sets the "blocked_until" field if the given value is not nil.
|
||
|
|
func (_u *UserIdentityUpdateOne) SetNillableBlockedUntil(v *time.Time) *UserIdentityUpdateOne {
|
||
|
|
if v != nil {
|
||
|
|
_u.SetBlockedUntil(*v)
|
||
|
|
}
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// Mutation returns the UserIdentityMutation object of the builder.
|
||
|
|
func (_u *UserIdentityUpdateOne) Mutation() *UserIdentityMutation {
|
||
|
|
return _u.mutation
|
||
|
|
}
|
||
|
|
|
||
|
|
// Where appends a list predicates to the UserIdentityUpdate builder.
|
||
|
|
func (_u *UserIdentityUpdateOne) Where(ps ...predicate.UserIdentity) *UserIdentityUpdateOne {
|
||
|
|
_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 *UserIdentityUpdateOne) Select(field string, fields ...string) *UserIdentityUpdateOne {
|
||
|
|
_u.fields = append([]string{field}, fields...)
|
||
|
|
return _u
|
||
|
|
}
|
||
|
|
|
||
|
|
// Save executes the query and returns the updated UserIdentity entity.
|
||
|
|
func (_u *UserIdentityUpdateOne) Save(ctx context.Context) (*UserIdentity, error) {
|
||
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SaveX is like Save, but panics if an error occurs.
|
||
|
|
func (_u *UserIdentityUpdateOne) SaveX(ctx context.Context) *UserIdentity {
|
||
|
|
node, err := _u.Save(ctx)
|
||
|
|
if err != nil {
|
||
|
|
panic(err)
|
||
|
|
}
|
||
|
|
return node
|
||
|
|
}
|
||
|
|
|
||
|
|
// Exec executes the query on the entity.
|
||
|
|
func (_u *UserIdentityUpdateOne) Exec(ctx context.Context) error {
|
||
|
|
_, err := _u.Save(ctx)
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
// ExecX is like Exec, but panics if an error occurs.
|
||
|
|
func (_u *UserIdentityUpdateOne) ExecX(ctx context.Context) {
|
||
|
|
if err := _u.Exec(ctx); err != nil {
|
||
|
|
panic(err)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// check runs all checks and user-defined validators on the builder.
|
||
|
|
func (_u *UserIdentityUpdateOne) check() error {
|
||
|
|
if v, ok := _u.mutation.UserID(); ok {
|
||
|
|
if err := useridentity.UserIDValidator(v); err != nil {
|
||
|
|
return &ValidationError{Name: "user_id", err: fmt.Errorf(`db: validator failed for field "UserIdentity.user_id": %w`, err)}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if v, ok := _u.mutation.ConnectorID(); ok {
|
||
|
|
if err := useridentity.ConnectorIDValidator(v); err != nil {
|
||
|
|
return &ValidationError{Name: "connector_id", err: fmt.Errorf(`db: validator failed for field "UserIdentity.connector_id": %w`, err)}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (_u *UserIdentityUpdateOne) sqlSave(ctx context.Context) (_node *UserIdentity, err error) {
|
||
|
|
if err := _u.check(); err != nil {
|
||
|
|
return _node, err
|
||
|
|
}
|
||
|
|
_spec := sqlgraph.NewUpdateSpec(useridentity.Table, useridentity.Columns, sqlgraph.NewFieldSpec(useridentity.FieldID, field.TypeString))
|
||
|
|
id, ok := _u.mutation.ID()
|
||
|
|
if !ok {
|
||
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "UserIdentity.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, useridentity.FieldID)
|
||
|
|
for _, f := range fields {
|
||
|
|
if !useridentity.ValidColumn(f) {
|
||
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)}
|
||
|
|
}
|
||
|
|
if f != useridentity.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.UserID(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldUserID, field.TypeString, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.ConnectorID(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldConnectorID, field.TypeString, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.ClaimsUserID(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldClaimsUserID, field.TypeString, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.ClaimsUsername(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldClaimsUsername, field.TypeString, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.ClaimsPreferredUsername(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldClaimsPreferredUsername, field.TypeString, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.ClaimsEmail(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldClaimsEmail, field.TypeString, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.ClaimsEmailVerified(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldClaimsEmailVerified, field.TypeBool, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.ClaimsGroups(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldClaimsGroups, field.TypeJSON, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.AppendedClaimsGroups(); ok {
|
||
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
||
|
|
sqljson.Append(u, useridentity.FieldClaimsGroups, value)
|
||
|
|
})
|
||
|
|
}
|
||
|
|
if _u.mutation.ClaimsGroupsCleared() {
|
||
|
|
_spec.ClearField(useridentity.FieldClaimsGroups, field.TypeJSON)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.Consents(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldConsents, field.TypeBytes, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldCreatedAt, field.TypeTime, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.LastLogin(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldLastLogin, field.TypeTime, value)
|
||
|
|
}
|
||
|
|
if value, ok := _u.mutation.BlockedUntil(); ok {
|
||
|
|
_spec.SetField(useridentity.FieldBlockedUntil, field.TypeTime, value)
|
||
|
|
}
|
||
|
|
_node = &UserIdentity{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{useridentity.Label}
|
||
|
|
} else if sqlgraph.IsConstraintError(err) {
|
||
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||
|
|
}
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
_u.mutation.done = true
|
||
|
|
return _node, nil
|
||
|
|
}
|