pushregistration_update.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "time"
  8. "w303a/server/app/gate/internal/data/ent/predicate"
  9. "w303a/server/app/gate/internal/data/ent/pushregistration"
  10. "entgo.io/ent/dialect/sql"
  11. "entgo.io/ent/dialect/sql/sqlgraph"
  12. "entgo.io/ent/schema/field"
  13. )
  14. // PushRegistrationUpdate is the builder for updating PushRegistration entities.
  15. type PushRegistrationUpdate struct {
  16. config
  17. hooks []Hook
  18. mutation *PushRegistrationMutation
  19. }
  20. // Where appends a list predicates to the PushRegistrationUpdate builder.
  21. func (pru *PushRegistrationUpdate) Where(ps ...predicate.PushRegistration) *PushRegistrationUpdate {
  22. pru.mutation.Where(ps...)
  23. return pru
  24. }
  25. // SetRegID sets the "reg_id" field.
  26. func (pru *PushRegistrationUpdate) SetRegID(s string) *PushRegistrationUpdate {
  27. pru.mutation.SetRegID(s)
  28. return pru
  29. }
  30. // SetNillableRegID sets the "reg_id" field if the given value is not nil.
  31. func (pru *PushRegistrationUpdate) SetNillableRegID(s *string) *PushRegistrationUpdate {
  32. if s != nil {
  33. pru.SetRegID(*s)
  34. }
  35. return pru
  36. }
  37. // SetRegistrantPlatformType sets the "registrant_platform_type" field.
  38. func (pru *PushRegistrationUpdate) SetRegistrantPlatformType(i int8) *PushRegistrationUpdate {
  39. pru.mutation.ResetRegistrantPlatformType()
  40. pru.mutation.SetRegistrantPlatformType(i)
  41. return pru
  42. }
  43. // SetNillableRegistrantPlatformType sets the "registrant_platform_type" field if the given value is not nil.
  44. func (pru *PushRegistrationUpdate) SetNillableRegistrantPlatformType(i *int8) *PushRegistrationUpdate {
  45. if i != nil {
  46. pru.SetRegistrantPlatformType(*i)
  47. }
  48. return pru
  49. }
  50. // AddRegistrantPlatformType adds i to the "registrant_platform_type" field.
  51. func (pru *PushRegistrationUpdate) AddRegistrantPlatformType(i int8) *PushRegistrationUpdate {
  52. pru.mutation.AddRegistrantPlatformType(i)
  53. return pru
  54. }
  55. // SetLanguage sets the "language" field.
  56. func (pru *PushRegistrationUpdate) SetLanguage(s string) *PushRegistrationUpdate {
  57. pru.mutation.SetLanguage(s)
  58. return pru
  59. }
  60. // SetNillableLanguage sets the "language" field if the given value is not nil.
  61. func (pru *PushRegistrationUpdate) SetNillableLanguage(s *string) *PushRegistrationUpdate {
  62. if s != nil {
  63. pru.SetLanguage(*s)
  64. }
  65. return pru
  66. }
  67. // SetDeviceModel sets the "device_model" field.
  68. func (pru *PushRegistrationUpdate) SetDeviceModel(s string) *PushRegistrationUpdate {
  69. pru.mutation.SetDeviceModel(s)
  70. return pru
  71. }
  72. // SetNillableDeviceModel sets the "device_model" field if the given value is not nil.
  73. func (pru *PushRegistrationUpdate) SetNillableDeviceModel(s *string) *PushRegistrationUpdate {
  74. if s != nil {
  75. pru.SetDeviceModel(*s)
  76. }
  77. return pru
  78. }
  79. // SetDeviceManufacturer sets the "device_manufacturer" field.
  80. func (pru *PushRegistrationUpdate) SetDeviceManufacturer(s string) *PushRegistrationUpdate {
  81. pru.mutation.SetDeviceManufacturer(s)
  82. return pru
  83. }
  84. // SetNillableDeviceManufacturer sets the "device_manufacturer" field if the given value is not nil.
  85. func (pru *PushRegistrationUpdate) SetNillableDeviceManufacturer(s *string) *PushRegistrationUpdate {
  86. if s != nil {
  87. pru.SetDeviceManufacturer(*s)
  88. }
  89. return pru
  90. }
  91. // SetDeviceSystemVersion sets the "device_system_version" field.
  92. func (pru *PushRegistrationUpdate) SetDeviceSystemVersion(s string) *PushRegistrationUpdate {
  93. pru.mutation.SetDeviceSystemVersion(s)
  94. return pru
  95. }
  96. // SetNillableDeviceSystemVersion sets the "device_system_version" field if the given value is not nil.
  97. func (pru *PushRegistrationUpdate) SetNillableDeviceSystemVersion(s *string) *PushRegistrationUpdate {
  98. if s != nil {
  99. pru.SetDeviceSystemVersion(*s)
  100. }
  101. return pru
  102. }
  103. // SetDeviceSystem sets the "device_system" field.
  104. func (pru *PushRegistrationUpdate) SetDeviceSystem(s string) *PushRegistrationUpdate {
  105. pru.mutation.SetDeviceSystem(s)
  106. return pru
  107. }
  108. // SetNillableDeviceSystem sets the "device_system" field if the given value is not nil.
  109. func (pru *PushRegistrationUpdate) SetNillableDeviceSystem(s *string) *PushRegistrationUpdate {
  110. if s != nil {
  111. pru.SetDeviceSystem(*s)
  112. }
  113. return pru
  114. }
  115. // SetCreatedAt sets the "created_at" field.
  116. func (pru *PushRegistrationUpdate) SetCreatedAt(t time.Time) *PushRegistrationUpdate {
  117. pru.mutation.SetCreatedAt(t)
  118. return pru
  119. }
  120. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  121. func (pru *PushRegistrationUpdate) SetNillableCreatedAt(t *time.Time) *PushRegistrationUpdate {
  122. if t != nil {
  123. pru.SetCreatedAt(*t)
  124. }
  125. return pru
  126. }
  127. // ClearCreatedAt clears the value of the "created_at" field.
  128. func (pru *PushRegistrationUpdate) ClearCreatedAt() *PushRegistrationUpdate {
  129. pru.mutation.ClearCreatedAt()
  130. return pru
  131. }
  132. // SetUpdatedAt sets the "updated_at" field.
  133. func (pru *PushRegistrationUpdate) SetUpdatedAt(t time.Time) *PushRegistrationUpdate {
  134. pru.mutation.SetUpdatedAt(t)
  135. return pru
  136. }
  137. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  138. func (pru *PushRegistrationUpdate) SetNillableUpdatedAt(t *time.Time) *PushRegistrationUpdate {
  139. if t != nil {
  140. pru.SetUpdatedAt(*t)
  141. }
  142. return pru
  143. }
  144. // ClearUpdatedAt clears the value of the "updated_at" field.
  145. func (pru *PushRegistrationUpdate) ClearUpdatedAt() *PushRegistrationUpdate {
  146. pru.mutation.ClearUpdatedAt()
  147. return pru
  148. }
  149. // Mutation returns the PushRegistrationMutation object of the builder.
  150. func (pru *PushRegistrationUpdate) Mutation() *PushRegistrationMutation {
  151. return pru.mutation
  152. }
  153. // Save executes the query and returns the number of nodes affected by the update operation.
  154. func (pru *PushRegistrationUpdate) Save(ctx context.Context) (int, error) {
  155. return withHooks(ctx, pru.sqlSave, pru.mutation, pru.hooks)
  156. }
  157. // SaveX is like Save, but panics if an error occurs.
  158. func (pru *PushRegistrationUpdate) SaveX(ctx context.Context) int {
  159. affected, err := pru.Save(ctx)
  160. if err != nil {
  161. panic(err)
  162. }
  163. return affected
  164. }
  165. // Exec executes the query.
  166. func (pru *PushRegistrationUpdate) Exec(ctx context.Context) error {
  167. _, err := pru.Save(ctx)
  168. return err
  169. }
  170. // ExecX is like Exec, but panics if an error occurs.
  171. func (pru *PushRegistrationUpdate) ExecX(ctx context.Context) {
  172. if err := pru.Exec(ctx); err != nil {
  173. panic(err)
  174. }
  175. }
  176. // check runs all checks and user-defined validators on the builder.
  177. func (pru *PushRegistrationUpdate) check() error {
  178. if v, ok := pru.mutation.Language(); ok {
  179. if err := pushregistration.LanguageValidator(v); err != nil {
  180. return &ValidationError{Name: "language", err: fmt.Errorf(`ent: validator failed for field "PushRegistration.language": %w`, err)}
  181. }
  182. }
  183. return nil
  184. }
  185. func (pru *PushRegistrationUpdate) sqlSave(ctx context.Context) (n int, err error) {
  186. if err := pru.check(); err != nil {
  187. return n, err
  188. }
  189. _spec := sqlgraph.NewUpdateSpec(pushregistration.Table, pushregistration.Columns, sqlgraph.NewFieldSpec(pushregistration.FieldID, field.TypeUUID))
  190. if ps := pru.mutation.predicates; len(ps) > 0 {
  191. _spec.Predicate = func(selector *sql.Selector) {
  192. for i := range ps {
  193. ps[i](selector)
  194. }
  195. }
  196. }
  197. if value, ok := pru.mutation.RegID(); ok {
  198. _spec.SetField(pushregistration.FieldRegID, field.TypeString, value)
  199. }
  200. if value, ok := pru.mutation.RegistrantPlatformType(); ok {
  201. _spec.SetField(pushregistration.FieldRegistrantPlatformType, field.TypeInt8, value)
  202. }
  203. if value, ok := pru.mutation.AddedRegistrantPlatformType(); ok {
  204. _spec.AddField(pushregistration.FieldRegistrantPlatformType, field.TypeInt8, value)
  205. }
  206. if value, ok := pru.mutation.Language(); ok {
  207. _spec.SetField(pushregistration.FieldLanguage, field.TypeString, value)
  208. }
  209. if value, ok := pru.mutation.DeviceModel(); ok {
  210. _spec.SetField(pushregistration.FieldDeviceModel, field.TypeString, value)
  211. }
  212. if value, ok := pru.mutation.DeviceManufacturer(); ok {
  213. _spec.SetField(pushregistration.FieldDeviceManufacturer, field.TypeString, value)
  214. }
  215. if value, ok := pru.mutation.DeviceSystemVersion(); ok {
  216. _spec.SetField(pushregistration.FieldDeviceSystemVersion, field.TypeString, value)
  217. }
  218. if value, ok := pru.mutation.DeviceSystem(); ok {
  219. _spec.SetField(pushregistration.FieldDeviceSystem, field.TypeString, value)
  220. }
  221. if value, ok := pru.mutation.CreatedAt(); ok {
  222. _spec.SetField(pushregistration.FieldCreatedAt, field.TypeTime, value)
  223. }
  224. if pru.mutation.CreatedAtCleared() {
  225. _spec.ClearField(pushregistration.FieldCreatedAt, field.TypeTime)
  226. }
  227. if value, ok := pru.mutation.UpdatedAt(); ok {
  228. _spec.SetField(pushregistration.FieldUpdatedAt, field.TypeTime, value)
  229. }
  230. if pru.mutation.UpdatedAtCleared() {
  231. _spec.ClearField(pushregistration.FieldUpdatedAt, field.TypeTime)
  232. }
  233. if n, err = sqlgraph.UpdateNodes(ctx, pru.driver, _spec); err != nil {
  234. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  235. err = &NotFoundError{pushregistration.Label}
  236. } else if sqlgraph.IsConstraintError(err) {
  237. err = &ConstraintError{msg: err.Error(), wrap: err}
  238. }
  239. return 0, err
  240. }
  241. pru.mutation.done = true
  242. return n, nil
  243. }
  244. // PushRegistrationUpdateOne is the builder for updating a single PushRegistration entity.
  245. type PushRegistrationUpdateOne struct {
  246. config
  247. fields []string
  248. hooks []Hook
  249. mutation *PushRegistrationMutation
  250. }
  251. // SetRegID sets the "reg_id" field.
  252. func (pruo *PushRegistrationUpdateOne) SetRegID(s string) *PushRegistrationUpdateOne {
  253. pruo.mutation.SetRegID(s)
  254. return pruo
  255. }
  256. // SetNillableRegID sets the "reg_id" field if the given value is not nil.
  257. func (pruo *PushRegistrationUpdateOne) SetNillableRegID(s *string) *PushRegistrationUpdateOne {
  258. if s != nil {
  259. pruo.SetRegID(*s)
  260. }
  261. return pruo
  262. }
  263. // SetRegistrantPlatformType sets the "registrant_platform_type" field.
  264. func (pruo *PushRegistrationUpdateOne) SetRegistrantPlatformType(i int8) *PushRegistrationUpdateOne {
  265. pruo.mutation.ResetRegistrantPlatformType()
  266. pruo.mutation.SetRegistrantPlatformType(i)
  267. return pruo
  268. }
  269. // SetNillableRegistrantPlatformType sets the "registrant_platform_type" field if the given value is not nil.
  270. func (pruo *PushRegistrationUpdateOne) SetNillableRegistrantPlatformType(i *int8) *PushRegistrationUpdateOne {
  271. if i != nil {
  272. pruo.SetRegistrantPlatformType(*i)
  273. }
  274. return pruo
  275. }
  276. // AddRegistrantPlatformType adds i to the "registrant_platform_type" field.
  277. func (pruo *PushRegistrationUpdateOne) AddRegistrantPlatformType(i int8) *PushRegistrationUpdateOne {
  278. pruo.mutation.AddRegistrantPlatformType(i)
  279. return pruo
  280. }
  281. // SetLanguage sets the "language" field.
  282. func (pruo *PushRegistrationUpdateOne) SetLanguage(s string) *PushRegistrationUpdateOne {
  283. pruo.mutation.SetLanguage(s)
  284. return pruo
  285. }
  286. // SetNillableLanguage sets the "language" field if the given value is not nil.
  287. func (pruo *PushRegistrationUpdateOne) SetNillableLanguage(s *string) *PushRegistrationUpdateOne {
  288. if s != nil {
  289. pruo.SetLanguage(*s)
  290. }
  291. return pruo
  292. }
  293. // SetDeviceModel sets the "device_model" field.
  294. func (pruo *PushRegistrationUpdateOne) SetDeviceModel(s string) *PushRegistrationUpdateOne {
  295. pruo.mutation.SetDeviceModel(s)
  296. return pruo
  297. }
  298. // SetNillableDeviceModel sets the "device_model" field if the given value is not nil.
  299. func (pruo *PushRegistrationUpdateOne) SetNillableDeviceModel(s *string) *PushRegistrationUpdateOne {
  300. if s != nil {
  301. pruo.SetDeviceModel(*s)
  302. }
  303. return pruo
  304. }
  305. // SetDeviceManufacturer sets the "device_manufacturer" field.
  306. func (pruo *PushRegistrationUpdateOne) SetDeviceManufacturer(s string) *PushRegistrationUpdateOne {
  307. pruo.mutation.SetDeviceManufacturer(s)
  308. return pruo
  309. }
  310. // SetNillableDeviceManufacturer sets the "device_manufacturer" field if the given value is not nil.
  311. func (pruo *PushRegistrationUpdateOne) SetNillableDeviceManufacturer(s *string) *PushRegistrationUpdateOne {
  312. if s != nil {
  313. pruo.SetDeviceManufacturer(*s)
  314. }
  315. return pruo
  316. }
  317. // SetDeviceSystemVersion sets the "device_system_version" field.
  318. func (pruo *PushRegistrationUpdateOne) SetDeviceSystemVersion(s string) *PushRegistrationUpdateOne {
  319. pruo.mutation.SetDeviceSystemVersion(s)
  320. return pruo
  321. }
  322. // SetNillableDeviceSystemVersion sets the "device_system_version" field if the given value is not nil.
  323. func (pruo *PushRegistrationUpdateOne) SetNillableDeviceSystemVersion(s *string) *PushRegistrationUpdateOne {
  324. if s != nil {
  325. pruo.SetDeviceSystemVersion(*s)
  326. }
  327. return pruo
  328. }
  329. // SetDeviceSystem sets the "device_system" field.
  330. func (pruo *PushRegistrationUpdateOne) SetDeviceSystem(s string) *PushRegistrationUpdateOne {
  331. pruo.mutation.SetDeviceSystem(s)
  332. return pruo
  333. }
  334. // SetNillableDeviceSystem sets the "device_system" field if the given value is not nil.
  335. func (pruo *PushRegistrationUpdateOne) SetNillableDeviceSystem(s *string) *PushRegistrationUpdateOne {
  336. if s != nil {
  337. pruo.SetDeviceSystem(*s)
  338. }
  339. return pruo
  340. }
  341. // SetCreatedAt sets the "created_at" field.
  342. func (pruo *PushRegistrationUpdateOne) SetCreatedAt(t time.Time) *PushRegistrationUpdateOne {
  343. pruo.mutation.SetCreatedAt(t)
  344. return pruo
  345. }
  346. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  347. func (pruo *PushRegistrationUpdateOne) SetNillableCreatedAt(t *time.Time) *PushRegistrationUpdateOne {
  348. if t != nil {
  349. pruo.SetCreatedAt(*t)
  350. }
  351. return pruo
  352. }
  353. // ClearCreatedAt clears the value of the "created_at" field.
  354. func (pruo *PushRegistrationUpdateOne) ClearCreatedAt() *PushRegistrationUpdateOne {
  355. pruo.mutation.ClearCreatedAt()
  356. return pruo
  357. }
  358. // SetUpdatedAt sets the "updated_at" field.
  359. func (pruo *PushRegistrationUpdateOne) SetUpdatedAt(t time.Time) *PushRegistrationUpdateOne {
  360. pruo.mutation.SetUpdatedAt(t)
  361. return pruo
  362. }
  363. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  364. func (pruo *PushRegistrationUpdateOne) SetNillableUpdatedAt(t *time.Time) *PushRegistrationUpdateOne {
  365. if t != nil {
  366. pruo.SetUpdatedAt(*t)
  367. }
  368. return pruo
  369. }
  370. // ClearUpdatedAt clears the value of the "updated_at" field.
  371. func (pruo *PushRegistrationUpdateOne) ClearUpdatedAt() *PushRegistrationUpdateOne {
  372. pruo.mutation.ClearUpdatedAt()
  373. return pruo
  374. }
  375. // Mutation returns the PushRegistrationMutation object of the builder.
  376. func (pruo *PushRegistrationUpdateOne) Mutation() *PushRegistrationMutation {
  377. return pruo.mutation
  378. }
  379. // Where appends a list predicates to the PushRegistrationUpdate builder.
  380. func (pruo *PushRegistrationUpdateOne) Where(ps ...predicate.PushRegistration) *PushRegistrationUpdateOne {
  381. pruo.mutation.Where(ps...)
  382. return pruo
  383. }
  384. // Select allows selecting one or more fields (columns) of the returned entity.
  385. // The default is selecting all fields defined in the entity schema.
  386. func (pruo *PushRegistrationUpdateOne) Select(field string, fields ...string) *PushRegistrationUpdateOne {
  387. pruo.fields = append([]string{field}, fields...)
  388. return pruo
  389. }
  390. // Save executes the query and returns the updated PushRegistration entity.
  391. func (pruo *PushRegistrationUpdateOne) Save(ctx context.Context) (*PushRegistration, error) {
  392. return withHooks(ctx, pruo.sqlSave, pruo.mutation, pruo.hooks)
  393. }
  394. // SaveX is like Save, but panics if an error occurs.
  395. func (pruo *PushRegistrationUpdateOne) SaveX(ctx context.Context) *PushRegistration {
  396. node, err := pruo.Save(ctx)
  397. if err != nil {
  398. panic(err)
  399. }
  400. return node
  401. }
  402. // Exec executes the query on the entity.
  403. func (pruo *PushRegistrationUpdateOne) Exec(ctx context.Context) error {
  404. _, err := pruo.Save(ctx)
  405. return err
  406. }
  407. // ExecX is like Exec, but panics if an error occurs.
  408. func (pruo *PushRegistrationUpdateOne) ExecX(ctx context.Context) {
  409. if err := pruo.Exec(ctx); err != nil {
  410. panic(err)
  411. }
  412. }
  413. // check runs all checks and user-defined validators on the builder.
  414. func (pruo *PushRegistrationUpdateOne) check() error {
  415. if v, ok := pruo.mutation.Language(); ok {
  416. if err := pushregistration.LanguageValidator(v); err != nil {
  417. return &ValidationError{Name: "language", err: fmt.Errorf(`ent: validator failed for field "PushRegistration.language": %w`, err)}
  418. }
  419. }
  420. return nil
  421. }
  422. func (pruo *PushRegistrationUpdateOne) sqlSave(ctx context.Context) (_node *PushRegistration, err error) {
  423. if err := pruo.check(); err != nil {
  424. return _node, err
  425. }
  426. _spec := sqlgraph.NewUpdateSpec(pushregistration.Table, pushregistration.Columns, sqlgraph.NewFieldSpec(pushregistration.FieldID, field.TypeUUID))
  427. id, ok := pruo.mutation.ID()
  428. if !ok {
  429. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PushRegistration.id" for update`)}
  430. }
  431. _spec.Node.ID.Value = id
  432. if fields := pruo.fields; len(fields) > 0 {
  433. _spec.Node.Columns = make([]string, 0, len(fields))
  434. _spec.Node.Columns = append(_spec.Node.Columns, pushregistration.FieldID)
  435. for _, f := range fields {
  436. if !pushregistration.ValidColumn(f) {
  437. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  438. }
  439. if f != pushregistration.FieldID {
  440. _spec.Node.Columns = append(_spec.Node.Columns, f)
  441. }
  442. }
  443. }
  444. if ps := pruo.mutation.predicates; len(ps) > 0 {
  445. _spec.Predicate = func(selector *sql.Selector) {
  446. for i := range ps {
  447. ps[i](selector)
  448. }
  449. }
  450. }
  451. if value, ok := pruo.mutation.RegID(); ok {
  452. _spec.SetField(pushregistration.FieldRegID, field.TypeString, value)
  453. }
  454. if value, ok := pruo.mutation.RegistrantPlatformType(); ok {
  455. _spec.SetField(pushregistration.FieldRegistrantPlatformType, field.TypeInt8, value)
  456. }
  457. if value, ok := pruo.mutation.AddedRegistrantPlatformType(); ok {
  458. _spec.AddField(pushregistration.FieldRegistrantPlatformType, field.TypeInt8, value)
  459. }
  460. if value, ok := pruo.mutation.Language(); ok {
  461. _spec.SetField(pushregistration.FieldLanguage, field.TypeString, value)
  462. }
  463. if value, ok := pruo.mutation.DeviceModel(); ok {
  464. _spec.SetField(pushregistration.FieldDeviceModel, field.TypeString, value)
  465. }
  466. if value, ok := pruo.mutation.DeviceManufacturer(); ok {
  467. _spec.SetField(pushregistration.FieldDeviceManufacturer, field.TypeString, value)
  468. }
  469. if value, ok := pruo.mutation.DeviceSystemVersion(); ok {
  470. _spec.SetField(pushregistration.FieldDeviceSystemVersion, field.TypeString, value)
  471. }
  472. if value, ok := pruo.mutation.DeviceSystem(); ok {
  473. _spec.SetField(pushregistration.FieldDeviceSystem, field.TypeString, value)
  474. }
  475. if value, ok := pruo.mutation.CreatedAt(); ok {
  476. _spec.SetField(pushregistration.FieldCreatedAt, field.TypeTime, value)
  477. }
  478. if pruo.mutation.CreatedAtCleared() {
  479. _spec.ClearField(pushregistration.FieldCreatedAt, field.TypeTime)
  480. }
  481. if value, ok := pruo.mutation.UpdatedAt(); ok {
  482. _spec.SetField(pushregistration.FieldUpdatedAt, field.TypeTime, value)
  483. }
  484. if pruo.mutation.UpdatedAtCleared() {
  485. _spec.ClearField(pushregistration.FieldUpdatedAt, field.TypeTime)
  486. }
  487. _node = &PushRegistration{config: pruo.config}
  488. _spec.Assign = _node.assignValues
  489. _spec.ScanValues = _node.scanValues
  490. if err = sqlgraph.UpdateNode(ctx, pruo.driver, _spec); err != nil {
  491. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  492. err = &NotFoundError{pushregistration.Label}
  493. } else if sqlgraph.IsConstraintError(err) {
  494. err = &ConstraintError{msg: err.Error(), wrap: err}
  495. }
  496. return nil, err
  497. }
  498. pruo.mutation.done = true
  499. return _node, nil
  500. }