idempotencyrecord_create.go 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "time"
  8. "entgo.io/ent/dialect/sql"
  9. "entgo.io/ent/dialect/sql/sqlgraph"
  10. "entgo.io/ent/schema/field"
  11. "github.com/Wei-Shaw/sub2api/ent/idempotencyrecord"
  12. )
  13. // IdempotencyRecordCreate is the builder for creating a IdempotencyRecord entity.
  14. type IdempotencyRecordCreate struct {
  15. config
  16. mutation *IdempotencyRecordMutation
  17. hooks []Hook
  18. conflict []sql.ConflictOption
  19. }
  20. // SetCreatedAt sets the "created_at" field.
  21. func (_c *IdempotencyRecordCreate) SetCreatedAt(v time.Time) *IdempotencyRecordCreate {
  22. _c.mutation.SetCreatedAt(v)
  23. return _c
  24. }
  25. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  26. func (_c *IdempotencyRecordCreate) SetNillableCreatedAt(v *time.Time) *IdempotencyRecordCreate {
  27. if v != nil {
  28. _c.SetCreatedAt(*v)
  29. }
  30. return _c
  31. }
  32. // SetUpdatedAt sets the "updated_at" field.
  33. func (_c *IdempotencyRecordCreate) SetUpdatedAt(v time.Time) *IdempotencyRecordCreate {
  34. _c.mutation.SetUpdatedAt(v)
  35. return _c
  36. }
  37. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  38. func (_c *IdempotencyRecordCreate) SetNillableUpdatedAt(v *time.Time) *IdempotencyRecordCreate {
  39. if v != nil {
  40. _c.SetUpdatedAt(*v)
  41. }
  42. return _c
  43. }
  44. // SetScope sets the "scope" field.
  45. func (_c *IdempotencyRecordCreate) SetScope(v string) *IdempotencyRecordCreate {
  46. _c.mutation.SetScope(v)
  47. return _c
  48. }
  49. // SetIdempotencyKeyHash sets the "idempotency_key_hash" field.
  50. func (_c *IdempotencyRecordCreate) SetIdempotencyKeyHash(v string) *IdempotencyRecordCreate {
  51. _c.mutation.SetIdempotencyKeyHash(v)
  52. return _c
  53. }
  54. // SetRequestFingerprint sets the "request_fingerprint" field.
  55. func (_c *IdempotencyRecordCreate) SetRequestFingerprint(v string) *IdempotencyRecordCreate {
  56. _c.mutation.SetRequestFingerprint(v)
  57. return _c
  58. }
  59. // SetStatus sets the "status" field.
  60. func (_c *IdempotencyRecordCreate) SetStatus(v string) *IdempotencyRecordCreate {
  61. _c.mutation.SetStatus(v)
  62. return _c
  63. }
  64. // SetResponseStatus sets the "response_status" field.
  65. func (_c *IdempotencyRecordCreate) SetResponseStatus(v int) *IdempotencyRecordCreate {
  66. _c.mutation.SetResponseStatus(v)
  67. return _c
  68. }
  69. // SetNillableResponseStatus sets the "response_status" field if the given value is not nil.
  70. func (_c *IdempotencyRecordCreate) SetNillableResponseStatus(v *int) *IdempotencyRecordCreate {
  71. if v != nil {
  72. _c.SetResponseStatus(*v)
  73. }
  74. return _c
  75. }
  76. // SetResponseBody sets the "response_body" field.
  77. func (_c *IdempotencyRecordCreate) SetResponseBody(v string) *IdempotencyRecordCreate {
  78. _c.mutation.SetResponseBody(v)
  79. return _c
  80. }
  81. // SetNillableResponseBody sets the "response_body" field if the given value is not nil.
  82. func (_c *IdempotencyRecordCreate) SetNillableResponseBody(v *string) *IdempotencyRecordCreate {
  83. if v != nil {
  84. _c.SetResponseBody(*v)
  85. }
  86. return _c
  87. }
  88. // SetErrorReason sets the "error_reason" field.
  89. func (_c *IdempotencyRecordCreate) SetErrorReason(v string) *IdempotencyRecordCreate {
  90. _c.mutation.SetErrorReason(v)
  91. return _c
  92. }
  93. // SetNillableErrorReason sets the "error_reason" field if the given value is not nil.
  94. func (_c *IdempotencyRecordCreate) SetNillableErrorReason(v *string) *IdempotencyRecordCreate {
  95. if v != nil {
  96. _c.SetErrorReason(*v)
  97. }
  98. return _c
  99. }
  100. // SetLockedUntil sets the "locked_until" field.
  101. func (_c *IdempotencyRecordCreate) SetLockedUntil(v time.Time) *IdempotencyRecordCreate {
  102. _c.mutation.SetLockedUntil(v)
  103. return _c
  104. }
  105. // SetNillableLockedUntil sets the "locked_until" field if the given value is not nil.
  106. func (_c *IdempotencyRecordCreate) SetNillableLockedUntil(v *time.Time) *IdempotencyRecordCreate {
  107. if v != nil {
  108. _c.SetLockedUntil(*v)
  109. }
  110. return _c
  111. }
  112. // SetExpiresAt sets the "expires_at" field.
  113. func (_c *IdempotencyRecordCreate) SetExpiresAt(v time.Time) *IdempotencyRecordCreate {
  114. _c.mutation.SetExpiresAt(v)
  115. return _c
  116. }
  117. // Mutation returns the IdempotencyRecordMutation object of the builder.
  118. func (_c *IdempotencyRecordCreate) Mutation() *IdempotencyRecordMutation {
  119. return _c.mutation
  120. }
  121. // Save creates the IdempotencyRecord in the database.
  122. func (_c *IdempotencyRecordCreate) Save(ctx context.Context) (*IdempotencyRecord, error) {
  123. _c.defaults()
  124. return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
  125. }
  126. // SaveX calls Save and panics if Save returns an error.
  127. func (_c *IdempotencyRecordCreate) SaveX(ctx context.Context) *IdempotencyRecord {
  128. v, err := _c.Save(ctx)
  129. if err != nil {
  130. panic(err)
  131. }
  132. return v
  133. }
  134. // Exec executes the query.
  135. func (_c *IdempotencyRecordCreate) Exec(ctx context.Context) error {
  136. _, err := _c.Save(ctx)
  137. return err
  138. }
  139. // ExecX is like Exec, but panics if an error occurs.
  140. func (_c *IdempotencyRecordCreate) ExecX(ctx context.Context) {
  141. if err := _c.Exec(ctx); err != nil {
  142. panic(err)
  143. }
  144. }
  145. // defaults sets the default values of the builder before save.
  146. func (_c *IdempotencyRecordCreate) defaults() {
  147. if _, ok := _c.mutation.CreatedAt(); !ok {
  148. v := idempotencyrecord.DefaultCreatedAt()
  149. _c.mutation.SetCreatedAt(v)
  150. }
  151. if _, ok := _c.mutation.UpdatedAt(); !ok {
  152. v := idempotencyrecord.DefaultUpdatedAt()
  153. _c.mutation.SetUpdatedAt(v)
  154. }
  155. }
  156. // check runs all checks and user-defined validators on the builder.
  157. func (_c *IdempotencyRecordCreate) check() error {
  158. if _, ok := _c.mutation.CreatedAt(); !ok {
  159. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "IdempotencyRecord.created_at"`)}
  160. }
  161. if _, ok := _c.mutation.UpdatedAt(); !ok {
  162. return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "IdempotencyRecord.updated_at"`)}
  163. }
  164. if _, ok := _c.mutation.Scope(); !ok {
  165. return &ValidationError{Name: "scope", err: errors.New(`ent: missing required field "IdempotencyRecord.scope"`)}
  166. }
  167. if v, ok := _c.mutation.Scope(); ok {
  168. if err := idempotencyrecord.ScopeValidator(v); err != nil {
  169. return &ValidationError{Name: "scope", err: fmt.Errorf(`ent: validator failed for field "IdempotencyRecord.scope": %w`, err)}
  170. }
  171. }
  172. if _, ok := _c.mutation.IdempotencyKeyHash(); !ok {
  173. return &ValidationError{Name: "idempotency_key_hash", err: errors.New(`ent: missing required field "IdempotencyRecord.idempotency_key_hash"`)}
  174. }
  175. if v, ok := _c.mutation.IdempotencyKeyHash(); ok {
  176. if err := idempotencyrecord.IdempotencyKeyHashValidator(v); err != nil {
  177. return &ValidationError{Name: "idempotency_key_hash", err: fmt.Errorf(`ent: validator failed for field "IdempotencyRecord.idempotency_key_hash": %w`, err)}
  178. }
  179. }
  180. if _, ok := _c.mutation.RequestFingerprint(); !ok {
  181. return &ValidationError{Name: "request_fingerprint", err: errors.New(`ent: missing required field "IdempotencyRecord.request_fingerprint"`)}
  182. }
  183. if v, ok := _c.mutation.RequestFingerprint(); ok {
  184. if err := idempotencyrecord.RequestFingerprintValidator(v); err != nil {
  185. return &ValidationError{Name: "request_fingerprint", err: fmt.Errorf(`ent: validator failed for field "IdempotencyRecord.request_fingerprint": %w`, err)}
  186. }
  187. }
  188. if _, ok := _c.mutation.Status(); !ok {
  189. return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "IdempotencyRecord.status"`)}
  190. }
  191. if v, ok := _c.mutation.Status(); ok {
  192. if err := idempotencyrecord.StatusValidator(v); err != nil {
  193. return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "IdempotencyRecord.status": %w`, err)}
  194. }
  195. }
  196. if v, ok := _c.mutation.ErrorReason(); ok {
  197. if err := idempotencyrecord.ErrorReasonValidator(v); err != nil {
  198. return &ValidationError{Name: "error_reason", err: fmt.Errorf(`ent: validator failed for field "IdempotencyRecord.error_reason": %w`, err)}
  199. }
  200. }
  201. if _, ok := _c.mutation.ExpiresAt(); !ok {
  202. return &ValidationError{Name: "expires_at", err: errors.New(`ent: missing required field "IdempotencyRecord.expires_at"`)}
  203. }
  204. return nil
  205. }
  206. func (_c *IdempotencyRecordCreate) sqlSave(ctx context.Context) (*IdempotencyRecord, error) {
  207. if err := _c.check(); err != nil {
  208. return nil, err
  209. }
  210. _node, _spec := _c.createSpec()
  211. if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
  212. if sqlgraph.IsConstraintError(err) {
  213. err = &ConstraintError{msg: err.Error(), wrap: err}
  214. }
  215. return nil, err
  216. }
  217. id := _spec.ID.Value.(int64)
  218. _node.ID = int64(id)
  219. _c.mutation.id = &_node.ID
  220. _c.mutation.done = true
  221. return _node, nil
  222. }
  223. func (_c *IdempotencyRecordCreate) createSpec() (*IdempotencyRecord, *sqlgraph.CreateSpec) {
  224. var (
  225. _node = &IdempotencyRecord{config: _c.config}
  226. _spec = sqlgraph.NewCreateSpec(idempotencyrecord.Table, sqlgraph.NewFieldSpec(idempotencyrecord.FieldID, field.TypeInt64))
  227. )
  228. _spec.OnConflict = _c.conflict
  229. if value, ok := _c.mutation.CreatedAt(); ok {
  230. _spec.SetField(idempotencyrecord.FieldCreatedAt, field.TypeTime, value)
  231. _node.CreatedAt = value
  232. }
  233. if value, ok := _c.mutation.UpdatedAt(); ok {
  234. _spec.SetField(idempotencyrecord.FieldUpdatedAt, field.TypeTime, value)
  235. _node.UpdatedAt = value
  236. }
  237. if value, ok := _c.mutation.Scope(); ok {
  238. _spec.SetField(idempotencyrecord.FieldScope, field.TypeString, value)
  239. _node.Scope = value
  240. }
  241. if value, ok := _c.mutation.IdempotencyKeyHash(); ok {
  242. _spec.SetField(idempotencyrecord.FieldIdempotencyKeyHash, field.TypeString, value)
  243. _node.IdempotencyKeyHash = value
  244. }
  245. if value, ok := _c.mutation.RequestFingerprint(); ok {
  246. _spec.SetField(idempotencyrecord.FieldRequestFingerprint, field.TypeString, value)
  247. _node.RequestFingerprint = value
  248. }
  249. if value, ok := _c.mutation.Status(); ok {
  250. _spec.SetField(idempotencyrecord.FieldStatus, field.TypeString, value)
  251. _node.Status = value
  252. }
  253. if value, ok := _c.mutation.ResponseStatus(); ok {
  254. _spec.SetField(idempotencyrecord.FieldResponseStatus, field.TypeInt, value)
  255. _node.ResponseStatus = &value
  256. }
  257. if value, ok := _c.mutation.ResponseBody(); ok {
  258. _spec.SetField(idempotencyrecord.FieldResponseBody, field.TypeString, value)
  259. _node.ResponseBody = &value
  260. }
  261. if value, ok := _c.mutation.ErrorReason(); ok {
  262. _spec.SetField(idempotencyrecord.FieldErrorReason, field.TypeString, value)
  263. _node.ErrorReason = &value
  264. }
  265. if value, ok := _c.mutation.LockedUntil(); ok {
  266. _spec.SetField(idempotencyrecord.FieldLockedUntil, field.TypeTime, value)
  267. _node.LockedUntil = &value
  268. }
  269. if value, ok := _c.mutation.ExpiresAt(); ok {
  270. _spec.SetField(idempotencyrecord.FieldExpiresAt, field.TypeTime, value)
  271. _node.ExpiresAt = value
  272. }
  273. return _node, _spec
  274. }
  275. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  276. // of the `INSERT` statement. For example:
  277. //
  278. // client.IdempotencyRecord.Create().
  279. // SetCreatedAt(v).
  280. // OnConflict(
  281. // // Update the row with the new values
  282. // // the was proposed for insertion.
  283. // sql.ResolveWithNewValues(),
  284. // ).
  285. // // Override some of the fields with custom
  286. // // update values.
  287. // Update(func(u *ent.IdempotencyRecordUpsert) {
  288. // SetCreatedAt(v+v).
  289. // }).
  290. // Exec(ctx)
  291. func (_c *IdempotencyRecordCreate) OnConflict(opts ...sql.ConflictOption) *IdempotencyRecordUpsertOne {
  292. _c.conflict = opts
  293. return &IdempotencyRecordUpsertOne{
  294. create: _c,
  295. }
  296. }
  297. // OnConflictColumns calls `OnConflict` and configures the columns
  298. // as conflict target. Using this option is equivalent to using:
  299. //
  300. // client.IdempotencyRecord.Create().
  301. // OnConflict(sql.ConflictColumns(columns...)).
  302. // Exec(ctx)
  303. func (_c *IdempotencyRecordCreate) OnConflictColumns(columns ...string) *IdempotencyRecordUpsertOne {
  304. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  305. return &IdempotencyRecordUpsertOne{
  306. create: _c,
  307. }
  308. }
  309. type (
  310. // IdempotencyRecordUpsertOne is the builder for "upsert"-ing
  311. // one IdempotencyRecord node.
  312. IdempotencyRecordUpsertOne struct {
  313. create *IdempotencyRecordCreate
  314. }
  315. // IdempotencyRecordUpsert is the "OnConflict" setter.
  316. IdempotencyRecordUpsert struct {
  317. *sql.UpdateSet
  318. }
  319. )
  320. // SetUpdatedAt sets the "updated_at" field.
  321. func (u *IdempotencyRecordUpsert) SetUpdatedAt(v time.Time) *IdempotencyRecordUpsert {
  322. u.Set(idempotencyrecord.FieldUpdatedAt, v)
  323. return u
  324. }
  325. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  326. func (u *IdempotencyRecordUpsert) UpdateUpdatedAt() *IdempotencyRecordUpsert {
  327. u.SetExcluded(idempotencyrecord.FieldUpdatedAt)
  328. return u
  329. }
  330. // SetScope sets the "scope" field.
  331. func (u *IdempotencyRecordUpsert) SetScope(v string) *IdempotencyRecordUpsert {
  332. u.Set(idempotencyrecord.FieldScope, v)
  333. return u
  334. }
  335. // UpdateScope sets the "scope" field to the value that was provided on create.
  336. func (u *IdempotencyRecordUpsert) UpdateScope() *IdempotencyRecordUpsert {
  337. u.SetExcluded(idempotencyrecord.FieldScope)
  338. return u
  339. }
  340. // SetIdempotencyKeyHash sets the "idempotency_key_hash" field.
  341. func (u *IdempotencyRecordUpsert) SetIdempotencyKeyHash(v string) *IdempotencyRecordUpsert {
  342. u.Set(idempotencyrecord.FieldIdempotencyKeyHash, v)
  343. return u
  344. }
  345. // UpdateIdempotencyKeyHash sets the "idempotency_key_hash" field to the value that was provided on create.
  346. func (u *IdempotencyRecordUpsert) UpdateIdempotencyKeyHash() *IdempotencyRecordUpsert {
  347. u.SetExcluded(idempotencyrecord.FieldIdempotencyKeyHash)
  348. return u
  349. }
  350. // SetRequestFingerprint sets the "request_fingerprint" field.
  351. func (u *IdempotencyRecordUpsert) SetRequestFingerprint(v string) *IdempotencyRecordUpsert {
  352. u.Set(idempotencyrecord.FieldRequestFingerprint, v)
  353. return u
  354. }
  355. // UpdateRequestFingerprint sets the "request_fingerprint" field to the value that was provided on create.
  356. func (u *IdempotencyRecordUpsert) UpdateRequestFingerprint() *IdempotencyRecordUpsert {
  357. u.SetExcluded(idempotencyrecord.FieldRequestFingerprint)
  358. return u
  359. }
  360. // SetStatus sets the "status" field.
  361. func (u *IdempotencyRecordUpsert) SetStatus(v string) *IdempotencyRecordUpsert {
  362. u.Set(idempotencyrecord.FieldStatus, v)
  363. return u
  364. }
  365. // UpdateStatus sets the "status" field to the value that was provided on create.
  366. func (u *IdempotencyRecordUpsert) UpdateStatus() *IdempotencyRecordUpsert {
  367. u.SetExcluded(idempotencyrecord.FieldStatus)
  368. return u
  369. }
  370. // SetResponseStatus sets the "response_status" field.
  371. func (u *IdempotencyRecordUpsert) SetResponseStatus(v int) *IdempotencyRecordUpsert {
  372. u.Set(idempotencyrecord.FieldResponseStatus, v)
  373. return u
  374. }
  375. // UpdateResponseStatus sets the "response_status" field to the value that was provided on create.
  376. func (u *IdempotencyRecordUpsert) UpdateResponseStatus() *IdempotencyRecordUpsert {
  377. u.SetExcluded(idempotencyrecord.FieldResponseStatus)
  378. return u
  379. }
  380. // AddResponseStatus adds v to the "response_status" field.
  381. func (u *IdempotencyRecordUpsert) AddResponseStatus(v int) *IdempotencyRecordUpsert {
  382. u.Add(idempotencyrecord.FieldResponseStatus, v)
  383. return u
  384. }
  385. // ClearResponseStatus clears the value of the "response_status" field.
  386. func (u *IdempotencyRecordUpsert) ClearResponseStatus() *IdempotencyRecordUpsert {
  387. u.SetNull(idempotencyrecord.FieldResponseStatus)
  388. return u
  389. }
  390. // SetResponseBody sets the "response_body" field.
  391. func (u *IdempotencyRecordUpsert) SetResponseBody(v string) *IdempotencyRecordUpsert {
  392. u.Set(idempotencyrecord.FieldResponseBody, v)
  393. return u
  394. }
  395. // UpdateResponseBody sets the "response_body" field to the value that was provided on create.
  396. func (u *IdempotencyRecordUpsert) UpdateResponseBody() *IdempotencyRecordUpsert {
  397. u.SetExcluded(idempotencyrecord.FieldResponseBody)
  398. return u
  399. }
  400. // ClearResponseBody clears the value of the "response_body" field.
  401. func (u *IdempotencyRecordUpsert) ClearResponseBody() *IdempotencyRecordUpsert {
  402. u.SetNull(idempotencyrecord.FieldResponseBody)
  403. return u
  404. }
  405. // SetErrorReason sets the "error_reason" field.
  406. func (u *IdempotencyRecordUpsert) SetErrorReason(v string) *IdempotencyRecordUpsert {
  407. u.Set(idempotencyrecord.FieldErrorReason, v)
  408. return u
  409. }
  410. // UpdateErrorReason sets the "error_reason" field to the value that was provided on create.
  411. func (u *IdempotencyRecordUpsert) UpdateErrorReason() *IdempotencyRecordUpsert {
  412. u.SetExcluded(idempotencyrecord.FieldErrorReason)
  413. return u
  414. }
  415. // ClearErrorReason clears the value of the "error_reason" field.
  416. func (u *IdempotencyRecordUpsert) ClearErrorReason() *IdempotencyRecordUpsert {
  417. u.SetNull(idempotencyrecord.FieldErrorReason)
  418. return u
  419. }
  420. // SetLockedUntil sets the "locked_until" field.
  421. func (u *IdempotencyRecordUpsert) SetLockedUntil(v time.Time) *IdempotencyRecordUpsert {
  422. u.Set(idempotencyrecord.FieldLockedUntil, v)
  423. return u
  424. }
  425. // UpdateLockedUntil sets the "locked_until" field to the value that was provided on create.
  426. func (u *IdempotencyRecordUpsert) UpdateLockedUntil() *IdempotencyRecordUpsert {
  427. u.SetExcluded(idempotencyrecord.FieldLockedUntil)
  428. return u
  429. }
  430. // ClearLockedUntil clears the value of the "locked_until" field.
  431. func (u *IdempotencyRecordUpsert) ClearLockedUntil() *IdempotencyRecordUpsert {
  432. u.SetNull(idempotencyrecord.FieldLockedUntil)
  433. return u
  434. }
  435. // SetExpiresAt sets the "expires_at" field.
  436. func (u *IdempotencyRecordUpsert) SetExpiresAt(v time.Time) *IdempotencyRecordUpsert {
  437. u.Set(idempotencyrecord.FieldExpiresAt, v)
  438. return u
  439. }
  440. // UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
  441. func (u *IdempotencyRecordUpsert) UpdateExpiresAt() *IdempotencyRecordUpsert {
  442. u.SetExcluded(idempotencyrecord.FieldExpiresAt)
  443. return u
  444. }
  445. // UpdateNewValues updates the mutable fields using the new values that were set on create.
  446. // Using this option is equivalent to using:
  447. //
  448. // client.IdempotencyRecord.Create().
  449. // OnConflict(
  450. // sql.ResolveWithNewValues(),
  451. // ).
  452. // Exec(ctx)
  453. func (u *IdempotencyRecordUpsertOne) UpdateNewValues() *IdempotencyRecordUpsertOne {
  454. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  455. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  456. if _, exists := u.create.mutation.CreatedAt(); exists {
  457. s.SetIgnore(idempotencyrecord.FieldCreatedAt)
  458. }
  459. }))
  460. return u
  461. }
  462. // Ignore sets each column to itself in case of conflict.
  463. // Using this option is equivalent to using:
  464. //
  465. // client.IdempotencyRecord.Create().
  466. // OnConflict(sql.ResolveWithIgnore()).
  467. // Exec(ctx)
  468. func (u *IdempotencyRecordUpsertOne) Ignore() *IdempotencyRecordUpsertOne {
  469. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  470. return u
  471. }
  472. // DoNothing configures the conflict_action to `DO NOTHING`.
  473. // Supported only by SQLite and PostgreSQL.
  474. func (u *IdempotencyRecordUpsertOne) DoNothing() *IdempotencyRecordUpsertOne {
  475. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  476. return u
  477. }
  478. // Update allows overriding fields `UPDATE` values. See the IdempotencyRecordCreate.OnConflict
  479. // documentation for more info.
  480. func (u *IdempotencyRecordUpsertOne) Update(set func(*IdempotencyRecordUpsert)) *IdempotencyRecordUpsertOne {
  481. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  482. set(&IdempotencyRecordUpsert{UpdateSet: update})
  483. }))
  484. return u
  485. }
  486. // SetUpdatedAt sets the "updated_at" field.
  487. func (u *IdempotencyRecordUpsertOne) SetUpdatedAt(v time.Time) *IdempotencyRecordUpsertOne {
  488. return u.Update(func(s *IdempotencyRecordUpsert) {
  489. s.SetUpdatedAt(v)
  490. })
  491. }
  492. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  493. func (u *IdempotencyRecordUpsertOne) UpdateUpdatedAt() *IdempotencyRecordUpsertOne {
  494. return u.Update(func(s *IdempotencyRecordUpsert) {
  495. s.UpdateUpdatedAt()
  496. })
  497. }
  498. // SetScope sets the "scope" field.
  499. func (u *IdempotencyRecordUpsertOne) SetScope(v string) *IdempotencyRecordUpsertOne {
  500. return u.Update(func(s *IdempotencyRecordUpsert) {
  501. s.SetScope(v)
  502. })
  503. }
  504. // UpdateScope sets the "scope" field to the value that was provided on create.
  505. func (u *IdempotencyRecordUpsertOne) UpdateScope() *IdempotencyRecordUpsertOne {
  506. return u.Update(func(s *IdempotencyRecordUpsert) {
  507. s.UpdateScope()
  508. })
  509. }
  510. // SetIdempotencyKeyHash sets the "idempotency_key_hash" field.
  511. func (u *IdempotencyRecordUpsertOne) SetIdempotencyKeyHash(v string) *IdempotencyRecordUpsertOne {
  512. return u.Update(func(s *IdempotencyRecordUpsert) {
  513. s.SetIdempotencyKeyHash(v)
  514. })
  515. }
  516. // UpdateIdempotencyKeyHash sets the "idempotency_key_hash" field to the value that was provided on create.
  517. func (u *IdempotencyRecordUpsertOne) UpdateIdempotencyKeyHash() *IdempotencyRecordUpsertOne {
  518. return u.Update(func(s *IdempotencyRecordUpsert) {
  519. s.UpdateIdempotencyKeyHash()
  520. })
  521. }
  522. // SetRequestFingerprint sets the "request_fingerprint" field.
  523. func (u *IdempotencyRecordUpsertOne) SetRequestFingerprint(v string) *IdempotencyRecordUpsertOne {
  524. return u.Update(func(s *IdempotencyRecordUpsert) {
  525. s.SetRequestFingerprint(v)
  526. })
  527. }
  528. // UpdateRequestFingerprint sets the "request_fingerprint" field to the value that was provided on create.
  529. func (u *IdempotencyRecordUpsertOne) UpdateRequestFingerprint() *IdempotencyRecordUpsertOne {
  530. return u.Update(func(s *IdempotencyRecordUpsert) {
  531. s.UpdateRequestFingerprint()
  532. })
  533. }
  534. // SetStatus sets the "status" field.
  535. func (u *IdempotencyRecordUpsertOne) SetStatus(v string) *IdempotencyRecordUpsertOne {
  536. return u.Update(func(s *IdempotencyRecordUpsert) {
  537. s.SetStatus(v)
  538. })
  539. }
  540. // UpdateStatus sets the "status" field to the value that was provided on create.
  541. func (u *IdempotencyRecordUpsertOne) UpdateStatus() *IdempotencyRecordUpsertOne {
  542. return u.Update(func(s *IdempotencyRecordUpsert) {
  543. s.UpdateStatus()
  544. })
  545. }
  546. // SetResponseStatus sets the "response_status" field.
  547. func (u *IdempotencyRecordUpsertOne) SetResponseStatus(v int) *IdempotencyRecordUpsertOne {
  548. return u.Update(func(s *IdempotencyRecordUpsert) {
  549. s.SetResponseStatus(v)
  550. })
  551. }
  552. // AddResponseStatus adds v to the "response_status" field.
  553. func (u *IdempotencyRecordUpsertOne) AddResponseStatus(v int) *IdempotencyRecordUpsertOne {
  554. return u.Update(func(s *IdempotencyRecordUpsert) {
  555. s.AddResponseStatus(v)
  556. })
  557. }
  558. // UpdateResponseStatus sets the "response_status" field to the value that was provided on create.
  559. func (u *IdempotencyRecordUpsertOne) UpdateResponseStatus() *IdempotencyRecordUpsertOne {
  560. return u.Update(func(s *IdempotencyRecordUpsert) {
  561. s.UpdateResponseStatus()
  562. })
  563. }
  564. // ClearResponseStatus clears the value of the "response_status" field.
  565. func (u *IdempotencyRecordUpsertOne) ClearResponseStatus() *IdempotencyRecordUpsertOne {
  566. return u.Update(func(s *IdempotencyRecordUpsert) {
  567. s.ClearResponseStatus()
  568. })
  569. }
  570. // SetResponseBody sets the "response_body" field.
  571. func (u *IdempotencyRecordUpsertOne) SetResponseBody(v string) *IdempotencyRecordUpsertOne {
  572. return u.Update(func(s *IdempotencyRecordUpsert) {
  573. s.SetResponseBody(v)
  574. })
  575. }
  576. // UpdateResponseBody sets the "response_body" field to the value that was provided on create.
  577. func (u *IdempotencyRecordUpsertOne) UpdateResponseBody() *IdempotencyRecordUpsertOne {
  578. return u.Update(func(s *IdempotencyRecordUpsert) {
  579. s.UpdateResponseBody()
  580. })
  581. }
  582. // ClearResponseBody clears the value of the "response_body" field.
  583. func (u *IdempotencyRecordUpsertOne) ClearResponseBody() *IdempotencyRecordUpsertOne {
  584. return u.Update(func(s *IdempotencyRecordUpsert) {
  585. s.ClearResponseBody()
  586. })
  587. }
  588. // SetErrorReason sets the "error_reason" field.
  589. func (u *IdempotencyRecordUpsertOne) SetErrorReason(v string) *IdempotencyRecordUpsertOne {
  590. return u.Update(func(s *IdempotencyRecordUpsert) {
  591. s.SetErrorReason(v)
  592. })
  593. }
  594. // UpdateErrorReason sets the "error_reason" field to the value that was provided on create.
  595. func (u *IdempotencyRecordUpsertOne) UpdateErrorReason() *IdempotencyRecordUpsertOne {
  596. return u.Update(func(s *IdempotencyRecordUpsert) {
  597. s.UpdateErrorReason()
  598. })
  599. }
  600. // ClearErrorReason clears the value of the "error_reason" field.
  601. func (u *IdempotencyRecordUpsertOne) ClearErrorReason() *IdempotencyRecordUpsertOne {
  602. return u.Update(func(s *IdempotencyRecordUpsert) {
  603. s.ClearErrorReason()
  604. })
  605. }
  606. // SetLockedUntil sets the "locked_until" field.
  607. func (u *IdempotencyRecordUpsertOne) SetLockedUntil(v time.Time) *IdempotencyRecordUpsertOne {
  608. return u.Update(func(s *IdempotencyRecordUpsert) {
  609. s.SetLockedUntil(v)
  610. })
  611. }
  612. // UpdateLockedUntil sets the "locked_until" field to the value that was provided on create.
  613. func (u *IdempotencyRecordUpsertOne) UpdateLockedUntil() *IdempotencyRecordUpsertOne {
  614. return u.Update(func(s *IdempotencyRecordUpsert) {
  615. s.UpdateLockedUntil()
  616. })
  617. }
  618. // ClearLockedUntil clears the value of the "locked_until" field.
  619. func (u *IdempotencyRecordUpsertOne) ClearLockedUntil() *IdempotencyRecordUpsertOne {
  620. return u.Update(func(s *IdempotencyRecordUpsert) {
  621. s.ClearLockedUntil()
  622. })
  623. }
  624. // SetExpiresAt sets the "expires_at" field.
  625. func (u *IdempotencyRecordUpsertOne) SetExpiresAt(v time.Time) *IdempotencyRecordUpsertOne {
  626. return u.Update(func(s *IdempotencyRecordUpsert) {
  627. s.SetExpiresAt(v)
  628. })
  629. }
  630. // UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
  631. func (u *IdempotencyRecordUpsertOne) UpdateExpiresAt() *IdempotencyRecordUpsertOne {
  632. return u.Update(func(s *IdempotencyRecordUpsert) {
  633. s.UpdateExpiresAt()
  634. })
  635. }
  636. // Exec executes the query.
  637. func (u *IdempotencyRecordUpsertOne) Exec(ctx context.Context) error {
  638. if len(u.create.conflict) == 0 {
  639. return errors.New("ent: missing options for IdempotencyRecordCreate.OnConflict")
  640. }
  641. return u.create.Exec(ctx)
  642. }
  643. // ExecX is like Exec, but panics if an error occurs.
  644. func (u *IdempotencyRecordUpsertOne) ExecX(ctx context.Context) {
  645. if err := u.create.Exec(ctx); err != nil {
  646. panic(err)
  647. }
  648. }
  649. // Exec executes the UPSERT query and returns the inserted/updated ID.
  650. func (u *IdempotencyRecordUpsertOne) ID(ctx context.Context) (id int64, err error) {
  651. node, err := u.create.Save(ctx)
  652. if err != nil {
  653. return id, err
  654. }
  655. return node.ID, nil
  656. }
  657. // IDX is like ID, but panics if an error occurs.
  658. func (u *IdempotencyRecordUpsertOne) IDX(ctx context.Context) int64 {
  659. id, err := u.ID(ctx)
  660. if err != nil {
  661. panic(err)
  662. }
  663. return id
  664. }
  665. // IdempotencyRecordCreateBulk is the builder for creating many IdempotencyRecord entities in bulk.
  666. type IdempotencyRecordCreateBulk struct {
  667. config
  668. err error
  669. builders []*IdempotencyRecordCreate
  670. conflict []sql.ConflictOption
  671. }
  672. // Save creates the IdempotencyRecord entities in the database.
  673. func (_c *IdempotencyRecordCreateBulk) Save(ctx context.Context) ([]*IdempotencyRecord, error) {
  674. if _c.err != nil {
  675. return nil, _c.err
  676. }
  677. specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
  678. nodes := make([]*IdempotencyRecord, len(_c.builders))
  679. mutators := make([]Mutator, len(_c.builders))
  680. for i := range _c.builders {
  681. func(i int, root context.Context) {
  682. builder := _c.builders[i]
  683. builder.defaults()
  684. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  685. mutation, ok := m.(*IdempotencyRecordMutation)
  686. if !ok {
  687. return nil, fmt.Errorf("unexpected mutation type %T", m)
  688. }
  689. if err := builder.check(); err != nil {
  690. return nil, err
  691. }
  692. builder.mutation = mutation
  693. var err error
  694. nodes[i], specs[i] = builder.createSpec()
  695. if i < len(mutators)-1 {
  696. _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
  697. } else {
  698. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  699. spec.OnConflict = _c.conflict
  700. // Invoke the actual operation on the latest mutation in the chain.
  701. if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
  702. if sqlgraph.IsConstraintError(err) {
  703. err = &ConstraintError{msg: err.Error(), wrap: err}
  704. }
  705. }
  706. }
  707. if err != nil {
  708. return nil, err
  709. }
  710. mutation.id = &nodes[i].ID
  711. if specs[i].ID.Value != nil {
  712. id := specs[i].ID.Value.(int64)
  713. nodes[i].ID = int64(id)
  714. }
  715. mutation.done = true
  716. return nodes[i], nil
  717. })
  718. for i := len(builder.hooks) - 1; i >= 0; i-- {
  719. mut = builder.hooks[i](mut)
  720. }
  721. mutators[i] = mut
  722. }(i, ctx)
  723. }
  724. if len(mutators) > 0 {
  725. if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
  726. return nil, err
  727. }
  728. }
  729. return nodes, nil
  730. }
  731. // SaveX is like Save, but panics if an error occurs.
  732. func (_c *IdempotencyRecordCreateBulk) SaveX(ctx context.Context) []*IdempotencyRecord {
  733. v, err := _c.Save(ctx)
  734. if err != nil {
  735. panic(err)
  736. }
  737. return v
  738. }
  739. // Exec executes the query.
  740. func (_c *IdempotencyRecordCreateBulk) Exec(ctx context.Context) error {
  741. _, err := _c.Save(ctx)
  742. return err
  743. }
  744. // ExecX is like Exec, but panics if an error occurs.
  745. func (_c *IdempotencyRecordCreateBulk) ExecX(ctx context.Context) {
  746. if err := _c.Exec(ctx); err != nil {
  747. panic(err)
  748. }
  749. }
  750. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  751. // of the `INSERT` statement. For example:
  752. //
  753. // client.IdempotencyRecord.CreateBulk(builders...).
  754. // OnConflict(
  755. // // Update the row with the new values
  756. // // the was proposed for insertion.
  757. // sql.ResolveWithNewValues(),
  758. // ).
  759. // // Override some of the fields with custom
  760. // // update values.
  761. // Update(func(u *ent.IdempotencyRecordUpsert) {
  762. // SetCreatedAt(v+v).
  763. // }).
  764. // Exec(ctx)
  765. func (_c *IdempotencyRecordCreateBulk) OnConflict(opts ...sql.ConflictOption) *IdempotencyRecordUpsertBulk {
  766. _c.conflict = opts
  767. return &IdempotencyRecordUpsertBulk{
  768. create: _c,
  769. }
  770. }
  771. // OnConflictColumns calls `OnConflict` and configures the columns
  772. // as conflict target. Using this option is equivalent to using:
  773. //
  774. // client.IdempotencyRecord.Create().
  775. // OnConflict(sql.ConflictColumns(columns...)).
  776. // Exec(ctx)
  777. func (_c *IdempotencyRecordCreateBulk) OnConflictColumns(columns ...string) *IdempotencyRecordUpsertBulk {
  778. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  779. return &IdempotencyRecordUpsertBulk{
  780. create: _c,
  781. }
  782. }
  783. // IdempotencyRecordUpsertBulk is the builder for "upsert"-ing
  784. // a bulk of IdempotencyRecord nodes.
  785. type IdempotencyRecordUpsertBulk struct {
  786. create *IdempotencyRecordCreateBulk
  787. }
  788. // UpdateNewValues updates the mutable fields using the new values that
  789. // were set on create. Using this option is equivalent to using:
  790. //
  791. // client.IdempotencyRecord.Create().
  792. // OnConflict(
  793. // sql.ResolveWithNewValues(),
  794. // ).
  795. // Exec(ctx)
  796. func (u *IdempotencyRecordUpsertBulk) UpdateNewValues() *IdempotencyRecordUpsertBulk {
  797. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  798. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  799. for _, b := range u.create.builders {
  800. if _, exists := b.mutation.CreatedAt(); exists {
  801. s.SetIgnore(idempotencyrecord.FieldCreatedAt)
  802. }
  803. }
  804. }))
  805. return u
  806. }
  807. // Ignore sets each column to itself in case of conflict.
  808. // Using this option is equivalent to using:
  809. //
  810. // client.IdempotencyRecord.Create().
  811. // OnConflict(sql.ResolveWithIgnore()).
  812. // Exec(ctx)
  813. func (u *IdempotencyRecordUpsertBulk) Ignore() *IdempotencyRecordUpsertBulk {
  814. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  815. return u
  816. }
  817. // DoNothing configures the conflict_action to `DO NOTHING`.
  818. // Supported only by SQLite and PostgreSQL.
  819. func (u *IdempotencyRecordUpsertBulk) DoNothing() *IdempotencyRecordUpsertBulk {
  820. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  821. return u
  822. }
  823. // Update allows overriding fields `UPDATE` values. See the IdempotencyRecordCreateBulk.OnConflict
  824. // documentation for more info.
  825. func (u *IdempotencyRecordUpsertBulk) Update(set func(*IdempotencyRecordUpsert)) *IdempotencyRecordUpsertBulk {
  826. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  827. set(&IdempotencyRecordUpsert{UpdateSet: update})
  828. }))
  829. return u
  830. }
  831. // SetUpdatedAt sets the "updated_at" field.
  832. func (u *IdempotencyRecordUpsertBulk) SetUpdatedAt(v time.Time) *IdempotencyRecordUpsertBulk {
  833. return u.Update(func(s *IdempotencyRecordUpsert) {
  834. s.SetUpdatedAt(v)
  835. })
  836. }
  837. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  838. func (u *IdempotencyRecordUpsertBulk) UpdateUpdatedAt() *IdempotencyRecordUpsertBulk {
  839. return u.Update(func(s *IdempotencyRecordUpsert) {
  840. s.UpdateUpdatedAt()
  841. })
  842. }
  843. // SetScope sets the "scope" field.
  844. func (u *IdempotencyRecordUpsertBulk) SetScope(v string) *IdempotencyRecordUpsertBulk {
  845. return u.Update(func(s *IdempotencyRecordUpsert) {
  846. s.SetScope(v)
  847. })
  848. }
  849. // UpdateScope sets the "scope" field to the value that was provided on create.
  850. func (u *IdempotencyRecordUpsertBulk) UpdateScope() *IdempotencyRecordUpsertBulk {
  851. return u.Update(func(s *IdempotencyRecordUpsert) {
  852. s.UpdateScope()
  853. })
  854. }
  855. // SetIdempotencyKeyHash sets the "idempotency_key_hash" field.
  856. func (u *IdempotencyRecordUpsertBulk) SetIdempotencyKeyHash(v string) *IdempotencyRecordUpsertBulk {
  857. return u.Update(func(s *IdempotencyRecordUpsert) {
  858. s.SetIdempotencyKeyHash(v)
  859. })
  860. }
  861. // UpdateIdempotencyKeyHash sets the "idempotency_key_hash" field to the value that was provided on create.
  862. func (u *IdempotencyRecordUpsertBulk) UpdateIdempotencyKeyHash() *IdempotencyRecordUpsertBulk {
  863. return u.Update(func(s *IdempotencyRecordUpsert) {
  864. s.UpdateIdempotencyKeyHash()
  865. })
  866. }
  867. // SetRequestFingerprint sets the "request_fingerprint" field.
  868. func (u *IdempotencyRecordUpsertBulk) SetRequestFingerprint(v string) *IdempotencyRecordUpsertBulk {
  869. return u.Update(func(s *IdempotencyRecordUpsert) {
  870. s.SetRequestFingerprint(v)
  871. })
  872. }
  873. // UpdateRequestFingerprint sets the "request_fingerprint" field to the value that was provided on create.
  874. func (u *IdempotencyRecordUpsertBulk) UpdateRequestFingerprint() *IdempotencyRecordUpsertBulk {
  875. return u.Update(func(s *IdempotencyRecordUpsert) {
  876. s.UpdateRequestFingerprint()
  877. })
  878. }
  879. // SetStatus sets the "status" field.
  880. func (u *IdempotencyRecordUpsertBulk) SetStatus(v string) *IdempotencyRecordUpsertBulk {
  881. return u.Update(func(s *IdempotencyRecordUpsert) {
  882. s.SetStatus(v)
  883. })
  884. }
  885. // UpdateStatus sets the "status" field to the value that was provided on create.
  886. func (u *IdempotencyRecordUpsertBulk) UpdateStatus() *IdempotencyRecordUpsertBulk {
  887. return u.Update(func(s *IdempotencyRecordUpsert) {
  888. s.UpdateStatus()
  889. })
  890. }
  891. // SetResponseStatus sets the "response_status" field.
  892. func (u *IdempotencyRecordUpsertBulk) SetResponseStatus(v int) *IdempotencyRecordUpsertBulk {
  893. return u.Update(func(s *IdempotencyRecordUpsert) {
  894. s.SetResponseStatus(v)
  895. })
  896. }
  897. // AddResponseStatus adds v to the "response_status" field.
  898. func (u *IdempotencyRecordUpsertBulk) AddResponseStatus(v int) *IdempotencyRecordUpsertBulk {
  899. return u.Update(func(s *IdempotencyRecordUpsert) {
  900. s.AddResponseStatus(v)
  901. })
  902. }
  903. // UpdateResponseStatus sets the "response_status" field to the value that was provided on create.
  904. func (u *IdempotencyRecordUpsertBulk) UpdateResponseStatus() *IdempotencyRecordUpsertBulk {
  905. return u.Update(func(s *IdempotencyRecordUpsert) {
  906. s.UpdateResponseStatus()
  907. })
  908. }
  909. // ClearResponseStatus clears the value of the "response_status" field.
  910. func (u *IdempotencyRecordUpsertBulk) ClearResponseStatus() *IdempotencyRecordUpsertBulk {
  911. return u.Update(func(s *IdempotencyRecordUpsert) {
  912. s.ClearResponseStatus()
  913. })
  914. }
  915. // SetResponseBody sets the "response_body" field.
  916. func (u *IdempotencyRecordUpsertBulk) SetResponseBody(v string) *IdempotencyRecordUpsertBulk {
  917. return u.Update(func(s *IdempotencyRecordUpsert) {
  918. s.SetResponseBody(v)
  919. })
  920. }
  921. // UpdateResponseBody sets the "response_body" field to the value that was provided on create.
  922. func (u *IdempotencyRecordUpsertBulk) UpdateResponseBody() *IdempotencyRecordUpsertBulk {
  923. return u.Update(func(s *IdempotencyRecordUpsert) {
  924. s.UpdateResponseBody()
  925. })
  926. }
  927. // ClearResponseBody clears the value of the "response_body" field.
  928. func (u *IdempotencyRecordUpsertBulk) ClearResponseBody() *IdempotencyRecordUpsertBulk {
  929. return u.Update(func(s *IdempotencyRecordUpsert) {
  930. s.ClearResponseBody()
  931. })
  932. }
  933. // SetErrorReason sets the "error_reason" field.
  934. func (u *IdempotencyRecordUpsertBulk) SetErrorReason(v string) *IdempotencyRecordUpsertBulk {
  935. return u.Update(func(s *IdempotencyRecordUpsert) {
  936. s.SetErrorReason(v)
  937. })
  938. }
  939. // UpdateErrorReason sets the "error_reason" field to the value that was provided on create.
  940. func (u *IdempotencyRecordUpsertBulk) UpdateErrorReason() *IdempotencyRecordUpsertBulk {
  941. return u.Update(func(s *IdempotencyRecordUpsert) {
  942. s.UpdateErrorReason()
  943. })
  944. }
  945. // ClearErrorReason clears the value of the "error_reason" field.
  946. func (u *IdempotencyRecordUpsertBulk) ClearErrorReason() *IdempotencyRecordUpsertBulk {
  947. return u.Update(func(s *IdempotencyRecordUpsert) {
  948. s.ClearErrorReason()
  949. })
  950. }
  951. // SetLockedUntil sets the "locked_until" field.
  952. func (u *IdempotencyRecordUpsertBulk) SetLockedUntil(v time.Time) *IdempotencyRecordUpsertBulk {
  953. return u.Update(func(s *IdempotencyRecordUpsert) {
  954. s.SetLockedUntil(v)
  955. })
  956. }
  957. // UpdateLockedUntil sets the "locked_until" field to the value that was provided on create.
  958. func (u *IdempotencyRecordUpsertBulk) UpdateLockedUntil() *IdempotencyRecordUpsertBulk {
  959. return u.Update(func(s *IdempotencyRecordUpsert) {
  960. s.UpdateLockedUntil()
  961. })
  962. }
  963. // ClearLockedUntil clears the value of the "locked_until" field.
  964. func (u *IdempotencyRecordUpsertBulk) ClearLockedUntil() *IdempotencyRecordUpsertBulk {
  965. return u.Update(func(s *IdempotencyRecordUpsert) {
  966. s.ClearLockedUntil()
  967. })
  968. }
  969. // SetExpiresAt sets the "expires_at" field.
  970. func (u *IdempotencyRecordUpsertBulk) SetExpiresAt(v time.Time) *IdempotencyRecordUpsertBulk {
  971. return u.Update(func(s *IdempotencyRecordUpsert) {
  972. s.SetExpiresAt(v)
  973. })
  974. }
  975. // UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
  976. func (u *IdempotencyRecordUpsertBulk) UpdateExpiresAt() *IdempotencyRecordUpsertBulk {
  977. return u.Update(func(s *IdempotencyRecordUpsert) {
  978. s.UpdateExpiresAt()
  979. })
  980. }
  981. // Exec executes the query.
  982. func (u *IdempotencyRecordUpsertBulk) Exec(ctx context.Context) error {
  983. if u.create.err != nil {
  984. return u.create.err
  985. }
  986. for i, b := range u.create.builders {
  987. if len(b.conflict) != 0 {
  988. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the IdempotencyRecordCreateBulk instead", i)
  989. }
  990. }
  991. if len(u.create.conflict) == 0 {
  992. return errors.New("ent: missing options for IdempotencyRecordCreateBulk.OnConflict")
  993. }
  994. return u.create.Exec(ctx)
  995. }
  996. // ExecX is like Exec, but panics if an error occurs.
  997. func (u *IdempotencyRecordUpsertBulk) ExecX(ctx context.Context) {
  998. if err := u.create.Exec(ctx); err != nil {
  999. panic(err)
  1000. }
  1001. }