task_update.go 17 KB

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