| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- "github.com/Wei-Shaw/sub2api/ent/identityadoptiondecision"
- "github.com/Wei-Shaw/sub2api/ent/pendingauthsession"
- "github.com/Wei-Shaw/sub2api/ent/predicate"
- "github.com/Wei-Shaw/sub2api/ent/user"
- )
- // PendingAuthSessionUpdate is the builder for updating PendingAuthSession entities.
- type PendingAuthSessionUpdate struct {
- config
- hooks []Hook
- mutation *PendingAuthSessionMutation
- }
- // Where appends a list predicates to the PendingAuthSessionUpdate builder.
- func (_u *PendingAuthSessionUpdate) Where(ps ...predicate.PendingAuthSession) *PendingAuthSessionUpdate {
- _u.mutation.Where(ps...)
- return _u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (_u *PendingAuthSessionUpdate) SetUpdatedAt(v time.Time) *PendingAuthSessionUpdate {
- _u.mutation.SetUpdatedAt(v)
- return _u
- }
- // SetSessionToken sets the "session_token" field.
- func (_u *PendingAuthSessionUpdate) SetSessionToken(v string) *PendingAuthSessionUpdate {
- _u.mutation.SetSessionToken(v)
- return _u
- }
- // SetNillableSessionToken sets the "session_token" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdate) SetNillableSessionToken(v *string) *PendingAuthSessionUpdate {
- if v != nil {
- _u.SetSessionToken(*v)
- }
- return _u
- }
- // SetIntent sets the "intent" field.
- func (_u *PendingAuthSessionUpdate) SetIntent(v string) *PendingAuthSessionUpdate {
- _u.mutation.SetIntent(v)
- return _u
- }
- // SetNillableIntent sets the "intent" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdate) SetNillableIntent(v *string) *PendingAuthSessionUpdate {
- if v != nil {
- _u.SetIntent(*v)
- }
- return _u
- }
- // SetProviderType sets the "provider_type" field.
- func (_u *PendingAuthSessionUpdate) SetProviderType(v string) *PendingAuthSessionUpdate {
- _u.mutation.SetProviderType(v)
- return _u
- }
- // SetNillableProviderType sets the "provider_type" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdate) SetNillableProviderType(v *string) *PendingAuthSessionUpdate {
- if v != nil {
- _u.SetProviderType(*v)
- }
- return _u
- }
- // SetProviderKey sets the "provider_key" field.
- func (_u *PendingAuthSessionUpdate) SetProviderKey(v string) *PendingAuthSessionUpdate {
- _u.mutation.SetProviderKey(v)
- return _u
- }
- // SetNillableProviderKey sets the "provider_key" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdate) SetNillableProviderKey(v *string) *PendingAuthSessionUpdate {
- if v != nil {
- _u.SetProviderKey(*v)
- }
- return _u
- }
- // SetProviderSubject sets the "provider_subject" field.
- func (_u *PendingAuthSessionUpdate) SetProviderSubject(v string) *PendingAuthSessionUpdate {
- _u.mutation.SetProviderSubject(v)
- return _u
- }
- // SetNillableProviderSubject sets the "provider_subject" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdate) SetNillableProviderSubject(v *string) *PendingAuthSessionUpdate {
- if v != nil {
- _u.SetProviderSubject(*v)
- }
- return _u
- }
- // SetTargetUserID sets the "target_user_id" field.
- func (_u *PendingAuthSessionUpdate) SetTargetUserID(v int64) *PendingAuthSessionUpdate {
- _u.mutation.SetTargetUserID(v)
- return _u
- }
- // SetNillableTargetUserID sets the "target_user_id" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdate) SetNillableTargetUserID(v *int64) *PendingAuthSessionUpdate {
- if v != nil {
- _u.SetTargetUserID(*v)
- }
- return _u
- }
- // ClearTargetUserID clears the value of the "target_user_id" field.
- func (_u *PendingAuthSessionUpdate) ClearTargetUserID() *PendingAuthSessionUpdate {
- _u.mutation.ClearTargetUserID()
- return _u
- }
- // SetRedirectTo sets the "redirect_to" field.
- func (_u *PendingAuthSessionUpdate) SetRedirectTo(v string) *PendingAuthSessionUpdate {
- _u.mutation.SetRedirectTo(v)
- return _u
- }
- // SetNillableRedirectTo sets the "redirect_to" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdate) SetNillableRedirectTo(v *string) *PendingAuthSessionUpdate {
- if v != nil {
- _u.SetRedirectTo(*v)
- }
- return _u
- }
- // SetResolvedEmail sets the "resolved_email" field.
- func (_u *PendingAuthSessionUpdate) SetResolvedEmail(v string) *PendingAuthSessionUpdate {
- _u.mutation.SetResolvedEmail(v)
- return _u
- }
- // SetNillableResolvedEmail sets the "resolved_email" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdate) SetNillableResolvedEmail(v *string) *PendingAuthSessionUpdate {
- if v != nil {
- _u.SetResolvedEmail(*v)
- }
- return _u
- }
- // SetRegistrationPasswordHash sets the "registration_password_hash" field.
- func (_u *PendingAuthSessionUpdate) SetRegistrationPasswordHash(v string) *PendingAuthSessionUpdate {
- _u.mutation.SetRegistrationPasswordHash(v)
- return _u
- }
- // SetNillableRegistrationPasswordHash sets the "registration_password_hash" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdate) SetNillableRegistrationPasswordHash(v *string) *PendingAuthSessionUpdate {
- if v != nil {
- _u.SetRegistrationPasswordHash(*v)
- }
- return _u
- }
- // SetUpstreamIdentityClaims sets the "upstream_identity_claims" field.
- func (_u *PendingAuthSessionUpdate) SetUpstreamIdentityClaims(v map[string]interface{}) *PendingAuthSessionUpdate {
- _u.mutation.SetUpstreamIdentityClaims(v)
- return _u
- }
- // SetLocalFlowState sets the "local_flow_state" field.
- func (_u *PendingAuthSessionUpdate) SetLocalFlowState(v map[string]interface{}) *PendingAuthSessionUpdate {
- _u.mutation.SetLocalFlowState(v)
- return _u
- }
- // SetBrowserSessionKey sets the "browser_session_key" field.
- func (_u *PendingAuthSessionUpdate) SetBrowserSessionKey(v string) *PendingAuthSessionUpdate {
- _u.mutation.SetBrowserSessionKey(v)
- return _u
- }
- // SetNillableBrowserSessionKey sets the "browser_session_key" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdate) SetNillableBrowserSessionKey(v *string) *PendingAuthSessionUpdate {
- if v != nil {
- _u.SetBrowserSessionKey(*v)
- }
- return _u
- }
- // SetCompletionCodeHash sets the "completion_code_hash" field.
- func (_u *PendingAuthSessionUpdate) SetCompletionCodeHash(v string) *PendingAuthSessionUpdate {
- _u.mutation.SetCompletionCodeHash(v)
- return _u
- }
- // SetNillableCompletionCodeHash sets the "completion_code_hash" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdate) SetNillableCompletionCodeHash(v *string) *PendingAuthSessionUpdate {
- if v != nil {
- _u.SetCompletionCodeHash(*v)
- }
- return _u
- }
- // SetCompletionCodeExpiresAt sets the "completion_code_expires_at" field.
- func (_u *PendingAuthSessionUpdate) SetCompletionCodeExpiresAt(v time.Time) *PendingAuthSessionUpdate {
- _u.mutation.SetCompletionCodeExpiresAt(v)
- return _u
- }
- // SetNillableCompletionCodeExpiresAt sets the "completion_code_expires_at" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdate) SetNillableCompletionCodeExpiresAt(v *time.Time) *PendingAuthSessionUpdate {
- if v != nil {
- _u.SetCompletionCodeExpiresAt(*v)
- }
- return _u
- }
- // ClearCompletionCodeExpiresAt clears the value of the "completion_code_expires_at" field.
- func (_u *PendingAuthSessionUpdate) ClearCompletionCodeExpiresAt() *PendingAuthSessionUpdate {
- _u.mutation.ClearCompletionCodeExpiresAt()
- return _u
- }
- // SetEmailVerifiedAt sets the "email_verified_at" field.
- func (_u *PendingAuthSessionUpdate) SetEmailVerifiedAt(v time.Time) *PendingAuthSessionUpdate {
- _u.mutation.SetEmailVerifiedAt(v)
- return _u
- }
- // SetNillableEmailVerifiedAt sets the "email_verified_at" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdate) SetNillableEmailVerifiedAt(v *time.Time) *PendingAuthSessionUpdate {
- if v != nil {
- _u.SetEmailVerifiedAt(*v)
- }
- return _u
- }
- // ClearEmailVerifiedAt clears the value of the "email_verified_at" field.
- func (_u *PendingAuthSessionUpdate) ClearEmailVerifiedAt() *PendingAuthSessionUpdate {
- _u.mutation.ClearEmailVerifiedAt()
- return _u
- }
- // SetPasswordVerifiedAt sets the "password_verified_at" field.
- func (_u *PendingAuthSessionUpdate) SetPasswordVerifiedAt(v time.Time) *PendingAuthSessionUpdate {
- _u.mutation.SetPasswordVerifiedAt(v)
- return _u
- }
- // SetNillablePasswordVerifiedAt sets the "password_verified_at" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdate) SetNillablePasswordVerifiedAt(v *time.Time) *PendingAuthSessionUpdate {
- if v != nil {
- _u.SetPasswordVerifiedAt(*v)
- }
- return _u
- }
- // ClearPasswordVerifiedAt clears the value of the "password_verified_at" field.
- func (_u *PendingAuthSessionUpdate) ClearPasswordVerifiedAt() *PendingAuthSessionUpdate {
- _u.mutation.ClearPasswordVerifiedAt()
- return _u
- }
- // SetTotpVerifiedAt sets the "totp_verified_at" field.
- func (_u *PendingAuthSessionUpdate) SetTotpVerifiedAt(v time.Time) *PendingAuthSessionUpdate {
- _u.mutation.SetTotpVerifiedAt(v)
- return _u
- }
- // SetNillableTotpVerifiedAt sets the "totp_verified_at" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdate) SetNillableTotpVerifiedAt(v *time.Time) *PendingAuthSessionUpdate {
- if v != nil {
- _u.SetTotpVerifiedAt(*v)
- }
- return _u
- }
- // ClearTotpVerifiedAt clears the value of the "totp_verified_at" field.
- func (_u *PendingAuthSessionUpdate) ClearTotpVerifiedAt() *PendingAuthSessionUpdate {
- _u.mutation.ClearTotpVerifiedAt()
- return _u
- }
- // SetExpiresAt sets the "expires_at" field.
- func (_u *PendingAuthSessionUpdate) SetExpiresAt(v time.Time) *PendingAuthSessionUpdate {
- _u.mutation.SetExpiresAt(v)
- return _u
- }
- // SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdate) SetNillableExpiresAt(v *time.Time) *PendingAuthSessionUpdate {
- if v != nil {
- _u.SetExpiresAt(*v)
- }
- return _u
- }
- // SetConsumedAt sets the "consumed_at" field.
- func (_u *PendingAuthSessionUpdate) SetConsumedAt(v time.Time) *PendingAuthSessionUpdate {
- _u.mutation.SetConsumedAt(v)
- return _u
- }
- // SetNillableConsumedAt sets the "consumed_at" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdate) SetNillableConsumedAt(v *time.Time) *PendingAuthSessionUpdate {
- if v != nil {
- _u.SetConsumedAt(*v)
- }
- return _u
- }
- // ClearConsumedAt clears the value of the "consumed_at" field.
- func (_u *PendingAuthSessionUpdate) ClearConsumedAt() *PendingAuthSessionUpdate {
- _u.mutation.ClearConsumedAt()
- return _u
- }
- // SetTargetUser sets the "target_user" edge to the User entity.
- func (_u *PendingAuthSessionUpdate) SetTargetUser(v *User) *PendingAuthSessionUpdate {
- return _u.SetTargetUserID(v.ID)
- }
- // SetAdoptionDecisionID sets the "adoption_decision" edge to the IdentityAdoptionDecision entity by ID.
- func (_u *PendingAuthSessionUpdate) SetAdoptionDecisionID(id int64) *PendingAuthSessionUpdate {
- _u.mutation.SetAdoptionDecisionID(id)
- return _u
- }
- // SetNillableAdoptionDecisionID sets the "adoption_decision" edge to the IdentityAdoptionDecision entity by ID if the given value is not nil.
- func (_u *PendingAuthSessionUpdate) SetNillableAdoptionDecisionID(id *int64) *PendingAuthSessionUpdate {
- if id != nil {
- _u = _u.SetAdoptionDecisionID(*id)
- }
- return _u
- }
- // SetAdoptionDecision sets the "adoption_decision" edge to the IdentityAdoptionDecision entity.
- func (_u *PendingAuthSessionUpdate) SetAdoptionDecision(v *IdentityAdoptionDecision) *PendingAuthSessionUpdate {
- return _u.SetAdoptionDecisionID(v.ID)
- }
- // Mutation returns the PendingAuthSessionMutation object of the builder.
- func (_u *PendingAuthSessionUpdate) Mutation() *PendingAuthSessionMutation {
- return _u.mutation
- }
- // ClearTargetUser clears the "target_user" edge to the User entity.
- func (_u *PendingAuthSessionUpdate) ClearTargetUser() *PendingAuthSessionUpdate {
- _u.mutation.ClearTargetUser()
- return _u
- }
- // ClearAdoptionDecision clears the "adoption_decision" edge to the IdentityAdoptionDecision entity.
- func (_u *PendingAuthSessionUpdate) ClearAdoptionDecision() *PendingAuthSessionUpdate {
- _u.mutation.ClearAdoptionDecision()
- return _u
- }
- // Save executes the query and returns the number of nodes affected by the update operation.
- func (_u *PendingAuthSessionUpdate) Save(ctx context.Context) (int, error) {
- _u.defaults()
- return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (_u *PendingAuthSessionUpdate) SaveX(ctx context.Context) int {
- affected, err := _u.Save(ctx)
- if err != nil {
- panic(err)
- }
- return affected
- }
- // Exec executes the query.
- func (_u *PendingAuthSessionUpdate) Exec(ctx context.Context) error {
- _, err := _u.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_u *PendingAuthSessionUpdate) ExecX(ctx context.Context) {
- if err := _u.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (_u *PendingAuthSessionUpdate) defaults() {
- if _, ok := _u.mutation.UpdatedAt(); !ok {
- v := pendingauthsession.UpdateDefaultUpdatedAt()
- _u.mutation.SetUpdatedAt(v)
- }
- }
- // check runs all checks and user-defined validators on the builder.
- func (_u *PendingAuthSessionUpdate) check() error {
- if v, ok := _u.mutation.SessionToken(); ok {
- if err := pendingauthsession.SessionTokenValidator(v); err != nil {
- return &ValidationError{Name: "session_token", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.session_token": %w`, err)}
- }
- }
- if v, ok := _u.mutation.Intent(); ok {
- if err := pendingauthsession.IntentValidator(v); err != nil {
- return &ValidationError{Name: "intent", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.intent": %w`, err)}
- }
- }
- if v, ok := _u.mutation.ProviderType(); ok {
- if err := pendingauthsession.ProviderTypeValidator(v); err != nil {
- return &ValidationError{Name: "provider_type", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.provider_type": %w`, err)}
- }
- }
- if v, ok := _u.mutation.ProviderKey(); ok {
- if err := pendingauthsession.ProviderKeyValidator(v); err != nil {
- return &ValidationError{Name: "provider_key", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.provider_key": %w`, err)}
- }
- }
- if v, ok := _u.mutation.ProviderSubject(); ok {
- if err := pendingauthsession.ProviderSubjectValidator(v); err != nil {
- return &ValidationError{Name: "provider_subject", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.provider_subject": %w`, err)}
- }
- }
- return nil
- }
- func (_u *PendingAuthSessionUpdate) sqlSave(ctx context.Context) (_node int, err error) {
- if err := _u.check(); err != nil {
- return _node, err
- }
- _spec := sqlgraph.NewUpdateSpec(pendingauthsession.Table, pendingauthsession.Columns, sqlgraph.NewFieldSpec(pendingauthsession.FieldID, field.TypeInt64))
- 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.UpdatedAt(); ok {
- _spec.SetField(pendingauthsession.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := _u.mutation.SessionToken(); ok {
- _spec.SetField(pendingauthsession.FieldSessionToken, field.TypeString, value)
- }
- if value, ok := _u.mutation.Intent(); ok {
- _spec.SetField(pendingauthsession.FieldIntent, field.TypeString, value)
- }
- if value, ok := _u.mutation.ProviderType(); ok {
- _spec.SetField(pendingauthsession.FieldProviderType, field.TypeString, value)
- }
- if value, ok := _u.mutation.ProviderKey(); ok {
- _spec.SetField(pendingauthsession.FieldProviderKey, field.TypeString, value)
- }
- if value, ok := _u.mutation.ProviderSubject(); ok {
- _spec.SetField(pendingauthsession.FieldProviderSubject, field.TypeString, value)
- }
- if value, ok := _u.mutation.RedirectTo(); ok {
- _spec.SetField(pendingauthsession.FieldRedirectTo, field.TypeString, value)
- }
- if value, ok := _u.mutation.ResolvedEmail(); ok {
- _spec.SetField(pendingauthsession.FieldResolvedEmail, field.TypeString, value)
- }
- if value, ok := _u.mutation.RegistrationPasswordHash(); ok {
- _spec.SetField(pendingauthsession.FieldRegistrationPasswordHash, field.TypeString, value)
- }
- if value, ok := _u.mutation.UpstreamIdentityClaims(); ok {
- _spec.SetField(pendingauthsession.FieldUpstreamIdentityClaims, field.TypeJSON, value)
- }
- if value, ok := _u.mutation.LocalFlowState(); ok {
- _spec.SetField(pendingauthsession.FieldLocalFlowState, field.TypeJSON, value)
- }
- if value, ok := _u.mutation.BrowserSessionKey(); ok {
- _spec.SetField(pendingauthsession.FieldBrowserSessionKey, field.TypeString, value)
- }
- if value, ok := _u.mutation.CompletionCodeHash(); ok {
- _spec.SetField(pendingauthsession.FieldCompletionCodeHash, field.TypeString, value)
- }
- if value, ok := _u.mutation.CompletionCodeExpiresAt(); ok {
- _spec.SetField(pendingauthsession.FieldCompletionCodeExpiresAt, field.TypeTime, value)
- }
- if _u.mutation.CompletionCodeExpiresAtCleared() {
- _spec.ClearField(pendingauthsession.FieldCompletionCodeExpiresAt, field.TypeTime)
- }
- if value, ok := _u.mutation.EmailVerifiedAt(); ok {
- _spec.SetField(pendingauthsession.FieldEmailVerifiedAt, field.TypeTime, value)
- }
- if _u.mutation.EmailVerifiedAtCleared() {
- _spec.ClearField(pendingauthsession.FieldEmailVerifiedAt, field.TypeTime)
- }
- if value, ok := _u.mutation.PasswordVerifiedAt(); ok {
- _spec.SetField(pendingauthsession.FieldPasswordVerifiedAt, field.TypeTime, value)
- }
- if _u.mutation.PasswordVerifiedAtCleared() {
- _spec.ClearField(pendingauthsession.FieldPasswordVerifiedAt, field.TypeTime)
- }
- if value, ok := _u.mutation.TotpVerifiedAt(); ok {
- _spec.SetField(pendingauthsession.FieldTotpVerifiedAt, field.TypeTime, value)
- }
- if _u.mutation.TotpVerifiedAtCleared() {
- _spec.ClearField(pendingauthsession.FieldTotpVerifiedAt, field.TypeTime)
- }
- if value, ok := _u.mutation.ExpiresAt(); ok {
- _spec.SetField(pendingauthsession.FieldExpiresAt, field.TypeTime, value)
- }
- if value, ok := _u.mutation.ConsumedAt(); ok {
- _spec.SetField(pendingauthsession.FieldConsumedAt, field.TypeTime, value)
- }
- if _u.mutation.ConsumedAtCleared() {
- _spec.ClearField(pendingauthsession.FieldConsumedAt, field.TypeTime)
- }
- if _u.mutation.TargetUserCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: pendingauthsession.TargetUserTable,
- Columns: []string{pendingauthsession.TargetUserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.TargetUserIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: pendingauthsession.TargetUserTable,
- Columns: []string{pendingauthsession.TargetUserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _u.mutation.AdoptionDecisionCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2O,
- Inverse: false,
- Table: pendingauthsession.AdoptionDecisionTable,
- Columns: []string{pendingauthsession.AdoptionDecisionColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(identityadoptiondecision.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.AdoptionDecisionIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2O,
- Inverse: false,
- Table: pendingauthsession.AdoptionDecisionTable,
- Columns: []string{pendingauthsession.AdoptionDecisionColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(identityadoptiondecision.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{pendingauthsession.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return 0, err
- }
- _u.mutation.done = true
- return _node, nil
- }
- // PendingAuthSessionUpdateOne is the builder for updating a single PendingAuthSession entity.
- type PendingAuthSessionUpdateOne struct {
- config
- fields []string
- hooks []Hook
- mutation *PendingAuthSessionMutation
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (_u *PendingAuthSessionUpdateOne) SetUpdatedAt(v time.Time) *PendingAuthSessionUpdateOne {
- _u.mutation.SetUpdatedAt(v)
- return _u
- }
- // SetSessionToken sets the "session_token" field.
- func (_u *PendingAuthSessionUpdateOne) SetSessionToken(v string) *PendingAuthSessionUpdateOne {
- _u.mutation.SetSessionToken(v)
- return _u
- }
- // SetNillableSessionToken sets the "session_token" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdateOne) SetNillableSessionToken(v *string) *PendingAuthSessionUpdateOne {
- if v != nil {
- _u.SetSessionToken(*v)
- }
- return _u
- }
- // SetIntent sets the "intent" field.
- func (_u *PendingAuthSessionUpdateOne) SetIntent(v string) *PendingAuthSessionUpdateOne {
- _u.mutation.SetIntent(v)
- return _u
- }
- // SetNillableIntent sets the "intent" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdateOne) SetNillableIntent(v *string) *PendingAuthSessionUpdateOne {
- if v != nil {
- _u.SetIntent(*v)
- }
- return _u
- }
- // SetProviderType sets the "provider_type" field.
- func (_u *PendingAuthSessionUpdateOne) SetProviderType(v string) *PendingAuthSessionUpdateOne {
- _u.mutation.SetProviderType(v)
- return _u
- }
- // SetNillableProviderType sets the "provider_type" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdateOne) SetNillableProviderType(v *string) *PendingAuthSessionUpdateOne {
- if v != nil {
- _u.SetProviderType(*v)
- }
- return _u
- }
- // SetProviderKey sets the "provider_key" field.
- func (_u *PendingAuthSessionUpdateOne) SetProviderKey(v string) *PendingAuthSessionUpdateOne {
- _u.mutation.SetProviderKey(v)
- return _u
- }
- // SetNillableProviderKey sets the "provider_key" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdateOne) SetNillableProviderKey(v *string) *PendingAuthSessionUpdateOne {
- if v != nil {
- _u.SetProviderKey(*v)
- }
- return _u
- }
- // SetProviderSubject sets the "provider_subject" field.
- func (_u *PendingAuthSessionUpdateOne) SetProviderSubject(v string) *PendingAuthSessionUpdateOne {
- _u.mutation.SetProviderSubject(v)
- return _u
- }
- // SetNillableProviderSubject sets the "provider_subject" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdateOne) SetNillableProviderSubject(v *string) *PendingAuthSessionUpdateOne {
- if v != nil {
- _u.SetProviderSubject(*v)
- }
- return _u
- }
- // SetTargetUserID sets the "target_user_id" field.
- func (_u *PendingAuthSessionUpdateOne) SetTargetUserID(v int64) *PendingAuthSessionUpdateOne {
- _u.mutation.SetTargetUserID(v)
- return _u
- }
- // SetNillableTargetUserID sets the "target_user_id" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdateOne) SetNillableTargetUserID(v *int64) *PendingAuthSessionUpdateOne {
- if v != nil {
- _u.SetTargetUserID(*v)
- }
- return _u
- }
- // ClearTargetUserID clears the value of the "target_user_id" field.
- func (_u *PendingAuthSessionUpdateOne) ClearTargetUserID() *PendingAuthSessionUpdateOne {
- _u.mutation.ClearTargetUserID()
- return _u
- }
- // SetRedirectTo sets the "redirect_to" field.
- func (_u *PendingAuthSessionUpdateOne) SetRedirectTo(v string) *PendingAuthSessionUpdateOne {
- _u.mutation.SetRedirectTo(v)
- return _u
- }
- // SetNillableRedirectTo sets the "redirect_to" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdateOne) SetNillableRedirectTo(v *string) *PendingAuthSessionUpdateOne {
- if v != nil {
- _u.SetRedirectTo(*v)
- }
- return _u
- }
- // SetResolvedEmail sets the "resolved_email" field.
- func (_u *PendingAuthSessionUpdateOne) SetResolvedEmail(v string) *PendingAuthSessionUpdateOne {
- _u.mutation.SetResolvedEmail(v)
- return _u
- }
- // SetNillableResolvedEmail sets the "resolved_email" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdateOne) SetNillableResolvedEmail(v *string) *PendingAuthSessionUpdateOne {
- if v != nil {
- _u.SetResolvedEmail(*v)
- }
- return _u
- }
- // SetRegistrationPasswordHash sets the "registration_password_hash" field.
- func (_u *PendingAuthSessionUpdateOne) SetRegistrationPasswordHash(v string) *PendingAuthSessionUpdateOne {
- _u.mutation.SetRegistrationPasswordHash(v)
- return _u
- }
- // SetNillableRegistrationPasswordHash sets the "registration_password_hash" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdateOne) SetNillableRegistrationPasswordHash(v *string) *PendingAuthSessionUpdateOne {
- if v != nil {
- _u.SetRegistrationPasswordHash(*v)
- }
- return _u
- }
- // SetUpstreamIdentityClaims sets the "upstream_identity_claims" field.
- func (_u *PendingAuthSessionUpdateOne) SetUpstreamIdentityClaims(v map[string]interface{}) *PendingAuthSessionUpdateOne {
- _u.mutation.SetUpstreamIdentityClaims(v)
- return _u
- }
- // SetLocalFlowState sets the "local_flow_state" field.
- func (_u *PendingAuthSessionUpdateOne) SetLocalFlowState(v map[string]interface{}) *PendingAuthSessionUpdateOne {
- _u.mutation.SetLocalFlowState(v)
- return _u
- }
- // SetBrowserSessionKey sets the "browser_session_key" field.
- func (_u *PendingAuthSessionUpdateOne) SetBrowserSessionKey(v string) *PendingAuthSessionUpdateOne {
- _u.mutation.SetBrowserSessionKey(v)
- return _u
- }
- // SetNillableBrowserSessionKey sets the "browser_session_key" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdateOne) SetNillableBrowserSessionKey(v *string) *PendingAuthSessionUpdateOne {
- if v != nil {
- _u.SetBrowserSessionKey(*v)
- }
- return _u
- }
- // SetCompletionCodeHash sets the "completion_code_hash" field.
- func (_u *PendingAuthSessionUpdateOne) SetCompletionCodeHash(v string) *PendingAuthSessionUpdateOne {
- _u.mutation.SetCompletionCodeHash(v)
- return _u
- }
- // SetNillableCompletionCodeHash sets the "completion_code_hash" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdateOne) SetNillableCompletionCodeHash(v *string) *PendingAuthSessionUpdateOne {
- if v != nil {
- _u.SetCompletionCodeHash(*v)
- }
- return _u
- }
- // SetCompletionCodeExpiresAt sets the "completion_code_expires_at" field.
- func (_u *PendingAuthSessionUpdateOne) SetCompletionCodeExpiresAt(v time.Time) *PendingAuthSessionUpdateOne {
- _u.mutation.SetCompletionCodeExpiresAt(v)
- return _u
- }
- // SetNillableCompletionCodeExpiresAt sets the "completion_code_expires_at" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdateOne) SetNillableCompletionCodeExpiresAt(v *time.Time) *PendingAuthSessionUpdateOne {
- if v != nil {
- _u.SetCompletionCodeExpiresAt(*v)
- }
- return _u
- }
- // ClearCompletionCodeExpiresAt clears the value of the "completion_code_expires_at" field.
- func (_u *PendingAuthSessionUpdateOne) ClearCompletionCodeExpiresAt() *PendingAuthSessionUpdateOne {
- _u.mutation.ClearCompletionCodeExpiresAt()
- return _u
- }
- // SetEmailVerifiedAt sets the "email_verified_at" field.
- func (_u *PendingAuthSessionUpdateOne) SetEmailVerifiedAt(v time.Time) *PendingAuthSessionUpdateOne {
- _u.mutation.SetEmailVerifiedAt(v)
- return _u
- }
- // SetNillableEmailVerifiedAt sets the "email_verified_at" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdateOne) SetNillableEmailVerifiedAt(v *time.Time) *PendingAuthSessionUpdateOne {
- if v != nil {
- _u.SetEmailVerifiedAt(*v)
- }
- return _u
- }
- // ClearEmailVerifiedAt clears the value of the "email_verified_at" field.
- func (_u *PendingAuthSessionUpdateOne) ClearEmailVerifiedAt() *PendingAuthSessionUpdateOne {
- _u.mutation.ClearEmailVerifiedAt()
- return _u
- }
- // SetPasswordVerifiedAt sets the "password_verified_at" field.
- func (_u *PendingAuthSessionUpdateOne) SetPasswordVerifiedAt(v time.Time) *PendingAuthSessionUpdateOne {
- _u.mutation.SetPasswordVerifiedAt(v)
- return _u
- }
- // SetNillablePasswordVerifiedAt sets the "password_verified_at" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdateOne) SetNillablePasswordVerifiedAt(v *time.Time) *PendingAuthSessionUpdateOne {
- if v != nil {
- _u.SetPasswordVerifiedAt(*v)
- }
- return _u
- }
- // ClearPasswordVerifiedAt clears the value of the "password_verified_at" field.
- func (_u *PendingAuthSessionUpdateOne) ClearPasswordVerifiedAt() *PendingAuthSessionUpdateOne {
- _u.mutation.ClearPasswordVerifiedAt()
- return _u
- }
- // SetTotpVerifiedAt sets the "totp_verified_at" field.
- func (_u *PendingAuthSessionUpdateOne) SetTotpVerifiedAt(v time.Time) *PendingAuthSessionUpdateOne {
- _u.mutation.SetTotpVerifiedAt(v)
- return _u
- }
- // SetNillableTotpVerifiedAt sets the "totp_verified_at" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdateOne) SetNillableTotpVerifiedAt(v *time.Time) *PendingAuthSessionUpdateOne {
- if v != nil {
- _u.SetTotpVerifiedAt(*v)
- }
- return _u
- }
- // ClearTotpVerifiedAt clears the value of the "totp_verified_at" field.
- func (_u *PendingAuthSessionUpdateOne) ClearTotpVerifiedAt() *PendingAuthSessionUpdateOne {
- _u.mutation.ClearTotpVerifiedAt()
- return _u
- }
- // SetExpiresAt sets the "expires_at" field.
- func (_u *PendingAuthSessionUpdateOne) SetExpiresAt(v time.Time) *PendingAuthSessionUpdateOne {
- _u.mutation.SetExpiresAt(v)
- return _u
- }
- // SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdateOne) SetNillableExpiresAt(v *time.Time) *PendingAuthSessionUpdateOne {
- if v != nil {
- _u.SetExpiresAt(*v)
- }
- return _u
- }
- // SetConsumedAt sets the "consumed_at" field.
- func (_u *PendingAuthSessionUpdateOne) SetConsumedAt(v time.Time) *PendingAuthSessionUpdateOne {
- _u.mutation.SetConsumedAt(v)
- return _u
- }
- // SetNillableConsumedAt sets the "consumed_at" field if the given value is not nil.
- func (_u *PendingAuthSessionUpdateOne) SetNillableConsumedAt(v *time.Time) *PendingAuthSessionUpdateOne {
- if v != nil {
- _u.SetConsumedAt(*v)
- }
- return _u
- }
- // ClearConsumedAt clears the value of the "consumed_at" field.
- func (_u *PendingAuthSessionUpdateOne) ClearConsumedAt() *PendingAuthSessionUpdateOne {
- _u.mutation.ClearConsumedAt()
- return _u
- }
- // SetTargetUser sets the "target_user" edge to the User entity.
- func (_u *PendingAuthSessionUpdateOne) SetTargetUser(v *User) *PendingAuthSessionUpdateOne {
- return _u.SetTargetUserID(v.ID)
- }
- // SetAdoptionDecisionID sets the "adoption_decision" edge to the IdentityAdoptionDecision entity by ID.
- func (_u *PendingAuthSessionUpdateOne) SetAdoptionDecisionID(id int64) *PendingAuthSessionUpdateOne {
- _u.mutation.SetAdoptionDecisionID(id)
- return _u
- }
- // SetNillableAdoptionDecisionID sets the "adoption_decision" edge to the IdentityAdoptionDecision entity by ID if the given value is not nil.
- func (_u *PendingAuthSessionUpdateOne) SetNillableAdoptionDecisionID(id *int64) *PendingAuthSessionUpdateOne {
- if id != nil {
- _u = _u.SetAdoptionDecisionID(*id)
- }
- return _u
- }
- // SetAdoptionDecision sets the "adoption_decision" edge to the IdentityAdoptionDecision entity.
- func (_u *PendingAuthSessionUpdateOne) SetAdoptionDecision(v *IdentityAdoptionDecision) *PendingAuthSessionUpdateOne {
- return _u.SetAdoptionDecisionID(v.ID)
- }
- // Mutation returns the PendingAuthSessionMutation object of the builder.
- func (_u *PendingAuthSessionUpdateOne) Mutation() *PendingAuthSessionMutation {
- return _u.mutation
- }
- // ClearTargetUser clears the "target_user" edge to the User entity.
- func (_u *PendingAuthSessionUpdateOne) ClearTargetUser() *PendingAuthSessionUpdateOne {
- _u.mutation.ClearTargetUser()
- return _u
- }
- // ClearAdoptionDecision clears the "adoption_decision" edge to the IdentityAdoptionDecision entity.
- func (_u *PendingAuthSessionUpdateOne) ClearAdoptionDecision() *PendingAuthSessionUpdateOne {
- _u.mutation.ClearAdoptionDecision()
- return _u
- }
- // Where appends a list predicates to the PendingAuthSessionUpdate builder.
- func (_u *PendingAuthSessionUpdateOne) Where(ps ...predicate.PendingAuthSession) *PendingAuthSessionUpdateOne {
- _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 *PendingAuthSessionUpdateOne) Select(field string, fields ...string) *PendingAuthSessionUpdateOne {
- _u.fields = append([]string{field}, fields...)
- return _u
- }
- // Save executes the query and returns the updated PendingAuthSession entity.
- func (_u *PendingAuthSessionUpdateOne) Save(ctx context.Context) (*PendingAuthSession, error) {
- _u.defaults()
- return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (_u *PendingAuthSessionUpdateOne) SaveX(ctx context.Context) *PendingAuthSession {
- node, err := _u.Save(ctx)
- if err != nil {
- panic(err)
- }
- return node
- }
- // Exec executes the query on the entity.
- func (_u *PendingAuthSessionUpdateOne) Exec(ctx context.Context) error {
- _, err := _u.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_u *PendingAuthSessionUpdateOne) ExecX(ctx context.Context) {
- if err := _u.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (_u *PendingAuthSessionUpdateOne) defaults() {
- if _, ok := _u.mutation.UpdatedAt(); !ok {
- v := pendingauthsession.UpdateDefaultUpdatedAt()
- _u.mutation.SetUpdatedAt(v)
- }
- }
- // check runs all checks and user-defined validators on the builder.
- func (_u *PendingAuthSessionUpdateOne) check() error {
- if v, ok := _u.mutation.SessionToken(); ok {
- if err := pendingauthsession.SessionTokenValidator(v); err != nil {
- return &ValidationError{Name: "session_token", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.session_token": %w`, err)}
- }
- }
- if v, ok := _u.mutation.Intent(); ok {
- if err := pendingauthsession.IntentValidator(v); err != nil {
- return &ValidationError{Name: "intent", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.intent": %w`, err)}
- }
- }
- if v, ok := _u.mutation.ProviderType(); ok {
- if err := pendingauthsession.ProviderTypeValidator(v); err != nil {
- return &ValidationError{Name: "provider_type", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.provider_type": %w`, err)}
- }
- }
- if v, ok := _u.mutation.ProviderKey(); ok {
- if err := pendingauthsession.ProviderKeyValidator(v); err != nil {
- return &ValidationError{Name: "provider_key", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.provider_key": %w`, err)}
- }
- }
- if v, ok := _u.mutation.ProviderSubject(); ok {
- if err := pendingauthsession.ProviderSubjectValidator(v); err != nil {
- return &ValidationError{Name: "provider_subject", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.provider_subject": %w`, err)}
- }
- }
- return nil
- }
- func (_u *PendingAuthSessionUpdateOne) sqlSave(ctx context.Context) (_node *PendingAuthSession, err error) {
- if err := _u.check(); err != nil {
- return _node, err
- }
- _spec := sqlgraph.NewUpdateSpec(pendingauthsession.Table, pendingauthsession.Columns, sqlgraph.NewFieldSpec(pendingauthsession.FieldID, field.TypeInt64))
- id, ok := _u.mutation.ID()
- if !ok {
- return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PendingAuthSession.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, pendingauthsession.FieldID)
- for _, f := range fields {
- if !pendingauthsession.ValidColumn(f) {
- return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
- }
- if f != pendingauthsession.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.UpdatedAt(); ok {
- _spec.SetField(pendingauthsession.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := _u.mutation.SessionToken(); ok {
- _spec.SetField(pendingauthsession.FieldSessionToken, field.TypeString, value)
- }
- if value, ok := _u.mutation.Intent(); ok {
- _spec.SetField(pendingauthsession.FieldIntent, field.TypeString, value)
- }
- if value, ok := _u.mutation.ProviderType(); ok {
- _spec.SetField(pendingauthsession.FieldProviderType, field.TypeString, value)
- }
- if value, ok := _u.mutation.ProviderKey(); ok {
- _spec.SetField(pendingauthsession.FieldProviderKey, field.TypeString, value)
- }
- if value, ok := _u.mutation.ProviderSubject(); ok {
- _spec.SetField(pendingauthsession.FieldProviderSubject, field.TypeString, value)
- }
- if value, ok := _u.mutation.RedirectTo(); ok {
- _spec.SetField(pendingauthsession.FieldRedirectTo, field.TypeString, value)
- }
- if value, ok := _u.mutation.ResolvedEmail(); ok {
- _spec.SetField(pendingauthsession.FieldResolvedEmail, field.TypeString, value)
- }
- if value, ok := _u.mutation.RegistrationPasswordHash(); ok {
- _spec.SetField(pendingauthsession.FieldRegistrationPasswordHash, field.TypeString, value)
- }
- if value, ok := _u.mutation.UpstreamIdentityClaims(); ok {
- _spec.SetField(pendingauthsession.FieldUpstreamIdentityClaims, field.TypeJSON, value)
- }
- if value, ok := _u.mutation.LocalFlowState(); ok {
- _spec.SetField(pendingauthsession.FieldLocalFlowState, field.TypeJSON, value)
- }
- if value, ok := _u.mutation.BrowserSessionKey(); ok {
- _spec.SetField(pendingauthsession.FieldBrowserSessionKey, field.TypeString, value)
- }
- if value, ok := _u.mutation.CompletionCodeHash(); ok {
- _spec.SetField(pendingauthsession.FieldCompletionCodeHash, field.TypeString, value)
- }
- if value, ok := _u.mutation.CompletionCodeExpiresAt(); ok {
- _spec.SetField(pendingauthsession.FieldCompletionCodeExpiresAt, field.TypeTime, value)
- }
- if _u.mutation.CompletionCodeExpiresAtCleared() {
- _spec.ClearField(pendingauthsession.FieldCompletionCodeExpiresAt, field.TypeTime)
- }
- if value, ok := _u.mutation.EmailVerifiedAt(); ok {
- _spec.SetField(pendingauthsession.FieldEmailVerifiedAt, field.TypeTime, value)
- }
- if _u.mutation.EmailVerifiedAtCleared() {
- _spec.ClearField(pendingauthsession.FieldEmailVerifiedAt, field.TypeTime)
- }
- if value, ok := _u.mutation.PasswordVerifiedAt(); ok {
- _spec.SetField(pendingauthsession.FieldPasswordVerifiedAt, field.TypeTime, value)
- }
- if _u.mutation.PasswordVerifiedAtCleared() {
- _spec.ClearField(pendingauthsession.FieldPasswordVerifiedAt, field.TypeTime)
- }
- if value, ok := _u.mutation.TotpVerifiedAt(); ok {
- _spec.SetField(pendingauthsession.FieldTotpVerifiedAt, field.TypeTime, value)
- }
- if _u.mutation.TotpVerifiedAtCleared() {
- _spec.ClearField(pendingauthsession.FieldTotpVerifiedAt, field.TypeTime)
- }
- if value, ok := _u.mutation.ExpiresAt(); ok {
- _spec.SetField(pendingauthsession.FieldExpiresAt, field.TypeTime, value)
- }
- if value, ok := _u.mutation.ConsumedAt(); ok {
- _spec.SetField(pendingauthsession.FieldConsumedAt, field.TypeTime, value)
- }
- if _u.mutation.ConsumedAtCleared() {
- _spec.ClearField(pendingauthsession.FieldConsumedAt, field.TypeTime)
- }
- if _u.mutation.TargetUserCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: pendingauthsession.TargetUserTable,
- Columns: []string{pendingauthsession.TargetUserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.TargetUserIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: pendingauthsession.TargetUserTable,
- Columns: []string{pendingauthsession.TargetUserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _u.mutation.AdoptionDecisionCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2O,
- Inverse: false,
- Table: pendingauthsession.AdoptionDecisionTable,
- Columns: []string{pendingauthsession.AdoptionDecisionColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(identityadoptiondecision.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.AdoptionDecisionIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2O,
- Inverse: false,
- Table: pendingauthsession.AdoptionDecisionTable,
- Columns: []string{pendingauthsession.AdoptionDecisionColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(identityadoptiondecision.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- _node = &PendingAuthSession{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{pendingauthsession.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- _u.mutation.done = true
- return _node, nil
- }
|