feat(sync): full code sync from release
This commit is contained in:
676
backend/ent/idempotencyrecord_update.go
Normal file
676
backend/ent/idempotencyrecord_update.go
Normal file
@@ -0,0 +1,676 @@
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user