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.
823 lines
26 KiB
823 lines
26 KiB
// 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/authcode" |
|
"github.com/dexidp/dex/storage/ent/db/predicate" |
|
) |
|
|
|
// AuthCodeUpdate is the builder for updating AuthCode entities. |
|
type AuthCodeUpdate struct { |
|
config |
|
hooks []Hook |
|
mutation *AuthCodeMutation |
|
} |
|
|
|
// Where appends a list predicates to the AuthCodeUpdate builder. |
|
func (_u *AuthCodeUpdate) Where(ps ...predicate.AuthCode) *AuthCodeUpdate { |
|
_u.mutation.Where(ps...) |
|
return _u |
|
} |
|
|
|
// SetClientID sets the "client_id" field. |
|
func (_u *AuthCodeUpdate) SetClientID(v string) *AuthCodeUpdate { |
|
_u.mutation.SetClientID(v) |
|
return _u |
|
} |
|
|
|
// SetNillableClientID sets the "client_id" field if the given value is not nil. |
|
func (_u *AuthCodeUpdate) SetNillableClientID(v *string) *AuthCodeUpdate { |
|
if v != nil { |
|
_u.SetClientID(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetScopes sets the "scopes" field. |
|
func (_u *AuthCodeUpdate) SetScopes(v []string) *AuthCodeUpdate { |
|
_u.mutation.SetScopes(v) |
|
return _u |
|
} |
|
|
|
// AppendScopes appends value to the "scopes" field. |
|
func (_u *AuthCodeUpdate) AppendScopes(v []string) *AuthCodeUpdate { |
|
_u.mutation.AppendScopes(v) |
|
return _u |
|
} |
|
|
|
// ClearScopes clears the value of the "scopes" field. |
|
func (_u *AuthCodeUpdate) ClearScopes() *AuthCodeUpdate { |
|
_u.mutation.ClearScopes() |
|
return _u |
|
} |
|
|
|
// SetNonce sets the "nonce" field. |
|
func (_u *AuthCodeUpdate) SetNonce(v string) *AuthCodeUpdate { |
|
_u.mutation.SetNonce(v) |
|
return _u |
|
} |
|
|
|
// SetNillableNonce sets the "nonce" field if the given value is not nil. |
|
func (_u *AuthCodeUpdate) SetNillableNonce(v *string) *AuthCodeUpdate { |
|
if v != nil { |
|
_u.SetNonce(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetRedirectURI sets the "redirect_uri" field. |
|
func (_u *AuthCodeUpdate) SetRedirectURI(v string) *AuthCodeUpdate { |
|
_u.mutation.SetRedirectURI(v) |
|
return _u |
|
} |
|
|
|
// SetNillableRedirectURI sets the "redirect_uri" field if the given value is not nil. |
|
func (_u *AuthCodeUpdate) SetNillableRedirectURI(v *string) *AuthCodeUpdate { |
|
if v != nil { |
|
_u.SetRedirectURI(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetClaimsUserID sets the "claims_user_id" field. |
|
func (_u *AuthCodeUpdate) SetClaimsUserID(v string) *AuthCodeUpdate { |
|
_u.mutation.SetClaimsUserID(v) |
|
return _u |
|
} |
|
|
|
// SetNillableClaimsUserID sets the "claims_user_id" field if the given value is not nil. |
|
func (_u *AuthCodeUpdate) SetNillableClaimsUserID(v *string) *AuthCodeUpdate { |
|
if v != nil { |
|
_u.SetClaimsUserID(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetClaimsUsername sets the "claims_username" field. |
|
func (_u *AuthCodeUpdate) SetClaimsUsername(v string) *AuthCodeUpdate { |
|
_u.mutation.SetClaimsUsername(v) |
|
return _u |
|
} |
|
|
|
// SetNillableClaimsUsername sets the "claims_username" field if the given value is not nil. |
|
func (_u *AuthCodeUpdate) SetNillableClaimsUsername(v *string) *AuthCodeUpdate { |
|
if v != nil { |
|
_u.SetClaimsUsername(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetClaimsEmail sets the "claims_email" field. |
|
func (_u *AuthCodeUpdate) SetClaimsEmail(v string) *AuthCodeUpdate { |
|
_u.mutation.SetClaimsEmail(v) |
|
return _u |
|
} |
|
|
|
// SetNillableClaimsEmail sets the "claims_email" field if the given value is not nil. |
|
func (_u *AuthCodeUpdate) SetNillableClaimsEmail(v *string) *AuthCodeUpdate { |
|
if v != nil { |
|
_u.SetClaimsEmail(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetClaimsEmailVerified sets the "claims_email_verified" field. |
|
func (_u *AuthCodeUpdate) SetClaimsEmailVerified(v bool) *AuthCodeUpdate { |
|
_u.mutation.SetClaimsEmailVerified(v) |
|
return _u |
|
} |
|
|
|
// SetNillableClaimsEmailVerified sets the "claims_email_verified" field if the given value is not nil. |
|
func (_u *AuthCodeUpdate) SetNillableClaimsEmailVerified(v *bool) *AuthCodeUpdate { |
|
if v != nil { |
|
_u.SetClaimsEmailVerified(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetClaimsGroups sets the "claims_groups" field. |
|
func (_u *AuthCodeUpdate) SetClaimsGroups(v []string) *AuthCodeUpdate { |
|
_u.mutation.SetClaimsGroups(v) |
|
return _u |
|
} |
|
|
|
// AppendClaimsGroups appends value to the "claims_groups" field. |
|
func (_u *AuthCodeUpdate) AppendClaimsGroups(v []string) *AuthCodeUpdate { |
|
_u.mutation.AppendClaimsGroups(v) |
|
return _u |
|
} |
|
|
|
// ClearClaimsGroups clears the value of the "claims_groups" field. |
|
func (_u *AuthCodeUpdate) ClearClaimsGroups() *AuthCodeUpdate { |
|
_u.mutation.ClearClaimsGroups() |
|
return _u |
|
} |
|
|
|
// SetClaimsPreferredUsername sets the "claims_preferred_username" field. |
|
func (_u *AuthCodeUpdate) SetClaimsPreferredUsername(v string) *AuthCodeUpdate { |
|
_u.mutation.SetClaimsPreferredUsername(v) |
|
return _u |
|
} |
|
|
|
// SetNillableClaimsPreferredUsername sets the "claims_preferred_username" field if the given value is not nil. |
|
func (_u *AuthCodeUpdate) SetNillableClaimsPreferredUsername(v *string) *AuthCodeUpdate { |
|
if v != nil { |
|
_u.SetClaimsPreferredUsername(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetConnectorID sets the "connector_id" field. |
|
func (_u *AuthCodeUpdate) SetConnectorID(v string) *AuthCodeUpdate { |
|
_u.mutation.SetConnectorID(v) |
|
return _u |
|
} |
|
|
|
// SetNillableConnectorID sets the "connector_id" field if the given value is not nil. |
|
func (_u *AuthCodeUpdate) SetNillableConnectorID(v *string) *AuthCodeUpdate { |
|
if v != nil { |
|
_u.SetConnectorID(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetConnectorData sets the "connector_data" field. |
|
func (_u *AuthCodeUpdate) SetConnectorData(v []byte) *AuthCodeUpdate { |
|
_u.mutation.SetConnectorData(v) |
|
return _u |
|
} |
|
|
|
// ClearConnectorData clears the value of the "connector_data" field. |
|
func (_u *AuthCodeUpdate) ClearConnectorData() *AuthCodeUpdate { |
|
_u.mutation.ClearConnectorData() |
|
return _u |
|
} |
|
|
|
// SetExpiry sets the "expiry" field. |
|
func (_u *AuthCodeUpdate) SetExpiry(v time.Time) *AuthCodeUpdate { |
|
_u.mutation.SetExpiry(v) |
|
return _u |
|
} |
|
|
|
// SetNillableExpiry sets the "expiry" field if the given value is not nil. |
|
func (_u *AuthCodeUpdate) SetNillableExpiry(v *time.Time) *AuthCodeUpdate { |
|
if v != nil { |
|
_u.SetExpiry(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetCodeChallenge sets the "code_challenge" field. |
|
func (_u *AuthCodeUpdate) SetCodeChallenge(v string) *AuthCodeUpdate { |
|
_u.mutation.SetCodeChallenge(v) |
|
return _u |
|
} |
|
|
|
// SetNillableCodeChallenge sets the "code_challenge" field if the given value is not nil. |
|
func (_u *AuthCodeUpdate) SetNillableCodeChallenge(v *string) *AuthCodeUpdate { |
|
if v != nil { |
|
_u.SetCodeChallenge(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetCodeChallengeMethod sets the "code_challenge_method" field. |
|
func (_u *AuthCodeUpdate) SetCodeChallengeMethod(v string) *AuthCodeUpdate { |
|
_u.mutation.SetCodeChallengeMethod(v) |
|
return _u |
|
} |
|
|
|
// SetNillableCodeChallengeMethod sets the "code_challenge_method" field if the given value is not nil. |
|
func (_u *AuthCodeUpdate) SetNillableCodeChallengeMethod(v *string) *AuthCodeUpdate { |
|
if v != nil { |
|
_u.SetCodeChallengeMethod(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// Mutation returns the AuthCodeMutation object of the builder. |
|
func (_u *AuthCodeUpdate) Mutation() *AuthCodeMutation { |
|
return _u.mutation |
|
} |
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation. |
|
func (_u *AuthCodeUpdate) 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 *AuthCodeUpdate) SaveX(ctx context.Context) int { |
|
affected, err := _u.Save(ctx) |
|
if err != nil { |
|
panic(err) |
|
} |
|
return affected |
|
} |
|
|
|
// Exec executes the query. |
|
func (_u *AuthCodeUpdate) Exec(ctx context.Context) error { |
|
_, err := _u.Save(ctx) |
|
return err |
|
} |
|
|
|
// ExecX is like Exec, but panics if an error occurs. |
|
func (_u *AuthCodeUpdate) 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 *AuthCodeUpdate) check() error { |
|
if v, ok := _u.mutation.ClientID(); ok { |
|
if err := authcode.ClientIDValidator(v); err != nil { |
|
return &ValidationError{Name: "client_id", err: fmt.Errorf(`db: validator failed for field "AuthCode.client_id": %w`, err)} |
|
} |
|
} |
|
if v, ok := _u.mutation.Nonce(); ok { |
|
if err := authcode.NonceValidator(v); err != nil { |
|
return &ValidationError{Name: "nonce", err: fmt.Errorf(`db: validator failed for field "AuthCode.nonce": %w`, err)} |
|
} |
|
} |
|
if v, ok := _u.mutation.RedirectURI(); ok { |
|
if err := authcode.RedirectURIValidator(v); err != nil { |
|
return &ValidationError{Name: "redirect_uri", err: fmt.Errorf(`db: validator failed for field "AuthCode.redirect_uri": %w`, err)} |
|
} |
|
} |
|
if v, ok := _u.mutation.ClaimsUserID(); ok { |
|
if err := authcode.ClaimsUserIDValidator(v); err != nil { |
|
return &ValidationError{Name: "claims_user_id", err: fmt.Errorf(`db: validator failed for field "AuthCode.claims_user_id": %w`, err)} |
|
} |
|
} |
|
if v, ok := _u.mutation.ClaimsUsername(); ok { |
|
if err := authcode.ClaimsUsernameValidator(v); err != nil { |
|
return &ValidationError{Name: "claims_username", err: fmt.Errorf(`db: validator failed for field "AuthCode.claims_username": %w`, err)} |
|
} |
|
} |
|
if v, ok := _u.mutation.ClaimsEmail(); ok { |
|
if err := authcode.ClaimsEmailValidator(v); err != nil { |
|
return &ValidationError{Name: "claims_email", err: fmt.Errorf(`db: validator failed for field "AuthCode.claims_email": %w`, err)} |
|
} |
|
} |
|
if v, ok := _u.mutation.ConnectorID(); ok { |
|
if err := authcode.ConnectorIDValidator(v); err != nil { |
|
return &ValidationError{Name: "connector_id", err: fmt.Errorf(`db: validator failed for field "AuthCode.connector_id": %w`, err)} |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
func (_u *AuthCodeUpdate) sqlSave(ctx context.Context) (_node int, err error) { |
|
if err := _u.check(); err != nil { |
|
return _node, err |
|
} |
|
_spec := sqlgraph.NewUpdateSpec(authcode.Table, authcode.Columns, sqlgraph.NewFieldSpec(authcode.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.ClientID(); ok { |
|
_spec.SetField(authcode.FieldClientID, field.TypeString, value) |
|
} |
|
if value, ok := _u.mutation.Scopes(); ok { |
|
_spec.SetField(authcode.FieldScopes, field.TypeJSON, value) |
|
} |
|
if value, ok := _u.mutation.AppendedScopes(); ok { |
|
_spec.AddModifier(func(u *sql.UpdateBuilder) { |
|
sqljson.Append(u, authcode.FieldScopes, value) |
|
}) |
|
} |
|
if _u.mutation.ScopesCleared() { |
|
_spec.ClearField(authcode.FieldScopes, field.TypeJSON) |
|
} |
|
if value, ok := _u.mutation.Nonce(); ok { |
|
_spec.SetField(authcode.FieldNonce, field.TypeString, value) |
|
} |
|
if value, ok := _u.mutation.RedirectURI(); ok { |
|
_spec.SetField(authcode.FieldRedirectURI, field.TypeString, value) |
|
} |
|
if value, ok := _u.mutation.ClaimsUserID(); ok { |
|
_spec.SetField(authcode.FieldClaimsUserID, field.TypeString, value) |
|
} |
|
if value, ok := _u.mutation.ClaimsUsername(); ok { |
|
_spec.SetField(authcode.FieldClaimsUsername, field.TypeString, value) |
|
} |
|
if value, ok := _u.mutation.ClaimsEmail(); ok { |
|
_spec.SetField(authcode.FieldClaimsEmail, field.TypeString, value) |
|
} |
|
if value, ok := _u.mutation.ClaimsEmailVerified(); ok { |
|
_spec.SetField(authcode.FieldClaimsEmailVerified, field.TypeBool, value) |
|
} |
|
if value, ok := _u.mutation.ClaimsGroups(); ok { |
|
_spec.SetField(authcode.FieldClaimsGroups, field.TypeJSON, value) |
|
} |
|
if value, ok := _u.mutation.AppendedClaimsGroups(); ok { |
|
_spec.AddModifier(func(u *sql.UpdateBuilder) { |
|
sqljson.Append(u, authcode.FieldClaimsGroups, value) |
|
}) |
|
} |
|
if _u.mutation.ClaimsGroupsCleared() { |
|
_spec.ClearField(authcode.FieldClaimsGroups, field.TypeJSON) |
|
} |
|
if value, ok := _u.mutation.ClaimsPreferredUsername(); ok { |
|
_spec.SetField(authcode.FieldClaimsPreferredUsername, field.TypeString, value) |
|
} |
|
if value, ok := _u.mutation.ConnectorID(); ok { |
|
_spec.SetField(authcode.FieldConnectorID, field.TypeString, value) |
|
} |
|
if value, ok := _u.mutation.ConnectorData(); ok { |
|
_spec.SetField(authcode.FieldConnectorData, field.TypeBytes, value) |
|
} |
|
if _u.mutation.ConnectorDataCleared() { |
|
_spec.ClearField(authcode.FieldConnectorData, field.TypeBytes) |
|
} |
|
if value, ok := _u.mutation.Expiry(); ok { |
|
_spec.SetField(authcode.FieldExpiry, field.TypeTime, value) |
|
} |
|
if value, ok := _u.mutation.CodeChallenge(); ok { |
|
_spec.SetField(authcode.FieldCodeChallenge, field.TypeString, value) |
|
} |
|
if value, ok := _u.mutation.CodeChallengeMethod(); ok { |
|
_spec.SetField(authcode.FieldCodeChallengeMethod, field.TypeString, value) |
|
} |
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { |
|
if _, ok := err.(*sqlgraph.NotFoundError); ok { |
|
err = &NotFoundError{authcode.Label} |
|
} else if sqlgraph.IsConstraintError(err) { |
|
err = &ConstraintError{msg: err.Error(), wrap: err} |
|
} |
|
return 0, err |
|
} |
|
_u.mutation.done = true |
|
return _node, nil |
|
} |
|
|
|
// AuthCodeUpdateOne is the builder for updating a single AuthCode entity. |
|
type AuthCodeUpdateOne struct { |
|
config |
|
fields []string |
|
hooks []Hook |
|
mutation *AuthCodeMutation |
|
} |
|
|
|
// SetClientID sets the "client_id" field. |
|
func (_u *AuthCodeUpdateOne) SetClientID(v string) *AuthCodeUpdateOne { |
|
_u.mutation.SetClientID(v) |
|
return _u |
|
} |
|
|
|
// SetNillableClientID sets the "client_id" field if the given value is not nil. |
|
func (_u *AuthCodeUpdateOne) SetNillableClientID(v *string) *AuthCodeUpdateOne { |
|
if v != nil { |
|
_u.SetClientID(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetScopes sets the "scopes" field. |
|
func (_u *AuthCodeUpdateOne) SetScopes(v []string) *AuthCodeUpdateOne { |
|
_u.mutation.SetScopes(v) |
|
return _u |
|
} |
|
|
|
// AppendScopes appends value to the "scopes" field. |
|
func (_u *AuthCodeUpdateOne) AppendScopes(v []string) *AuthCodeUpdateOne { |
|
_u.mutation.AppendScopes(v) |
|
return _u |
|
} |
|
|
|
// ClearScopes clears the value of the "scopes" field. |
|
func (_u *AuthCodeUpdateOne) ClearScopes() *AuthCodeUpdateOne { |
|
_u.mutation.ClearScopes() |
|
return _u |
|
} |
|
|
|
// SetNonce sets the "nonce" field. |
|
func (_u *AuthCodeUpdateOne) SetNonce(v string) *AuthCodeUpdateOne { |
|
_u.mutation.SetNonce(v) |
|
return _u |
|
} |
|
|
|
// SetNillableNonce sets the "nonce" field if the given value is not nil. |
|
func (_u *AuthCodeUpdateOne) SetNillableNonce(v *string) *AuthCodeUpdateOne { |
|
if v != nil { |
|
_u.SetNonce(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetRedirectURI sets the "redirect_uri" field. |
|
func (_u *AuthCodeUpdateOne) SetRedirectURI(v string) *AuthCodeUpdateOne { |
|
_u.mutation.SetRedirectURI(v) |
|
return _u |
|
} |
|
|
|
// SetNillableRedirectURI sets the "redirect_uri" field if the given value is not nil. |
|
func (_u *AuthCodeUpdateOne) SetNillableRedirectURI(v *string) *AuthCodeUpdateOne { |
|
if v != nil { |
|
_u.SetRedirectURI(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetClaimsUserID sets the "claims_user_id" field. |
|
func (_u *AuthCodeUpdateOne) SetClaimsUserID(v string) *AuthCodeUpdateOne { |
|
_u.mutation.SetClaimsUserID(v) |
|
return _u |
|
} |
|
|
|
// SetNillableClaimsUserID sets the "claims_user_id" field if the given value is not nil. |
|
func (_u *AuthCodeUpdateOne) SetNillableClaimsUserID(v *string) *AuthCodeUpdateOne { |
|
if v != nil { |
|
_u.SetClaimsUserID(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetClaimsUsername sets the "claims_username" field. |
|
func (_u *AuthCodeUpdateOne) SetClaimsUsername(v string) *AuthCodeUpdateOne { |
|
_u.mutation.SetClaimsUsername(v) |
|
return _u |
|
} |
|
|
|
// SetNillableClaimsUsername sets the "claims_username" field if the given value is not nil. |
|
func (_u *AuthCodeUpdateOne) SetNillableClaimsUsername(v *string) *AuthCodeUpdateOne { |
|
if v != nil { |
|
_u.SetClaimsUsername(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetClaimsEmail sets the "claims_email" field. |
|
func (_u *AuthCodeUpdateOne) SetClaimsEmail(v string) *AuthCodeUpdateOne { |
|
_u.mutation.SetClaimsEmail(v) |
|
return _u |
|
} |
|
|
|
// SetNillableClaimsEmail sets the "claims_email" field if the given value is not nil. |
|
func (_u *AuthCodeUpdateOne) SetNillableClaimsEmail(v *string) *AuthCodeUpdateOne { |
|
if v != nil { |
|
_u.SetClaimsEmail(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetClaimsEmailVerified sets the "claims_email_verified" field. |
|
func (_u *AuthCodeUpdateOne) SetClaimsEmailVerified(v bool) *AuthCodeUpdateOne { |
|
_u.mutation.SetClaimsEmailVerified(v) |
|
return _u |
|
} |
|
|
|
// SetNillableClaimsEmailVerified sets the "claims_email_verified" field if the given value is not nil. |
|
func (_u *AuthCodeUpdateOne) SetNillableClaimsEmailVerified(v *bool) *AuthCodeUpdateOne { |
|
if v != nil { |
|
_u.SetClaimsEmailVerified(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetClaimsGroups sets the "claims_groups" field. |
|
func (_u *AuthCodeUpdateOne) SetClaimsGroups(v []string) *AuthCodeUpdateOne { |
|
_u.mutation.SetClaimsGroups(v) |
|
return _u |
|
} |
|
|
|
// AppendClaimsGroups appends value to the "claims_groups" field. |
|
func (_u *AuthCodeUpdateOne) AppendClaimsGroups(v []string) *AuthCodeUpdateOne { |
|
_u.mutation.AppendClaimsGroups(v) |
|
return _u |
|
} |
|
|
|
// ClearClaimsGroups clears the value of the "claims_groups" field. |
|
func (_u *AuthCodeUpdateOne) ClearClaimsGroups() *AuthCodeUpdateOne { |
|
_u.mutation.ClearClaimsGroups() |
|
return _u |
|
} |
|
|
|
// SetClaimsPreferredUsername sets the "claims_preferred_username" field. |
|
func (_u *AuthCodeUpdateOne) SetClaimsPreferredUsername(v string) *AuthCodeUpdateOne { |
|
_u.mutation.SetClaimsPreferredUsername(v) |
|
return _u |
|
} |
|
|
|
// SetNillableClaimsPreferredUsername sets the "claims_preferred_username" field if the given value is not nil. |
|
func (_u *AuthCodeUpdateOne) SetNillableClaimsPreferredUsername(v *string) *AuthCodeUpdateOne { |
|
if v != nil { |
|
_u.SetClaimsPreferredUsername(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetConnectorID sets the "connector_id" field. |
|
func (_u *AuthCodeUpdateOne) SetConnectorID(v string) *AuthCodeUpdateOne { |
|
_u.mutation.SetConnectorID(v) |
|
return _u |
|
} |
|
|
|
// SetNillableConnectorID sets the "connector_id" field if the given value is not nil. |
|
func (_u *AuthCodeUpdateOne) SetNillableConnectorID(v *string) *AuthCodeUpdateOne { |
|
if v != nil { |
|
_u.SetConnectorID(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetConnectorData sets the "connector_data" field. |
|
func (_u *AuthCodeUpdateOne) SetConnectorData(v []byte) *AuthCodeUpdateOne { |
|
_u.mutation.SetConnectorData(v) |
|
return _u |
|
} |
|
|
|
// ClearConnectorData clears the value of the "connector_data" field. |
|
func (_u *AuthCodeUpdateOne) ClearConnectorData() *AuthCodeUpdateOne { |
|
_u.mutation.ClearConnectorData() |
|
return _u |
|
} |
|
|
|
// SetExpiry sets the "expiry" field. |
|
func (_u *AuthCodeUpdateOne) SetExpiry(v time.Time) *AuthCodeUpdateOne { |
|
_u.mutation.SetExpiry(v) |
|
return _u |
|
} |
|
|
|
// SetNillableExpiry sets the "expiry" field if the given value is not nil. |
|
func (_u *AuthCodeUpdateOne) SetNillableExpiry(v *time.Time) *AuthCodeUpdateOne { |
|
if v != nil { |
|
_u.SetExpiry(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetCodeChallenge sets the "code_challenge" field. |
|
func (_u *AuthCodeUpdateOne) SetCodeChallenge(v string) *AuthCodeUpdateOne { |
|
_u.mutation.SetCodeChallenge(v) |
|
return _u |
|
} |
|
|
|
// SetNillableCodeChallenge sets the "code_challenge" field if the given value is not nil. |
|
func (_u *AuthCodeUpdateOne) SetNillableCodeChallenge(v *string) *AuthCodeUpdateOne { |
|
if v != nil { |
|
_u.SetCodeChallenge(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// SetCodeChallengeMethod sets the "code_challenge_method" field. |
|
func (_u *AuthCodeUpdateOne) SetCodeChallengeMethod(v string) *AuthCodeUpdateOne { |
|
_u.mutation.SetCodeChallengeMethod(v) |
|
return _u |
|
} |
|
|
|
// SetNillableCodeChallengeMethod sets the "code_challenge_method" field if the given value is not nil. |
|
func (_u *AuthCodeUpdateOne) SetNillableCodeChallengeMethod(v *string) *AuthCodeUpdateOne { |
|
if v != nil { |
|
_u.SetCodeChallengeMethod(*v) |
|
} |
|
return _u |
|
} |
|
|
|
// Mutation returns the AuthCodeMutation object of the builder. |
|
func (_u *AuthCodeUpdateOne) Mutation() *AuthCodeMutation { |
|
return _u.mutation |
|
} |
|
|
|
// Where appends a list predicates to the AuthCodeUpdate builder. |
|
func (_u *AuthCodeUpdateOne) Where(ps ...predicate.AuthCode) *AuthCodeUpdateOne { |
|
_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 *AuthCodeUpdateOne) Select(field string, fields ...string) *AuthCodeUpdateOne { |
|
_u.fields = append([]string{field}, fields...) |
|
return _u |
|
} |
|
|
|
// Save executes the query and returns the updated AuthCode entity. |
|
func (_u *AuthCodeUpdateOne) Save(ctx context.Context) (*AuthCode, error) { |
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) |
|
} |
|
|
|
// SaveX is like Save, but panics if an error occurs. |
|
func (_u *AuthCodeUpdateOne) SaveX(ctx context.Context) *AuthCode { |
|
node, err := _u.Save(ctx) |
|
if err != nil { |
|
panic(err) |
|
} |
|
return node |
|
} |
|
|
|
// Exec executes the query on the entity. |
|
func (_u *AuthCodeUpdateOne) Exec(ctx context.Context) error { |
|
_, err := _u.Save(ctx) |
|
return err |
|
} |
|
|
|
// ExecX is like Exec, but panics if an error occurs. |
|
func (_u *AuthCodeUpdateOne) 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 *AuthCodeUpdateOne) check() error { |
|
if v, ok := _u.mutation.ClientID(); ok { |
|
if err := authcode.ClientIDValidator(v); err != nil { |
|
return &ValidationError{Name: "client_id", err: fmt.Errorf(`db: validator failed for field "AuthCode.client_id": %w`, err)} |
|
} |
|
} |
|
if v, ok := _u.mutation.Nonce(); ok { |
|
if err := authcode.NonceValidator(v); err != nil { |
|
return &ValidationError{Name: "nonce", err: fmt.Errorf(`db: validator failed for field "AuthCode.nonce": %w`, err)} |
|
} |
|
} |
|
if v, ok := _u.mutation.RedirectURI(); ok { |
|
if err := authcode.RedirectURIValidator(v); err != nil { |
|
return &ValidationError{Name: "redirect_uri", err: fmt.Errorf(`db: validator failed for field "AuthCode.redirect_uri": %w`, err)} |
|
} |
|
} |
|
if v, ok := _u.mutation.ClaimsUserID(); ok { |
|
if err := authcode.ClaimsUserIDValidator(v); err != nil { |
|
return &ValidationError{Name: "claims_user_id", err: fmt.Errorf(`db: validator failed for field "AuthCode.claims_user_id": %w`, err)} |
|
} |
|
} |
|
if v, ok := _u.mutation.ClaimsUsername(); ok { |
|
if err := authcode.ClaimsUsernameValidator(v); err != nil { |
|
return &ValidationError{Name: "claims_username", err: fmt.Errorf(`db: validator failed for field "AuthCode.claims_username": %w`, err)} |
|
} |
|
} |
|
if v, ok := _u.mutation.ClaimsEmail(); ok { |
|
if err := authcode.ClaimsEmailValidator(v); err != nil { |
|
return &ValidationError{Name: "claims_email", err: fmt.Errorf(`db: validator failed for field "AuthCode.claims_email": %w`, err)} |
|
} |
|
} |
|
if v, ok := _u.mutation.ConnectorID(); ok { |
|
if err := authcode.ConnectorIDValidator(v); err != nil { |
|
return &ValidationError{Name: "connector_id", err: fmt.Errorf(`db: validator failed for field "AuthCode.connector_id": %w`, err)} |
|
} |
|
} |
|
return nil |
|
} |
|
|
|
func (_u *AuthCodeUpdateOne) sqlSave(ctx context.Context) (_node *AuthCode, err error) { |
|
if err := _u.check(); err != nil { |
|
return _node, err |
|
} |
|
_spec := sqlgraph.NewUpdateSpec(authcode.Table, authcode.Columns, sqlgraph.NewFieldSpec(authcode.FieldID, field.TypeString)) |
|
id, ok := _u.mutation.ID() |
|
if !ok { |
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "AuthCode.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, authcode.FieldID) |
|
for _, f := range fields { |
|
if !authcode.ValidColumn(f) { |
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} |
|
} |
|
if f != authcode.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.ClientID(); ok { |
|
_spec.SetField(authcode.FieldClientID, field.TypeString, value) |
|
} |
|
if value, ok := _u.mutation.Scopes(); ok { |
|
_spec.SetField(authcode.FieldScopes, field.TypeJSON, value) |
|
} |
|
if value, ok := _u.mutation.AppendedScopes(); ok { |
|
_spec.AddModifier(func(u *sql.UpdateBuilder) { |
|
sqljson.Append(u, authcode.FieldScopes, value) |
|
}) |
|
} |
|
if _u.mutation.ScopesCleared() { |
|
_spec.ClearField(authcode.FieldScopes, field.TypeJSON) |
|
} |
|
if value, ok := _u.mutation.Nonce(); ok { |
|
_spec.SetField(authcode.FieldNonce, field.TypeString, value) |
|
} |
|
if value, ok := _u.mutation.RedirectURI(); ok { |
|
_spec.SetField(authcode.FieldRedirectURI, field.TypeString, value) |
|
} |
|
if value, ok := _u.mutation.ClaimsUserID(); ok { |
|
_spec.SetField(authcode.FieldClaimsUserID, field.TypeString, value) |
|
} |
|
if value, ok := _u.mutation.ClaimsUsername(); ok { |
|
_spec.SetField(authcode.FieldClaimsUsername, field.TypeString, value) |
|
} |
|
if value, ok := _u.mutation.ClaimsEmail(); ok { |
|
_spec.SetField(authcode.FieldClaimsEmail, field.TypeString, value) |
|
} |
|
if value, ok := _u.mutation.ClaimsEmailVerified(); ok { |
|
_spec.SetField(authcode.FieldClaimsEmailVerified, field.TypeBool, value) |
|
} |
|
if value, ok := _u.mutation.ClaimsGroups(); ok { |
|
_spec.SetField(authcode.FieldClaimsGroups, field.TypeJSON, value) |
|
} |
|
if value, ok := _u.mutation.AppendedClaimsGroups(); ok { |
|
_spec.AddModifier(func(u *sql.UpdateBuilder) { |
|
sqljson.Append(u, authcode.FieldClaimsGroups, value) |
|
}) |
|
} |
|
if _u.mutation.ClaimsGroupsCleared() { |
|
_spec.ClearField(authcode.FieldClaimsGroups, field.TypeJSON) |
|
} |
|
if value, ok := _u.mutation.ClaimsPreferredUsername(); ok { |
|
_spec.SetField(authcode.FieldClaimsPreferredUsername, field.TypeString, value) |
|
} |
|
if value, ok := _u.mutation.ConnectorID(); ok { |
|
_spec.SetField(authcode.FieldConnectorID, field.TypeString, value) |
|
} |
|
if value, ok := _u.mutation.ConnectorData(); ok { |
|
_spec.SetField(authcode.FieldConnectorData, field.TypeBytes, value) |
|
} |
|
if _u.mutation.ConnectorDataCleared() { |
|
_spec.ClearField(authcode.FieldConnectorData, field.TypeBytes) |
|
} |
|
if value, ok := _u.mutation.Expiry(); ok { |
|
_spec.SetField(authcode.FieldExpiry, field.TypeTime, value) |
|
} |
|
if value, ok := _u.mutation.CodeChallenge(); ok { |
|
_spec.SetField(authcode.FieldCodeChallenge, field.TypeString, value) |
|
} |
|
if value, ok := _u.mutation.CodeChallengeMethod(); ok { |
|
_spec.SetField(authcode.FieldCodeChallengeMethod, field.TypeString, value) |
|
} |
|
_node = &AuthCode{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{authcode.Label} |
|
} else if sqlgraph.IsConstraintError(err) { |
|
err = &ConstraintError{msg: err.Error(), wrap: err} |
|
} |
|
return nil, err |
|
} |
|
_u.mutation.done = true |
|
return _node, nil |
|
}
|
|
|