| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676 |
- // 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/idempotencyrecord"
- "github.com/Wei-Shaw/sub2api/ent/predicate"
- )
- // IdempotencyRecordUpdate is the builder for updating IdempotencyRecord entities.
- type IdempotencyRecordUpdate struct {
- config
- hooks []Hook
- mutation *IdempotencyRecordMutation
- }
- // Where appends a list predicates to the IdempotencyRecordUpdate builder.
- func (_u *IdempotencyRecordUpdate) Where(ps ...predicate.IdempotencyRecord) *IdempotencyRecordUpdate {
- _u.mutation.Where(ps...)
- return _u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (_u *IdempotencyRecordUpdate) SetUpdatedAt(v time.Time) *IdempotencyRecordUpdate {
- _u.mutation.SetUpdatedAt(v)
- return _u
- }
- // SetScope sets the "scope" field.
- func (_u *IdempotencyRecordUpdate) SetScope(v string) *IdempotencyRecordUpdate {
- _u.mutation.SetScope(v)
- return _u
- }
- // SetNillableScope sets the "scope" field if the given value is not nil.
- func (_u *IdempotencyRecordUpdate) SetNillableScope(v *string) *IdempotencyRecordUpdate {
- if v != nil {
- _u.SetScope(*v)
- }
- return _u
- }
- // SetIdempotencyKeyHash sets the "idempotency_key_hash" field.
- func (_u *IdempotencyRecordUpdate) SetIdempotencyKeyHash(v string) *IdempotencyRecordUpdate {
- _u.mutation.SetIdempotencyKeyHash(v)
- return _u
- }
- // SetNillableIdempotencyKeyHash sets the "idempotency_key_hash" field if the given value is not nil.
- func (_u *IdempotencyRecordUpdate) SetNillableIdempotencyKeyHash(v *string) *IdempotencyRecordUpdate {
- if v != nil {
- _u.SetIdempotencyKeyHash(*v)
- }
- return _u
- }
- // SetRequestFingerprint sets the "request_fingerprint" field.
- func (_u *IdempotencyRecordUpdate) SetRequestFingerprint(v string) *IdempotencyRecordUpdate {
- _u.mutation.SetRequestFingerprint(v)
- return _u
- }
- // SetNillableRequestFingerprint sets the "request_fingerprint" field if the given value is not nil.
- func (_u *IdempotencyRecordUpdate) SetNillableRequestFingerprint(v *string) *IdempotencyRecordUpdate {
- if v != nil {
- _u.SetRequestFingerprint(*v)
- }
- return _u
- }
- // SetStatus sets the "status" field.
- func (_u *IdempotencyRecordUpdate) SetStatus(v string) *IdempotencyRecordUpdate {
- _u.mutation.SetStatus(v)
- return _u
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (_u *IdempotencyRecordUpdate) SetNillableStatus(v *string) *IdempotencyRecordUpdate {
- if v != nil {
- _u.SetStatus(*v)
- }
- return _u
- }
- // SetResponseStatus sets the "response_status" field.
- func (_u *IdempotencyRecordUpdate) SetResponseStatus(v int) *IdempotencyRecordUpdate {
- _u.mutation.ResetResponseStatus()
- _u.mutation.SetResponseStatus(v)
- return _u
- }
- // SetNillableResponseStatus sets the "response_status" field if the given value is not nil.
- func (_u *IdempotencyRecordUpdate) SetNillableResponseStatus(v *int) *IdempotencyRecordUpdate {
- if v != nil {
- _u.SetResponseStatus(*v)
- }
- return _u
- }
- // AddResponseStatus adds value to the "response_status" field.
- func (_u *IdempotencyRecordUpdate) AddResponseStatus(v int) *IdempotencyRecordUpdate {
- _u.mutation.AddResponseStatus(v)
- return _u
- }
- // ClearResponseStatus clears the value of the "response_status" field.
- func (_u *IdempotencyRecordUpdate) ClearResponseStatus() *IdempotencyRecordUpdate {
- _u.mutation.ClearResponseStatus()
- return _u
- }
- // SetResponseBody sets the "response_body" field.
- func (_u *IdempotencyRecordUpdate) SetResponseBody(v string) *IdempotencyRecordUpdate {
- _u.mutation.SetResponseBody(v)
- return _u
- }
- // SetNillableResponseBody sets the "response_body" field if the given value is not nil.
- func (_u *IdempotencyRecordUpdate) SetNillableResponseBody(v *string) *IdempotencyRecordUpdate {
- if v != nil {
- _u.SetResponseBody(*v)
- }
- return _u
- }
- // ClearResponseBody clears the value of the "response_body" field.
- func (_u *IdempotencyRecordUpdate) ClearResponseBody() *IdempotencyRecordUpdate {
- _u.mutation.ClearResponseBody()
- return _u
- }
- // SetErrorReason sets the "error_reason" field.
- func (_u *IdempotencyRecordUpdate) SetErrorReason(v string) *IdempotencyRecordUpdate {
- _u.mutation.SetErrorReason(v)
- return _u
- }
- // SetNillableErrorReason sets the "error_reason" field if the given value is not nil.
- func (_u *IdempotencyRecordUpdate) SetNillableErrorReason(v *string) *IdempotencyRecordUpdate {
- if v != nil {
- _u.SetErrorReason(*v)
- }
- return _u
- }
- // ClearErrorReason clears the value of the "error_reason" field.
- func (_u *IdempotencyRecordUpdate) ClearErrorReason() *IdempotencyRecordUpdate {
- _u.mutation.ClearErrorReason()
- return _u
- }
- // SetLockedUntil sets the "locked_until" field.
- func (_u *IdempotencyRecordUpdate) SetLockedUntil(v time.Time) *IdempotencyRecordUpdate {
- _u.mutation.SetLockedUntil(v)
- return _u
- }
- // SetNillableLockedUntil sets the "locked_until" field if the given value is not nil.
- func (_u *IdempotencyRecordUpdate) SetNillableLockedUntil(v *time.Time) *IdempotencyRecordUpdate {
- if v != nil {
- _u.SetLockedUntil(*v)
- }
- return _u
- }
- // ClearLockedUntil clears the value of the "locked_until" field.
- func (_u *IdempotencyRecordUpdate) ClearLockedUntil() *IdempotencyRecordUpdate {
- _u.mutation.ClearLockedUntil()
- return _u
- }
- // SetExpiresAt sets the "expires_at" field.
- func (_u *IdempotencyRecordUpdate) SetExpiresAt(v time.Time) *IdempotencyRecordUpdate {
- _u.mutation.SetExpiresAt(v)
- return _u
- }
- // SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
- func (_u *IdempotencyRecordUpdate) SetNillableExpiresAt(v *time.Time) *IdempotencyRecordUpdate {
- if v != nil {
- _u.SetExpiresAt(*v)
- }
- return _u
- }
- // Mutation returns the IdempotencyRecordMutation object of the builder.
- func (_u *IdempotencyRecordUpdate) Mutation() *IdempotencyRecordMutation {
- return _u.mutation
- }
- // Save executes the query and returns the number of nodes affected by the update operation.
- func (_u *IdempotencyRecordUpdate) 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 *IdempotencyRecordUpdate) SaveX(ctx context.Context) int {
- affected, err := _u.Save(ctx)
- if err != nil {
- panic(err)
- }
- return affected
- }
- // Exec executes the query.
- func (_u *IdempotencyRecordUpdate) Exec(ctx context.Context) error {
- _, err := _u.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_u *IdempotencyRecordUpdate) 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 *IdempotencyRecordUpdate) defaults() {
- if _, ok := _u.mutation.UpdatedAt(); !ok {
- v := idempotencyrecord.UpdateDefaultUpdatedAt()
- _u.mutation.SetUpdatedAt(v)
- }
- }
- // check runs all checks and user-defined validators on the builder.
- func (_u *IdempotencyRecordUpdate) check() error {
- if v, ok := _u.mutation.Scope(); ok {
- if err := idempotencyrecord.ScopeValidator(v); err != nil {
- return &ValidationError{Name: "scope", err: fmt.Errorf(`ent: validator failed for field "IdempotencyRecord.scope": %w`, err)}
- }
- }
- if v, ok := _u.mutation.IdempotencyKeyHash(); ok {
- if err := idempotencyrecord.IdempotencyKeyHashValidator(v); err != nil {
- return &ValidationError{Name: "idempotency_key_hash", err: fmt.Errorf(`ent: validator failed for field "IdempotencyRecord.idempotency_key_hash": %w`, err)}
- }
- }
- if v, ok := _u.mutation.RequestFingerprint(); ok {
- if err := idempotencyrecord.RequestFingerprintValidator(v); err != nil {
- return &ValidationError{Name: "request_fingerprint", err: fmt.Errorf(`ent: validator failed for field "IdempotencyRecord.request_fingerprint": %w`, err)}
- }
- }
- if v, ok := _u.mutation.Status(); ok {
- if err := idempotencyrecord.StatusValidator(v); err != nil {
- return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "IdempotencyRecord.status": %w`, err)}
- }
- }
- if v, ok := _u.mutation.ErrorReason(); ok {
- if err := idempotencyrecord.ErrorReasonValidator(v); err != nil {
- return &ValidationError{Name: "error_reason", err: fmt.Errorf(`ent: validator failed for field "IdempotencyRecord.error_reason": %w`, err)}
- }
- }
- return nil
- }
- func (_u *IdempotencyRecordUpdate) sqlSave(ctx context.Context) (_node int, err error) {
- if err := _u.check(); err != nil {
- return _node, err
- }
- _spec := sqlgraph.NewUpdateSpec(idempotencyrecord.Table, idempotencyrecord.Columns, sqlgraph.NewFieldSpec(idempotencyrecord.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(idempotencyrecord.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := _u.mutation.Scope(); ok {
- _spec.SetField(idempotencyrecord.FieldScope, field.TypeString, value)
- }
- if value, ok := _u.mutation.IdempotencyKeyHash(); ok {
- _spec.SetField(idempotencyrecord.FieldIdempotencyKeyHash, field.TypeString, value)
- }
- if value, ok := _u.mutation.RequestFingerprint(); ok {
- _spec.SetField(idempotencyrecord.FieldRequestFingerprint, field.TypeString, value)
- }
- if value, ok := _u.mutation.Status(); ok {
- _spec.SetField(idempotencyrecord.FieldStatus, field.TypeString, value)
- }
- if value, ok := _u.mutation.ResponseStatus(); ok {
- _spec.SetField(idempotencyrecord.FieldResponseStatus, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedResponseStatus(); ok {
- _spec.AddField(idempotencyrecord.FieldResponseStatus, field.TypeInt, value)
- }
- if _u.mutation.ResponseStatusCleared() {
- _spec.ClearField(idempotencyrecord.FieldResponseStatus, field.TypeInt)
- }
- if value, ok := _u.mutation.ResponseBody(); ok {
- _spec.SetField(idempotencyrecord.FieldResponseBody, field.TypeString, value)
- }
- if _u.mutation.ResponseBodyCleared() {
- _spec.ClearField(idempotencyrecord.FieldResponseBody, field.TypeString)
- }
- if value, ok := _u.mutation.ErrorReason(); ok {
- _spec.SetField(idempotencyrecord.FieldErrorReason, field.TypeString, value)
- }
- if _u.mutation.ErrorReasonCleared() {
- _spec.ClearField(idempotencyrecord.FieldErrorReason, field.TypeString)
- }
- if value, ok := _u.mutation.LockedUntil(); ok {
- _spec.SetField(idempotencyrecord.FieldLockedUntil, field.TypeTime, value)
- }
- if _u.mutation.LockedUntilCleared() {
- _spec.ClearField(idempotencyrecord.FieldLockedUntil, field.TypeTime)
- }
- if value, ok := _u.mutation.ExpiresAt(); ok {
- _spec.SetField(idempotencyrecord.FieldExpiresAt, field.TypeTime, value)
- }
- if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{idempotencyrecord.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return 0, err
- }
- _u.mutation.done = true
- return _node, nil
- }
- // IdempotencyRecordUpdateOne is the builder for updating a single IdempotencyRecord entity.
- type IdempotencyRecordUpdateOne struct {
- config
- fields []string
- hooks []Hook
- mutation *IdempotencyRecordMutation
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (_u *IdempotencyRecordUpdateOne) SetUpdatedAt(v time.Time) *IdempotencyRecordUpdateOne {
- _u.mutation.SetUpdatedAt(v)
- return _u
- }
- // SetScope sets the "scope" field.
- func (_u *IdempotencyRecordUpdateOne) SetScope(v string) *IdempotencyRecordUpdateOne {
- _u.mutation.SetScope(v)
- return _u
- }
- // SetNillableScope sets the "scope" field if the given value is not nil.
- func (_u *IdempotencyRecordUpdateOne) SetNillableScope(v *string) *IdempotencyRecordUpdateOne {
- if v != nil {
- _u.SetScope(*v)
- }
- return _u
- }
- // SetIdempotencyKeyHash sets the "idempotency_key_hash" field.
- func (_u *IdempotencyRecordUpdateOne) SetIdempotencyKeyHash(v string) *IdempotencyRecordUpdateOne {
- _u.mutation.SetIdempotencyKeyHash(v)
- return _u
- }
- // SetNillableIdempotencyKeyHash sets the "idempotency_key_hash" field if the given value is not nil.
- func (_u *IdempotencyRecordUpdateOne) SetNillableIdempotencyKeyHash(v *string) *IdempotencyRecordUpdateOne {
- if v != nil {
- _u.SetIdempotencyKeyHash(*v)
- }
- return _u
- }
- // SetRequestFingerprint sets the "request_fingerprint" field.
- func (_u *IdempotencyRecordUpdateOne) SetRequestFingerprint(v string) *IdempotencyRecordUpdateOne {
- _u.mutation.SetRequestFingerprint(v)
- return _u
- }
- // SetNillableRequestFingerprint sets the "request_fingerprint" field if the given value is not nil.
- func (_u *IdempotencyRecordUpdateOne) SetNillableRequestFingerprint(v *string) *IdempotencyRecordUpdateOne {
- if v != nil {
- _u.SetRequestFingerprint(*v)
- }
- return _u
- }
- // SetStatus sets the "status" field.
- func (_u *IdempotencyRecordUpdateOne) SetStatus(v string) *IdempotencyRecordUpdateOne {
- _u.mutation.SetStatus(v)
- return _u
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (_u *IdempotencyRecordUpdateOne) SetNillableStatus(v *string) *IdempotencyRecordUpdateOne {
- if v != nil {
- _u.SetStatus(*v)
- }
- return _u
- }
- // SetResponseStatus sets the "response_status" field.
- func (_u *IdempotencyRecordUpdateOne) SetResponseStatus(v int) *IdempotencyRecordUpdateOne {
- _u.mutation.ResetResponseStatus()
- _u.mutation.SetResponseStatus(v)
- return _u
- }
- // SetNillableResponseStatus sets the "response_status" field if the given value is not nil.
- func (_u *IdempotencyRecordUpdateOne) SetNillableResponseStatus(v *int) *IdempotencyRecordUpdateOne {
- if v != nil {
- _u.SetResponseStatus(*v)
- }
- return _u
- }
- // AddResponseStatus adds value to the "response_status" field.
- func (_u *IdempotencyRecordUpdateOne) AddResponseStatus(v int) *IdempotencyRecordUpdateOne {
- _u.mutation.AddResponseStatus(v)
- return _u
- }
- // ClearResponseStatus clears the value of the "response_status" field.
- func (_u *IdempotencyRecordUpdateOne) ClearResponseStatus() *IdempotencyRecordUpdateOne {
- _u.mutation.ClearResponseStatus()
- return _u
- }
- // SetResponseBody sets the "response_body" field.
- func (_u *IdempotencyRecordUpdateOne) SetResponseBody(v string) *IdempotencyRecordUpdateOne {
- _u.mutation.SetResponseBody(v)
- return _u
- }
- // SetNillableResponseBody sets the "response_body" field if the given value is not nil.
- func (_u *IdempotencyRecordUpdateOne) SetNillableResponseBody(v *string) *IdempotencyRecordUpdateOne {
- if v != nil {
- _u.SetResponseBody(*v)
- }
- return _u
- }
- // ClearResponseBody clears the value of the "response_body" field.
- func (_u *IdempotencyRecordUpdateOne) ClearResponseBody() *IdempotencyRecordUpdateOne {
- _u.mutation.ClearResponseBody()
- return _u
- }
- // SetErrorReason sets the "error_reason" field.
- func (_u *IdempotencyRecordUpdateOne) SetErrorReason(v string) *IdempotencyRecordUpdateOne {
- _u.mutation.SetErrorReason(v)
- return _u
- }
- // SetNillableErrorReason sets the "error_reason" field if the given value is not nil.
- func (_u *IdempotencyRecordUpdateOne) SetNillableErrorReason(v *string) *IdempotencyRecordUpdateOne {
- if v != nil {
- _u.SetErrorReason(*v)
- }
- return _u
- }
- // ClearErrorReason clears the value of the "error_reason" field.
- func (_u *IdempotencyRecordUpdateOne) ClearErrorReason() *IdempotencyRecordUpdateOne {
- _u.mutation.ClearErrorReason()
- return _u
- }
- // SetLockedUntil sets the "locked_until" field.
- func (_u *IdempotencyRecordUpdateOne) SetLockedUntil(v time.Time) *IdempotencyRecordUpdateOne {
- _u.mutation.SetLockedUntil(v)
- return _u
- }
- // SetNillableLockedUntil sets the "locked_until" field if the given value is not nil.
- func (_u *IdempotencyRecordUpdateOne) SetNillableLockedUntil(v *time.Time) *IdempotencyRecordUpdateOne {
- if v != nil {
- _u.SetLockedUntil(*v)
- }
- return _u
- }
- // ClearLockedUntil clears the value of the "locked_until" field.
- func (_u *IdempotencyRecordUpdateOne) ClearLockedUntil() *IdempotencyRecordUpdateOne {
- _u.mutation.ClearLockedUntil()
- return _u
- }
- // SetExpiresAt sets the "expires_at" field.
- func (_u *IdempotencyRecordUpdateOne) SetExpiresAt(v time.Time) *IdempotencyRecordUpdateOne {
- _u.mutation.SetExpiresAt(v)
- return _u
- }
- // SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
- func (_u *IdempotencyRecordUpdateOne) SetNillableExpiresAt(v *time.Time) *IdempotencyRecordUpdateOne {
- if v != nil {
- _u.SetExpiresAt(*v)
- }
- return _u
- }
- // Mutation returns the IdempotencyRecordMutation object of the builder.
- func (_u *IdempotencyRecordUpdateOne) Mutation() *IdempotencyRecordMutation {
- return _u.mutation
- }
- // Where appends a list predicates to the IdempotencyRecordUpdate builder.
- func (_u *IdempotencyRecordUpdateOne) Where(ps ...predicate.IdempotencyRecord) *IdempotencyRecordUpdateOne {
- _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 *IdempotencyRecordUpdateOne) Select(field string, fields ...string) *IdempotencyRecordUpdateOne {
- _u.fields = append([]string{field}, fields...)
- return _u
- }
- // Save executes the query and returns the updated IdempotencyRecord entity.
- func (_u *IdempotencyRecordUpdateOne) Save(ctx context.Context) (*IdempotencyRecord, error) {
- _u.defaults()
- return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (_u *IdempotencyRecordUpdateOne) SaveX(ctx context.Context) *IdempotencyRecord {
- node, err := _u.Save(ctx)
- if err != nil {
- panic(err)
- }
- return node
- }
- // Exec executes the query on the entity.
- func (_u *IdempotencyRecordUpdateOne) Exec(ctx context.Context) error {
- _, err := _u.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_u *IdempotencyRecordUpdateOne) 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 *IdempotencyRecordUpdateOne) defaults() {
- if _, ok := _u.mutation.UpdatedAt(); !ok {
- v := idempotencyrecord.UpdateDefaultUpdatedAt()
- _u.mutation.SetUpdatedAt(v)
- }
- }
- // check runs all checks and user-defined validators on the builder.
- func (_u *IdempotencyRecordUpdateOne) check() error {
- if v, ok := _u.mutation.Scope(); ok {
- if err := idempotencyrecord.ScopeValidator(v); err != nil {
- return &ValidationError{Name: "scope", err: fmt.Errorf(`ent: validator failed for field "IdempotencyRecord.scope": %w`, err)}
- }
- }
- if v, ok := _u.mutation.IdempotencyKeyHash(); ok {
- if err := idempotencyrecord.IdempotencyKeyHashValidator(v); err != nil {
- return &ValidationError{Name: "idempotency_key_hash", err: fmt.Errorf(`ent: validator failed for field "IdempotencyRecord.idempotency_key_hash": %w`, err)}
- }
- }
- if v, ok := _u.mutation.RequestFingerprint(); ok {
- if err := idempotencyrecord.RequestFingerprintValidator(v); err != nil {
- return &ValidationError{Name: "request_fingerprint", err: fmt.Errorf(`ent: validator failed for field "IdempotencyRecord.request_fingerprint": %w`, err)}
- }
- }
- if v, ok := _u.mutation.Status(); ok {
- if err := idempotencyrecord.StatusValidator(v); err != nil {
- return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "IdempotencyRecord.status": %w`, err)}
- }
- }
- if v, ok := _u.mutation.ErrorReason(); ok {
- if err := idempotencyrecord.ErrorReasonValidator(v); err != nil {
- return &ValidationError{Name: "error_reason", err: fmt.Errorf(`ent: validator failed for field "IdempotencyRecord.error_reason": %w`, err)}
- }
- }
- return nil
- }
- func (_u *IdempotencyRecordUpdateOne) sqlSave(ctx context.Context) (_node *IdempotencyRecord, err error) {
- if err := _u.check(); err != nil {
- return _node, err
- }
- _spec := sqlgraph.NewUpdateSpec(idempotencyrecord.Table, idempotencyrecord.Columns, sqlgraph.NewFieldSpec(idempotencyrecord.FieldID, field.TypeInt64))
- id, ok := _u.mutation.ID()
- if !ok {
- return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "IdempotencyRecord.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, idempotencyrecord.FieldID)
- for _, f := range fields {
- if !idempotencyrecord.ValidColumn(f) {
- return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
- }
- if f != idempotencyrecord.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(idempotencyrecord.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := _u.mutation.Scope(); ok {
- _spec.SetField(idempotencyrecord.FieldScope, field.TypeString, value)
- }
- if value, ok := _u.mutation.IdempotencyKeyHash(); ok {
- _spec.SetField(idempotencyrecord.FieldIdempotencyKeyHash, field.TypeString, value)
- }
- if value, ok := _u.mutation.RequestFingerprint(); ok {
- _spec.SetField(idempotencyrecord.FieldRequestFingerprint, field.TypeString, value)
- }
- if value, ok := _u.mutation.Status(); ok {
- _spec.SetField(idempotencyrecord.FieldStatus, field.TypeString, value)
- }
- if value, ok := _u.mutation.ResponseStatus(); ok {
- _spec.SetField(idempotencyrecord.FieldResponseStatus, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedResponseStatus(); ok {
- _spec.AddField(idempotencyrecord.FieldResponseStatus, field.TypeInt, value)
- }
- if _u.mutation.ResponseStatusCleared() {
- _spec.ClearField(idempotencyrecord.FieldResponseStatus, field.TypeInt)
- }
- if value, ok := _u.mutation.ResponseBody(); ok {
- _spec.SetField(idempotencyrecord.FieldResponseBody, field.TypeString, value)
- }
- if _u.mutation.ResponseBodyCleared() {
- _spec.ClearField(idempotencyrecord.FieldResponseBody, field.TypeString)
- }
- if value, ok := _u.mutation.ErrorReason(); ok {
- _spec.SetField(idempotencyrecord.FieldErrorReason, field.TypeString, value)
- }
- if _u.mutation.ErrorReasonCleared() {
- _spec.ClearField(idempotencyrecord.FieldErrorReason, field.TypeString)
- }
- if value, ok := _u.mutation.LockedUntil(); ok {
- _spec.SetField(idempotencyrecord.FieldLockedUntil, field.TypeTime, value)
- }
- if _u.mutation.LockedUntilCleared() {
- _spec.ClearField(idempotencyrecord.FieldLockedUntil, field.TypeTime)
- }
- if value, ok := _u.mutation.ExpiresAt(); ok {
- _spec.SetField(idempotencyrecord.FieldExpiresAt, field.TypeTime, value)
- }
- _node = &IdempotencyRecord{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{idempotencyrecord.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- _u.mutation.done = true
- return _node, nil
- }
|