// Code generated by ent, DO NOT EDIT. package ent import ( "fmt" "strings" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/Wei-Shaw/sub2api/ent/idempotencyrecord" ) // IdempotencyRecord is the model entity for the IdempotencyRecord schema. type IdempotencyRecord struct { config `json:"-"` // ID of the ent. ID int64 `json:"id,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt time.Time `json:"created_at,omitempty"` // UpdatedAt holds the value of the "updated_at" field. UpdatedAt time.Time `json:"updated_at,omitempty"` // Scope holds the value of the "scope" field. Scope string `json:"scope,omitempty"` // IdempotencyKeyHash holds the value of the "idempotency_key_hash" field. IdempotencyKeyHash string `json:"idempotency_key_hash,omitempty"` // RequestFingerprint holds the value of the "request_fingerprint" field. RequestFingerprint string `json:"request_fingerprint,omitempty"` // Status holds the value of the "status" field. Status string `json:"status,omitempty"` // ResponseStatus holds the value of the "response_status" field. ResponseStatus *int `json:"response_status,omitempty"` // ResponseBody holds the value of the "response_body" field. ResponseBody *string `json:"response_body,omitempty"` // ErrorReason holds the value of the "error_reason" field. ErrorReason *string `json:"error_reason,omitempty"` // LockedUntil holds the value of the "locked_until" field. LockedUntil *time.Time `json:"locked_until,omitempty"` // ExpiresAt holds the value of the "expires_at" field. ExpiresAt time.Time `json:"expires_at,omitempty"` selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. func (*IdempotencyRecord) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case idempotencyrecord.FieldID, idempotencyrecord.FieldResponseStatus: values[i] = new(sql.NullInt64) case idempotencyrecord.FieldScope, idempotencyrecord.FieldIdempotencyKeyHash, idempotencyrecord.FieldRequestFingerprint, idempotencyrecord.FieldStatus, idempotencyrecord.FieldResponseBody, idempotencyrecord.FieldErrorReason: values[i] = new(sql.NullString) case idempotencyrecord.FieldCreatedAt, idempotencyrecord.FieldUpdatedAt, idempotencyrecord.FieldLockedUntil, idempotencyrecord.FieldExpiresAt: values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) } } return values, nil } // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the IdempotencyRecord fields. func (_m *IdempotencyRecord) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } for i := range columns { switch columns[i] { case idempotencyrecord.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } _m.ID = int64(value.Int64) case idempotencyrecord.FieldCreatedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field created_at", values[i]) } else if value.Valid { _m.CreatedAt = value.Time } case idempotencyrecord.FieldUpdatedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field updated_at", values[i]) } else if value.Valid { _m.UpdatedAt = value.Time } case idempotencyrecord.FieldScope: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field scope", values[i]) } else if value.Valid { _m.Scope = value.String } case idempotencyrecord.FieldIdempotencyKeyHash: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field idempotency_key_hash", values[i]) } else if value.Valid { _m.IdempotencyKeyHash = value.String } case idempotencyrecord.FieldRequestFingerprint: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field request_fingerprint", values[i]) } else if value.Valid { _m.RequestFingerprint = value.String } case idempotencyrecord.FieldStatus: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field status", values[i]) } else if value.Valid { _m.Status = value.String } case idempotencyrecord.FieldResponseStatus: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field response_status", values[i]) } else if value.Valid { _m.ResponseStatus = new(int) *_m.ResponseStatus = int(value.Int64) } case idempotencyrecord.FieldResponseBody: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field response_body", values[i]) } else if value.Valid { _m.ResponseBody = new(string) *_m.ResponseBody = value.String } case idempotencyrecord.FieldErrorReason: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field error_reason", values[i]) } else if value.Valid { _m.ErrorReason = new(string) *_m.ErrorReason = value.String } case idempotencyrecord.FieldLockedUntil: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field locked_until", values[i]) } else if value.Valid { _m.LockedUntil = new(time.Time) *_m.LockedUntil = value.Time } case idempotencyrecord.FieldExpiresAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field expires_at", values[i]) } else if value.Valid { _m.ExpiresAt = value.Time } default: _m.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the IdempotencyRecord. // This includes values selected through modifiers, order, etc. func (_m *IdempotencyRecord) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } // Update returns a builder for updating this IdempotencyRecord. // Note that you need to call IdempotencyRecord.Unwrap() before calling this method if this IdempotencyRecord // was returned from a transaction, and the transaction was committed or rolled back. func (_m *IdempotencyRecord) Update() *IdempotencyRecordUpdateOne { return NewIdempotencyRecordClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the IdempotencyRecord entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. func (_m *IdempotencyRecord) Unwrap() *IdempotencyRecord { _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: IdempotencyRecord is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. func (_m *IdempotencyRecord) String() string { var builder strings.Builder builder.WriteString("IdempotencyRecord(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("created_at=") builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("updated_at=") builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("scope=") builder.WriteString(_m.Scope) builder.WriteString(", ") builder.WriteString("idempotency_key_hash=") builder.WriteString(_m.IdempotencyKeyHash) builder.WriteString(", ") builder.WriteString("request_fingerprint=") builder.WriteString(_m.RequestFingerprint) builder.WriteString(", ") builder.WriteString("status=") builder.WriteString(_m.Status) builder.WriteString(", ") if v := _m.ResponseStatus; v != nil { builder.WriteString("response_status=") builder.WriteString(fmt.Sprintf("%v", *v)) } builder.WriteString(", ") if v := _m.ResponseBody; v != nil { builder.WriteString("response_body=") builder.WriteString(*v) } builder.WriteString(", ") if v := _m.ErrorReason; v != nil { builder.WriteString("error_reason=") builder.WriteString(*v) } builder.WriteString(", ") if v := _m.LockedUntil; v != nil { builder.WriteString("locked_until=") builder.WriteString(v.Format(time.ANSIC)) } builder.WriteString(", ") builder.WriteString("expires_at=") builder.WriteString(_m.ExpiresAt.Format(time.ANSIC)) builder.WriteByte(')') return builder.String() } // IdempotencyRecords is a parsable slice of IdempotencyRecord. type IdempotencyRecords []*IdempotencyRecord