labeltagging_update.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "time"
  8. "wechat-api/ent/labeltagging"
  9. "wechat-api/ent/predicate"
  10. "entgo.io/ent/dialect/sql"
  11. "entgo.io/ent/dialect/sql/sqlgraph"
  12. "entgo.io/ent/dialect/sql/sqljson"
  13. "entgo.io/ent/schema/field"
  14. )
  15. // LabelTaggingUpdate is the builder for updating LabelTagging entities.
  16. type LabelTaggingUpdate struct {
  17. config
  18. hooks []Hook
  19. mutation *LabelTaggingMutation
  20. }
  21. // Where appends a list predicates to the LabelTaggingUpdate builder.
  22. func (ltu *LabelTaggingUpdate) Where(ps ...predicate.LabelTagging) *LabelTaggingUpdate {
  23. ltu.mutation.Where(ps...)
  24. return ltu
  25. }
  26. // SetUpdatedAt sets the "updated_at" field.
  27. func (ltu *LabelTaggingUpdate) SetUpdatedAt(t time.Time) *LabelTaggingUpdate {
  28. ltu.mutation.SetUpdatedAt(t)
  29. return ltu
  30. }
  31. // SetStatus sets the "status" field.
  32. func (ltu *LabelTaggingUpdate) SetStatus(u uint8) *LabelTaggingUpdate {
  33. ltu.mutation.ResetStatus()
  34. ltu.mutation.SetStatus(u)
  35. return ltu
  36. }
  37. // SetNillableStatus sets the "status" field if the given value is not nil.
  38. func (ltu *LabelTaggingUpdate) SetNillableStatus(u *uint8) *LabelTaggingUpdate {
  39. if u != nil {
  40. ltu.SetStatus(*u)
  41. }
  42. return ltu
  43. }
  44. // AddStatus adds u to the "status" field.
  45. func (ltu *LabelTaggingUpdate) AddStatus(u int8) *LabelTaggingUpdate {
  46. ltu.mutation.AddStatus(u)
  47. return ltu
  48. }
  49. // ClearStatus clears the value of the "status" field.
  50. func (ltu *LabelTaggingUpdate) ClearStatus() *LabelTaggingUpdate {
  51. ltu.mutation.ClearStatus()
  52. return ltu
  53. }
  54. // SetDeletedAt sets the "deleted_at" field.
  55. func (ltu *LabelTaggingUpdate) SetDeletedAt(t time.Time) *LabelTaggingUpdate {
  56. ltu.mutation.SetDeletedAt(t)
  57. return ltu
  58. }
  59. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  60. func (ltu *LabelTaggingUpdate) SetNillableDeletedAt(t *time.Time) *LabelTaggingUpdate {
  61. if t != nil {
  62. ltu.SetDeletedAt(*t)
  63. }
  64. return ltu
  65. }
  66. // ClearDeletedAt clears the value of the "deleted_at" field.
  67. func (ltu *LabelTaggingUpdate) ClearDeletedAt() *LabelTaggingUpdate {
  68. ltu.mutation.ClearDeletedAt()
  69. return ltu
  70. }
  71. // SetOrganizationID sets the "organization_id" field.
  72. func (ltu *LabelTaggingUpdate) SetOrganizationID(u uint64) *LabelTaggingUpdate {
  73. ltu.mutation.ResetOrganizationID()
  74. ltu.mutation.SetOrganizationID(u)
  75. return ltu
  76. }
  77. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  78. func (ltu *LabelTaggingUpdate) SetNillableOrganizationID(u *uint64) *LabelTaggingUpdate {
  79. if u != nil {
  80. ltu.SetOrganizationID(*u)
  81. }
  82. return ltu
  83. }
  84. // AddOrganizationID adds u to the "organization_id" field.
  85. func (ltu *LabelTaggingUpdate) AddOrganizationID(u int64) *LabelTaggingUpdate {
  86. ltu.mutation.AddOrganizationID(u)
  87. return ltu
  88. }
  89. // SetType sets the "type" field.
  90. func (ltu *LabelTaggingUpdate) SetType(i int) *LabelTaggingUpdate {
  91. ltu.mutation.ResetType()
  92. ltu.mutation.SetType(i)
  93. return ltu
  94. }
  95. // SetNillableType sets the "type" field if the given value is not nil.
  96. func (ltu *LabelTaggingUpdate) SetNillableType(i *int) *LabelTaggingUpdate {
  97. if i != nil {
  98. ltu.SetType(*i)
  99. }
  100. return ltu
  101. }
  102. // AddType adds i to the "type" field.
  103. func (ltu *LabelTaggingUpdate) AddType(i int) *LabelTaggingUpdate {
  104. ltu.mutation.AddType(i)
  105. return ltu
  106. }
  107. // SetConditions sets the "conditions" field.
  108. func (ltu *LabelTaggingUpdate) SetConditions(s string) *LabelTaggingUpdate {
  109. ltu.mutation.SetConditions(s)
  110. return ltu
  111. }
  112. // SetNillableConditions sets the "conditions" field if the given value is not nil.
  113. func (ltu *LabelTaggingUpdate) SetNillableConditions(s *string) *LabelTaggingUpdate {
  114. if s != nil {
  115. ltu.SetConditions(*s)
  116. }
  117. return ltu
  118. }
  119. // SetActionLabelAdd sets the "action_label_add" field.
  120. func (ltu *LabelTaggingUpdate) SetActionLabelAdd(u []uint64) *LabelTaggingUpdate {
  121. ltu.mutation.SetActionLabelAdd(u)
  122. return ltu
  123. }
  124. // AppendActionLabelAdd appends u to the "action_label_add" field.
  125. func (ltu *LabelTaggingUpdate) AppendActionLabelAdd(u []uint64) *LabelTaggingUpdate {
  126. ltu.mutation.AppendActionLabelAdd(u)
  127. return ltu
  128. }
  129. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  130. func (ltu *LabelTaggingUpdate) ClearActionLabelAdd() *LabelTaggingUpdate {
  131. ltu.mutation.ClearActionLabelAdd()
  132. return ltu
  133. }
  134. // SetActionLabelDel sets the "action_label_del" field.
  135. func (ltu *LabelTaggingUpdate) SetActionLabelDel(u []uint64) *LabelTaggingUpdate {
  136. ltu.mutation.SetActionLabelDel(u)
  137. return ltu
  138. }
  139. // AppendActionLabelDel appends u to the "action_label_del" field.
  140. func (ltu *LabelTaggingUpdate) AppendActionLabelDel(u []uint64) *LabelTaggingUpdate {
  141. ltu.mutation.AppendActionLabelDel(u)
  142. return ltu
  143. }
  144. // ClearActionLabelDel clears the value of the "action_label_del" field.
  145. func (ltu *LabelTaggingUpdate) ClearActionLabelDel() *LabelTaggingUpdate {
  146. ltu.mutation.ClearActionLabelDel()
  147. return ltu
  148. }
  149. // Mutation returns the LabelTaggingMutation object of the builder.
  150. func (ltu *LabelTaggingUpdate) Mutation() *LabelTaggingMutation {
  151. return ltu.mutation
  152. }
  153. // Save executes the query and returns the number of nodes affected by the update operation.
  154. func (ltu *LabelTaggingUpdate) Save(ctx context.Context) (int, error) {
  155. if err := ltu.defaults(); err != nil {
  156. return 0, err
  157. }
  158. return withHooks(ctx, ltu.sqlSave, ltu.mutation, ltu.hooks)
  159. }
  160. // SaveX is like Save, but panics if an error occurs.
  161. func (ltu *LabelTaggingUpdate) SaveX(ctx context.Context) int {
  162. affected, err := ltu.Save(ctx)
  163. if err != nil {
  164. panic(err)
  165. }
  166. return affected
  167. }
  168. // Exec executes the query.
  169. func (ltu *LabelTaggingUpdate) Exec(ctx context.Context) error {
  170. _, err := ltu.Save(ctx)
  171. return err
  172. }
  173. // ExecX is like Exec, but panics if an error occurs.
  174. func (ltu *LabelTaggingUpdate) ExecX(ctx context.Context) {
  175. if err := ltu.Exec(ctx); err != nil {
  176. panic(err)
  177. }
  178. }
  179. // defaults sets the default values of the builder before save.
  180. func (ltu *LabelTaggingUpdate) defaults() error {
  181. if _, ok := ltu.mutation.UpdatedAt(); !ok {
  182. if labeltagging.UpdateDefaultUpdatedAt == nil {
  183. return fmt.Errorf("ent: uninitialized labeltagging.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  184. }
  185. v := labeltagging.UpdateDefaultUpdatedAt()
  186. ltu.mutation.SetUpdatedAt(v)
  187. }
  188. return nil
  189. }
  190. func (ltu *LabelTaggingUpdate) sqlSave(ctx context.Context) (n int, err error) {
  191. _spec := sqlgraph.NewUpdateSpec(labeltagging.Table, labeltagging.Columns, sqlgraph.NewFieldSpec(labeltagging.FieldID, field.TypeUint64))
  192. if ps := ltu.mutation.predicates; len(ps) > 0 {
  193. _spec.Predicate = func(selector *sql.Selector) {
  194. for i := range ps {
  195. ps[i](selector)
  196. }
  197. }
  198. }
  199. if value, ok := ltu.mutation.UpdatedAt(); ok {
  200. _spec.SetField(labeltagging.FieldUpdatedAt, field.TypeTime, value)
  201. }
  202. if value, ok := ltu.mutation.Status(); ok {
  203. _spec.SetField(labeltagging.FieldStatus, field.TypeUint8, value)
  204. }
  205. if value, ok := ltu.mutation.AddedStatus(); ok {
  206. _spec.AddField(labeltagging.FieldStatus, field.TypeUint8, value)
  207. }
  208. if ltu.mutation.StatusCleared() {
  209. _spec.ClearField(labeltagging.FieldStatus, field.TypeUint8)
  210. }
  211. if value, ok := ltu.mutation.DeletedAt(); ok {
  212. _spec.SetField(labeltagging.FieldDeletedAt, field.TypeTime, value)
  213. }
  214. if ltu.mutation.DeletedAtCleared() {
  215. _spec.ClearField(labeltagging.FieldDeletedAt, field.TypeTime)
  216. }
  217. if value, ok := ltu.mutation.OrganizationID(); ok {
  218. _spec.SetField(labeltagging.FieldOrganizationID, field.TypeUint64, value)
  219. }
  220. if value, ok := ltu.mutation.AddedOrganizationID(); ok {
  221. _spec.AddField(labeltagging.FieldOrganizationID, field.TypeUint64, value)
  222. }
  223. if value, ok := ltu.mutation.GetType(); ok {
  224. _spec.SetField(labeltagging.FieldType, field.TypeInt, value)
  225. }
  226. if value, ok := ltu.mutation.AddedType(); ok {
  227. _spec.AddField(labeltagging.FieldType, field.TypeInt, value)
  228. }
  229. if value, ok := ltu.mutation.Conditions(); ok {
  230. _spec.SetField(labeltagging.FieldConditions, field.TypeString, value)
  231. }
  232. if value, ok := ltu.mutation.ActionLabelAdd(); ok {
  233. _spec.SetField(labeltagging.FieldActionLabelAdd, field.TypeJSON, value)
  234. }
  235. if value, ok := ltu.mutation.AppendedActionLabelAdd(); ok {
  236. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  237. sqljson.Append(u, labeltagging.FieldActionLabelAdd, value)
  238. })
  239. }
  240. if ltu.mutation.ActionLabelAddCleared() {
  241. _spec.ClearField(labeltagging.FieldActionLabelAdd, field.TypeJSON)
  242. }
  243. if value, ok := ltu.mutation.ActionLabelDel(); ok {
  244. _spec.SetField(labeltagging.FieldActionLabelDel, field.TypeJSON, value)
  245. }
  246. if value, ok := ltu.mutation.AppendedActionLabelDel(); ok {
  247. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  248. sqljson.Append(u, labeltagging.FieldActionLabelDel, value)
  249. })
  250. }
  251. if ltu.mutation.ActionLabelDelCleared() {
  252. _spec.ClearField(labeltagging.FieldActionLabelDel, field.TypeJSON)
  253. }
  254. if n, err = sqlgraph.UpdateNodes(ctx, ltu.driver, _spec); err != nil {
  255. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  256. err = &NotFoundError{labeltagging.Label}
  257. } else if sqlgraph.IsConstraintError(err) {
  258. err = &ConstraintError{msg: err.Error(), wrap: err}
  259. }
  260. return 0, err
  261. }
  262. ltu.mutation.done = true
  263. return n, nil
  264. }
  265. // LabelTaggingUpdateOne is the builder for updating a single LabelTagging entity.
  266. type LabelTaggingUpdateOne struct {
  267. config
  268. fields []string
  269. hooks []Hook
  270. mutation *LabelTaggingMutation
  271. }
  272. // SetUpdatedAt sets the "updated_at" field.
  273. func (ltuo *LabelTaggingUpdateOne) SetUpdatedAt(t time.Time) *LabelTaggingUpdateOne {
  274. ltuo.mutation.SetUpdatedAt(t)
  275. return ltuo
  276. }
  277. // SetStatus sets the "status" field.
  278. func (ltuo *LabelTaggingUpdateOne) SetStatus(u uint8) *LabelTaggingUpdateOne {
  279. ltuo.mutation.ResetStatus()
  280. ltuo.mutation.SetStatus(u)
  281. return ltuo
  282. }
  283. // SetNillableStatus sets the "status" field if the given value is not nil.
  284. func (ltuo *LabelTaggingUpdateOne) SetNillableStatus(u *uint8) *LabelTaggingUpdateOne {
  285. if u != nil {
  286. ltuo.SetStatus(*u)
  287. }
  288. return ltuo
  289. }
  290. // AddStatus adds u to the "status" field.
  291. func (ltuo *LabelTaggingUpdateOne) AddStatus(u int8) *LabelTaggingUpdateOne {
  292. ltuo.mutation.AddStatus(u)
  293. return ltuo
  294. }
  295. // ClearStatus clears the value of the "status" field.
  296. func (ltuo *LabelTaggingUpdateOne) ClearStatus() *LabelTaggingUpdateOne {
  297. ltuo.mutation.ClearStatus()
  298. return ltuo
  299. }
  300. // SetDeletedAt sets the "deleted_at" field.
  301. func (ltuo *LabelTaggingUpdateOne) SetDeletedAt(t time.Time) *LabelTaggingUpdateOne {
  302. ltuo.mutation.SetDeletedAt(t)
  303. return ltuo
  304. }
  305. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  306. func (ltuo *LabelTaggingUpdateOne) SetNillableDeletedAt(t *time.Time) *LabelTaggingUpdateOne {
  307. if t != nil {
  308. ltuo.SetDeletedAt(*t)
  309. }
  310. return ltuo
  311. }
  312. // ClearDeletedAt clears the value of the "deleted_at" field.
  313. func (ltuo *LabelTaggingUpdateOne) ClearDeletedAt() *LabelTaggingUpdateOne {
  314. ltuo.mutation.ClearDeletedAt()
  315. return ltuo
  316. }
  317. // SetOrganizationID sets the "organization_id" field.
  318. func (ltuo *LabelTaggingUpdateOne) SetOrganizationID(u uint64) *LabelTaggingUpdateOne {
  319. ltuo.mutation.ResetOrganizationID()
  320. ltuo.mutation.SetOrganizationID(u)
  321. return ltuo
  322. }
  323. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  324. func (ltuo *LabelTaggingUpdateOne) SetNillableOrganizationID(u *uint64) *LabelTaggingUpdateOne {
  325. if u != nil {
  326. ltuo.SetOrganizationID(*u)
  327. }
  328. return ltuo
  329. }
  330. // AddOrganizationID adds u to the "organization_id" field.
  331. func (ltuo *LabelTaggingUpdateOne) AddOrganizationID(u int64) *LabelTaggingUpdateOne {
  332. ltuo.mutation.AddOrganizationID(u)
  333. return ltuo
  334. }
  335. // SetType sets the "type" field.
  336. func (ltuo *LabelTaggingUpdateOne) SetType(i int) *LabelTaggingUpdateOne {
  337. ltuo.mutation.ResetType()
  338. ltuo.mutation.SetType(i)
  339. return ltuo
  340. }
  341. // SetNillableType sets the "type" field if the given value is not nil.
  342. func (ltuo *LabelTaggingUpdateOne) SetNillableType(i *int) *LabelTaggingUpdateOne {
  343. if i != nil {
  344. ltuo.SetType(*i)
  345. }
  346. return ltuo
  347. }
  348. // AddType adds i to the "type" field.
  349. func (ltuo *LabelTaggingUpdateOne) AddType(i int) *LabelTaggingUpdateOne {
  350. ltuo.mutation.AddType(i)
  351. return ltuo
  352. }
  353. // SetConditions sets the "conditions" field.
  354. func (ltuo *LabelTaggingUpdateOne) SetConditions(s string) *LabelTaggingUpdateOne {
  355. ltuo.mutation.SetConditions(s)
  356. return ltuo
  357. }
  358. // SetNillableConditions sets the "conditions" field if the given value is not nil.
  359. func (ltuo *LabelTaggingUpdateOne) SetNillableConditions(s *string) *LabelTaggingUpdateOne {
  360. if s != nil {
  361. ltuo.SetConditions(*s)
  362. }
  363. return ltuo
  364. }
  365. // SetActionLabelAdd sets the "action_label_add" field.
  366. func (ltuo *LabelTaggingUpdateOne) SetActionLabelAdd(u []uint64) *LabelTaggingUpdateOne {
  367. ltuo.mutation.SetActionLabelAdd(u)
  368. return ltuo
  369. }
  370. // AppendActionLabelAdd appends u to the "action_label_add" field.
  371. func (ltuo *LabelTaggingUpdateOne) AppendActionLabelAdd(u []uint64) *LabelTaggingUpdateOne {
  372. ltuo.mutation.AppendActionLabelAdd(u)
  373. return ltuo
  374. }
  375. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  376. func (ltuo *LabelTaggingUpdateOne) ClearActionLabelAdd() *LabelTaggingUpdateOne {
  377. ltuo.mutation.ClearActionLabelAdd()
  378. return ltuo
  379. }
  380. // SetActionLabelDel sets the "action_label_del" field.
  381. func (ltuo *LabelTaggingUpdateOne) SetActionLabelDel(u []uint64) *LabelTaggingUpdateOne {
  382. ltuo.mutation.SetActionLabelDel(u)
  383. return ltuo
  384. }
  385. // AppendActionLabelDel appends u to the "action_label_del" field.
  386. func (ltuo *LabelTaggingUpdateOne) AppendActionLabelDel(u []uint64) *LabelTaggingUpdateOne {
  387. ltuo.mutation.AppendActionLabelDel(u)
  388. return ltuo
  389. }
  390. // ClearActionLabelDel clears the value of the "action_label_del" field.
  391. func (ltuo *LabelTaggingUpdateOne) ClearActionLabelDel() *LabelTaggingUpdateOne {
  392. ltuo.mutation.ClearActionLabelDel()
  393. return ltuo
  394. }
  395. // Mutation returns the LabelTaggingMutation object of the builder.
  396. func (ltuo *LabelTaggingUpdateOne) Mutation() *LabelTaggingMutation {
  397. return ltuo.mutation
  398. }
  399. // Where appends a list predicates to the LabelTaggingUpdate builder.
  400. func (ltuo *LabelTaggingUpdateOne) Where(ps ...predicate.LabelTagging) *LabelTaggingUpdateOne {
  401. ltuo.mutation.Where(ps...)
  402. return ltuo
  403. }
  404. // Select allows selecting one or more fields (columns) of the returned entity.
  405. // The default is selecting all fields defined in the entity schema.
  406. func (ltuo *LabelTaggingUpdateOne) Select(field string, fields ...string) *LabelTaggingUpdateOne {
  407. ltuo.fields = append([]string{field}, fields...)
  408. return ltuo
  409. }
  410. // Save executes the query and returns the updated LabelTagging entity.
  411. func (ltuo *LabelTaggingUpdateOne) Save(ctx context.Context) (*LabelTagging, error) {
  412. if err := ltuo.defaults(); err != nil {
  413. return nil, err
  414. }
  415. return withHooks(ctx, ltuo.sqlSave, ltuo.mutation, ltuo.hooks)
  416. }
  417. // SaveX is like Save, but panics if an error occurs.
  418. func (ltuo *LabelTaggingUpdateOne) SaveX(ctx context.Context) *LabelTagging {
  419. node, err := ltuo.Save(ctx)
  420. if err != nil {
  421. panic(err)
  422. }
  423. return node
  424. }
  425. // Exec executes the query on the entity.
  426. func (ltuo *LabelTaggingUpdateOne) Exec(ctx context.Context) error {
  427. _, err := ltuo.Save(ctx)
  428. return err
  429. }
  430. // ExecX is like Exec, but panics if an error occurs.
  431. func (ltuo *LabelTaggingUpdateOne) ExecX(ctx context.Context) {
  432. if err := ltuo.Exec(ctx); err != nil {
  433. panic(err)
  434. }
  435. }
  436. // defaults sets the default values of the builder before save.
  437. func (ltuo *LabelTaggingUpdateOne) defaults() error {
  438. if _, ok := ltuo.mutation.UpdatedAt(); !ok {
  439. if labeltagging.UpdateDefaultUpdatedAt == nil {
  440. return fmt.Errorf("ent: uninitialized labeltagging.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  441. }
  442. v := labeltagging.UpdateDefaultUpdatedAt()
  443. ltuo.mutation.SetUpdatedAt(v)
  444. }
  445. return nil
  446. }
  447. func (ltuo *LabelTaggingUpdateOne) sqlSave(ctx context.Context) (_node *LabelTagging, err error) {
  448. _spec := sqlgraph.NewUpdateSpec(labeltagging.Table, labeltagging.Columns, sqlgraph.NewFieldSpec(labeltagging.FieldID, field.TypeUint64))
  449. id, ok := ltuo.mutation.ID()
  450. if !ok {
  451. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "LabelTagging.id" for update`)}
  452. }
  453. _spec.Node.ID.Value = id
  454. if fields := ltuo.fields; len(fields) > 0 {
  455. _spec.Node.Columns = make([]string, 0, len(fields))
  456. _spec.Node.Columns = append(_spec.Node.Columns, labeltagging.FieldID)
  457. for _, f := range fields {
  458. if !labeltagging.ValidColumn(f) {
  459. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  460. }
  461. if f != labeltagging.FieldID {
  462. _spec.Node.Columns = append(_spec.Node.Columns, f)
  463. }
  464. }
  465. }
  466. if ps := ltuo.mutation.predicates; len(ps) > 0 {
  467. _spec.Predicate = func(selector *sql.Selector) {
  468. for i := range ps {
  469. ps[i](selector)
  470. }
  471. }
  472. }
  473. if value, ok := ltuo.mutation.UpdatedAt(); ok {
  474. _spec.SetField(labeltagging.FieldUpdatedAt, field.TypeTime, value)
  475. }
  476. if value, ok := ltuo.mutation.Status(); ok {
  477. _spec.SetField(labeltagging.FieldStatus, field.TypeUint8, value)
  478. }
  479. if value, ok := ltuo.mutation.AddedStatus(); ok {
  480. _spec.AddField(labeltagging.FieldStatus, field.TypeUint8, value)
  481. }
  482. if ltuo.mutation.StatusCleared() {
  483. _spec.ClearField(labeltagging.FieldStatus, field.TypeUint8)
  484. }
  485. if value, ok := ltuo.mutation.DeletedAt(); ok {
  486. _spec.SetField(labeltagging.FieldDeletedAt, field.TypeTime, value)
  487. }
  488. if ltuo.mutation.DeletedAtCleared() {
  489. _spec.ClearField(labeltagging.FieldDeletedAt, field.TypeTime)
  490. }
  491. if value, ok := ltuo.mutation.OrganizationID(); ok {
  492. _spec.SetField(labeltagging.FieldOrganizationID, field.TypeUint64, value)
  493. }
  494. if value, ok := ltuo.mutation.AddedOrganizationID(); ok {
  495. _spec.AddField(labeltagging.FieldOrganizationID, field.TypeUint64, value)
  496. }
  497. if value, ok := ltuo.mutation.GetType(); ok {
  498. _spec.SetField(labeltagging.FieldType, field.TypeInt, value)
  499. }
  500. if value, ok := ltuo.mutation.AddedType(); ok {
  501. _spec.AddField(labeltagging.FieldType, field.TypeInt, value)
  502. }
  503. if value, ok := ltuo.mutation.Conditions(); ok {
  504. _spec.SetField(labeltagging.FieldConditions, field.TypeString, value)
  505. }
  506. if value, ok := ltuo.mutation.ActionLabelAdd(); ok {
  507. _spec.SetField(labeltagging.FieldActionLabelAdd, field.TypeJSON, value)
  508. }
  509. if value, ok := ltuo.mutation.AppendedActionLabelAdd(); ok {
  510. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  511. sqljson.Append(u, labeltagging.FieldActionLabelAdd, value)
  512. })
  513. }
  514. if ltuo.mutation.ActionLabelAddCleared() {
  515. _spec.ClearField(labeltagging.FieldActionLabelAdd, field.TypeJSON)
  516. }
  517. if value, ok := ltuo.mutation.ActionLabelDel(); ok {
  518. _spec.SetField(labeltagging.FieldActionLabelDel, field.TypeJSON, value)
  519. }
  520. if value, ok := ltuo.mutation.AppendedActionLabelDel(); ok {
  521. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  522. sqljson.Append(u, labeltagging.FieldActionLabelDel, value)
  523. })
  524. }
  525. if ltuo.mutation.ActionLabelDelCleared() {
  526. _spec.ClearField(labeltagging.FieldActionLabelDel, field.TypeJSON)
  527. }
  528. _node = &LabelTagging{config: ltuo.config}
  529. _spec.Assign = _node.assignValues
  530. _spec.ScanValues = _node.scanValues
  531. if err = sqlgraph.UpdateNode(ctx, ltuo.driver, _spec); err != nil {
  532. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  533. err = &NotFoundError{labeltagging.Label}
  534. } else if sqlgraph.IsConstraintError(err) {
  535. err = &ConstraintError{msg: err.Error(), wrap: err}
  536. }
  537. return nil, err
  538. }
  539. ltuo.mutation.done = true
  540. return _node, nil
  541. }