identityadoptiondecision_update.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  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/authidentity"
  12. "github.com/Wei-Shaw/sub2api/ent/identityadoptiondecision"
  13. "github.com/Wei-Shaw/sub2api/ent/pendingauthsession"
  14. "github.com/Wei-Shaw/sub2api/ent/predicate"
  15. )
  16. // IdentityAdoptionDecisionUpdate is the builder for updating IdentityAdoptionDecision entities.
  17. type IdentityAdoptionDecisionUpdate struct {
  18. config
  19. hooks []Hook
  20. mutation *IdentityAdoptionDecisionMutation
  21. }
  22. // Where appends a list predicates to the IdentityAdoptionDecisionUpdate builder.
  23. func (_u *IdentityAdoptionDecisionUpdate) Where(ps ...predicate.IdentityAdoptionDecision) *IdentityAdoptionDecisionUpdate {
  24. _u.mutation.Where(ps...)
  25. return _u
  26. }
  27. // SetUpdatedAt sets the "updated_at" field.
  28. func (_u *IdentityAdoptionDecisionUpdate) SetUpdatedAt(v time.Time) *IdentityAdoptionDecisionUpdate {
  29. _u.mutation.SetUpdatedAt(v)
  30. return _u
  31. }
  32. // SetPendingAuthSessionID sets the "pending_auth_session_id" field.
  33. func (_u *IdentityAdoptionDecisionUpdate) SetPendingAuthSessionID(v int64) *IdentityAdoptionDecisionUpdate {
  34. _u.mutation.SetPendingAuthSessionID(v)
  35. return _u
  36. }
  37. // SetNillablePendingAuthSessionID sets the "pending_auth_session_id" field if the given value is not nil.
  38. func (_u *IdentityAdoptionDecisionUpdate) SetNillablePendingAuthSessionID(v *int64) *IdentityAdoptionDecisionUpdate {
  39. if v != nil {
  40. _u.SetPendingAuthSessionID(*v)
  41. }
  42. return _u
  43. }
  44. // SetIdentityID sets the "identity_id" field.
  45. func (_u *IdentityAdoptionDecisionUpdate) SetIdentityID(v int64) *IdentityAdoptionDecisionUpdate {
  46. _u.mutation.SetIdentityID(v)
  47. return _u
  48. }
  49. // SetNillableIdentityID sets the "identity_id" field if the given value is not nil.
  50. func (_u *IdentityAdoptionDecisionUpdate) SetNillableIdentityID(v *int64) *IdentityAdoptionDecisionUpdate {
  51. if v != nil {
  52. _u.SetIdentityID(*v)
  53. }
  54. return _u
  55. }
  56. // ClearIdentityID clears the value of the "identity_id" field.
  57. func (_u *IdentityAdoptionDecisionUpdate) ClearIdentityID() *IdentityAdoptionDecisionUpdate {
  58. _u.mutation.ClearIdentityID()
  59. return _u
  60. }
  61. // SetAdoptDisplayName sets the "adopt_display_name" field.
  62. func (_u *IdentityAdoptionDecisionUpdate) SetAdoptDisplayName(v bool) *IdentityAdoptionDecisionUpdate {
  63. _u.mutation.SetAdoptDisplayName(v)
  64. return _u
  65. }
  66. // SetNillableAdoptDisplayName sets the "adopt_display_name" field if the given value is not nil.
  67. func (_u *IdentityAdoptionDecisionUpdate) SetNillableAdoptDisplayName(v *bool) *IdentityAdoptionDecisionUpdate {
  68. if v != nil {
  69. _u.SetAdoptDisplayName(*v)
  70. }
  71. return _u
  72. }
  73. // SetAdoptAvatar sets the "adopt_avatar" field.
  74. func (_u *IdentityAdoptionDecisionUpdate) SetAdoptAvatar(v bool) *IdentityAdoptionDecisionUpdate {
  75. _u.mutation.SetAdoptAvatar(v)
  76. return _u
  77. }
  78. // SetNillableAdoptAvatar sets the "adopt_avatar" field if the given value is not nil.
  79. func (_u *IdentityAdoptionDecisionUpdate) SetNillableAdoptAvatar(v *bool) *IdentityAdoptionDecisionUpdate {
  80. if v != nil {
  81. _u.SetAdoptAvatar(*v)
  82. }
  83. return _u
  84. }
  85. // SetPendingAuthSession sets the "pending_auth_session" edge to the PendingAuthSession entity.
  86. func (_u *IdentityAdoptionDecisionUpdate) SetPendingAuthSession(v *PendingAuthSession) *IdentityAdoptionDecisionUpdate {
  87. return _u.SetPendingAuthSessionID(v.ID)
  88. }
  89. // SetIdentity sets the "identity" edge to the AuthIdentity entity.
  90. func (_u *IdentityAdoptionDecisionUpdate) SetIdentity(v *AuthIdentity) *IdentityAdoptionDecisionUpdate {
  91. return _u.SetIdentityID(v.ID)
  92. }
  93. // Mutation returns the IdentityAdoptionDecisionMutation object of the builder.
  94. func (_u *IdentityAdoptionDecisionUpdate) Mutation() *IdentityAdoptionDecisionMutation {
  95. return _u.mutation
  96. }
  97. // ClearPendingAuthSession clears the "pending_auth_session" edge to the PendingAuthSession entity.
  98. func (_u *IdentityAdoptionDecisionUpdate) ClearPendingAuthSession() *IdentityAdoptionDecisionUpdate {
  99. _u.mutation.ClearPendingAuthSession()
  100. return _u
  101. }
  102. // ClearIdentity clears the "identity" edge to the AuthIdentity entity.
  103. func (_u *IdentityAdoptionDecisionUpdate) ClearIdentity() *IdentityAdoptionDecisionUpdate {
  104. _u.mutation.ClearIdentity()
  105. return _u
  106. }
  107. // Save executes the query and returns the number of nodes affected by the update operation.
  108. func (_u *IdentityAdoptionDecisionUpdate) Save(ctx context.Context) (int, error) {
  109. _u.defaults()
  110. return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
  111. }
  112. // SaveX is like Save, but panics if an error occurs.
  113. func (_u *IdentityAdoptionDecisionUpdate) SaveX(ctx context.Context) int {
  114. affected, err := _u.Save(ctx)
  115. if err != nil {
  116. panic(err)
  117. }
  118. return affected
  119. }
  120. // Exec executes the query.
  121. func (_u *IdentityAdoptionDecisionUpdate) Exec(ctx context.Context) error {
  122. _, err := _u.Save(ctx)
  123. return err
  124. }
  125. // ExecX is like Exec, but panics if an error occurs.
  126. func (_u *IdentityAdoptionDecisionUpdate) ExecX(ctx context.Context) {
  127. if err := _u.Exec(ctx); err != nil {
  128. panic(err)
  129. }
  130. }
  131. // defaults sets the default values of the builder before save.
  132. func (_u *IdentityAdoptionDecisionUpdate) defaults() {
  133. if _, ok := _u.mutation.UpdatedAt(); !ok {
  134. v := identityadoptiondecision.UpdateDefaultUpdatedAt()
  135. _u.mutation.SetUpdatedAt(v)
  136. }
  137. }
  138. // check runs all checks and user-defined validators on the builder.
  139. func (_u *IdentityAdoptionDecisionUpdate) check() error {
  140. if _u.mutation.PendingAuthSessionCleared() && len(_u.mutation.PendingAuthSessionIDs()) > 0 {
  141. return errors.New(`ent: clearing a required unique edge "IdentityAdoptionDecision.pending_auth_session"`)
  142. }
  143. return nil
  144. }
  145. func (_u *IdentityAdoptionDecisionUpdate) sqlSave(ctx context.Context) (_node int, err error) {
  146. if err := _u.check(); err != nil {
  147. return _node, err
  148. }
  149. _spec := sqlgraph.NewUpdateSpec(identityadoptiondecision.Table, identityadoptiondecision.Columns, sqlgraph.NewFieldSpec(identityadoptiondecision.FieldID, field.TypeInt64))
  150. if ps := _u.mutation.predicates; len(ps) > 0 {
  151. _spec.Predicate = func(selector *sql.Selector) {
  152. for i := range ps {
  153. ps[i](selector)
  154. }
  155. }
  156. }
  157. if value, ok := _u.mutation.UpdatedAt(); ok {
  158. _spec.SetField(identityadoptiondecision.FieldUpdatedAt, field.TypeTime, value)
  159. }
  160. if value, ok := _u.mutation.AdoptDisplayName(); ok {
  161. _spec.SetField(identityadoptiondecision.FieldAdoptDisplayName, field.TypeBool, value)
  162. }
  163. if value, ok := _u.mutation.AdoptAvatar(); ok {
  164. _spec.SetField(identityadoptiondecision.FieldAdoptAvatar, field.TypeBool, value)
  165. }
  166. if _u.mutation.PendingAuthSessionCleared() {
  167. edge := &sqlgraph.EdgeSpec{
  168. Rel: sqlgraph.O2O,
  169. Inverse: true,
  170. Table: identityadoptiondecision.PendingAuthSessionTable,
  171. Columns: []string{identityadoptiondecision.PendingAuthSessionColumn},
  172. Bidi: false,
  173. Target: &sqlgraph.EdgeTarget{
  174. IDSpec: sqlgraph.NewFieldSpec(pendingauthsession.FieldID, field.TypeInt64),
  175. },
  176. }
  177. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  178. }
  179. if nodes := _u.mutation.PendingAuthSessionIDs(); len(nodes) > 0 {
  180. edge := &sqlgraph.EdgeSpec{
  181. Rel: sqlgraph.O2O,
  182. Inverse: true,
  183. Table: identityadoptiondecision.PendingAuthSessionTable,
  184. Columns: []string{identityadoptiondecision.PendingAuthSessionColumn},
  185. Bidi: false,
  186. Target: &sqlgraph.EdgeTarget{
  187. IDSpec: sqlgraph.NewFieldSpec(pendingauthsession.FieldID, field.TypeInt64),
  188. },
  189. }
  190. for _, k := range nodes {
  191. edge.Target.Nodes = append(edge.Target.Nodes, k)
  192. }
  193. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  194. }
  195. if _u.mutation.IdentityCleared() {
  196. edge := &sqlgraph.EdgeSpec{
  197. Rel: sqlgraph.M2O,
  198. Inverse: true,
  199. Table: identityadoptiondecision.IdentityTable,
  200. Columns: []string{identityadoptiondecision.IdentityColumn},
  201. Bidi: false,
  202. Target: &sqlgraph.EdgeTarget{
  203. IDSpec: sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64),
  204. },
  205. }
  206. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  207. }
  208. if nodes := _u.mutation.IdentityIDs(); len(nodes) > 0 {
  209. edge := &sqlgraph.EdgeSpec{
  210. Rel: sqlgraph.M2O,
  211. Inverse: true,
  212. Table: identityadoptiondecision.IdentityTable,
  213. Columns: []string{identityadoptiondecision.IdentityColumn},
  214. Bidi: false,
  215. Target: &sqlgraph.EdgeTarget{
  216. IDSpec: sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64),
  217. },
  218. }
  219. for _, k := range nodes {
  220. edge.Target.Nodes = append(edge.Target.Nodes, k)
  221. }
  222. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  223. }
  224. if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
  225. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  226. err = &NotFoundError{identityadoptiondecision.Label}
  227. } else if sqlgraph.IsConstraintError(err) {
  228. err = &ConstraintError{msg: err.Error(), wrap: err}
  229. }
  230. return 0, err
  231. }
  232. _u.mutation.done = true
  233. return _node, nil
  234. }
  235. // IdentityAdoptionDecisionUpdateOne is the builder for updating a single IdentityAdoptionDecision entity.
  236. type IdentityAdoptionDecisionUpdateOne struct {
  237. config
  238. fields []string
  239. hooks []Hook
  240. mutation *IdentityAdoptionDecisionMutation
  241. }
  242. // SetUpdatedAt sets the "updated_at" field.
  243. func (_u *IdentityAdoptionDecisionUpdateOne) SetUpdatedAt(v time.Time) *IdentityAdoptionDecisionUpdateOne {
  244. _u.mutation.SetUpdatedAt(v)
  245. return _u
  246. }
  247. // SetPendingAuthSessionID sets the "pending_auth_session_id" field.
  248. func (_u *IdentityAdoptionDecisionUpdateOne) SetPendingAuthSessionID(v int64) *IdentityAdoptionDecisionUpdateOne {
  249. _u.mutation.SetPendingAuthSessionID(v)
  250. return _u
  251. }
  252. // SetNillablePendingAuthSessionID sets the "pending_auth_session_id" field if the given value is not nil.
  253. func (_u *IdentityAdoptionDecisionUpdateOne) SetNillablePendingAuthSessionID(v *int64) *IdentityAdoptionDecisionUpdateOne {
  254. if v != nil {
  255. _u.SetPendingAuthSessionID(*v)
  256. }
  257. return _u
  258. }
  259. // SetIdentityID sets the "identity_id" field.
  260. func (_u *IdentityAdoptionDecisionUpdateOne) SetIdentityID(v int64) *IdentityAdoptionDecisionUpdateOne {
  261. _u.mutation.SetIdentityID(v)
  262. return _u
  263. }
  264. // SetNillableIdentityID sets the "identity_id" field if the given value is not nil.
  265. func (_u *IdentityAdoptionDecisionUpdateOne) SetNillableIdentityID(v *int64) *IdentityAdoptionDecisionUpdateOne {
  266. if v != nil {
  267. _u.SetIdentityID(*v)
  268. }
  269. return _u
  270. }
  271. // ClearIdentityID clears the value of the "identity_id" field.
  272. func (_u *IdentityAdoptionDecisionUpdateOne) ClearIdentityID() *IdentityAdoptionDecisionUpdateOne {
  273. _u.mutation.ClearIdentityID()
  274. return _u
  275. }
  276. // SetAdoptDisplayName sets the "adopt_display_name" field.
  277. func (_u *IdentityAdoptionDecisionUpdateOne) SetAdoptDisplayName(v bool) *IdentityAdoptionDecisionUpdateOne {
  278. _u.mutation.SetAdoptDisplayName(v)
  279. return _u
  280. }
  281. // SetNillableAdoptDisplayName sets the "adopt_display_name" field if the given value is not nil.
  282. func (_u *IdentityAdoptionDecisionUpdateOne) SetNillableAdoptDisplayName(v *bool) *IdentityAdoptionDecisionUpdateOne {
  283. if v != nil {
  284. _u.SetAdoptDisplayName(*v)
  285. }
  286. return _u
  287. }
  288. // SetAdoptAvatar sets the "adopt_avatar" field.
  289. func (_u *IdentityAdoptionDecisionUpdateOne) SetAdoptAvatar(v bool) *IdentityAdoptionDecisionUpdateOne {
  290. _u.mutation.SetAdoptAvatar(v)
  291. return _u
  292. }
  293. // SetNillableAdoptAvatar sets the "adopt_avatar" field if the given value is not nil.
  294. func (_u *IdentityAdoptionDecisionUpdateOne) SetNillableAdoptAvatar(v *bool) *IdentityAdoptionDecisionUpdateOne {
  295. if v != nil {
  296. _u.SetAdoptAvatar(*v)
  297. }
  298. return _u
  299. }
  300. // SetPendingAuthSession sets the "pending_auth_session" edge to the PendingAuthSession entity.
  301. func (_u *IdentityAdoptionDecisionUpdateOne) SetPendingAuthSession(v *PendingAuthSession) *IdentityAdoptionDecisionUpdateOne {
  302. return _u.SetPendingAuthSessionID(v.ID)
  303. }
  304. // SetIdentity sets the "identity" edge to the AuthIdentity entity.
  305. func (_u *IdentityAdoptionDecisionUpdateOne) SetIdentity(v *AuthIdentity) *IdentityAdoptionDecisionUpdateOne {
  306. return _u.SetIdentityID(v.ID)
  307. }
  308. // Mutation returns the IdentityAdoptionDecisionMutation object of the builder.
  309. func (_u *IdentityAdoptionDecisionUpdateOne) Mutation() *IdentityAdoptionDecisionMutation {
  310. return _u.mutation
  311. }
  312. // ClearPendingAuthSession clears the "pending_auth_session" edge to the PendingAuthSession entity.
  313. func (_u *IdentityAdoptionDecisionUpdateOne) ClearPendingAuthSession() *IdentityAdoptionDecisionUpdateOne {
  314. _u.mutation.ClearPendingAuthSession()
  315. return _u
  316. }
  317. // ClearIdentity clears the "identity" edge to the AuthIdentity entity.
  318. func (_u *IdentityAdoptionDecisionUpdateOne) ClearIdentity() *IdentityAdoptionDecisionUpdateOne {
  319. _u.mutation.ClearIdentity()
  320. return _u
  321. }
  322. // Where appends a list predicates to the IdentityAdoptionDecisionUpdate builder.
  323. func (_u *IdentityAdoptionDecisionUpdateOne) Where(ps ...predicate.IdentityAdoptionDecision) *IdentityAdoptionDecisionUpdateOne {
  324. _u.mutation.Where(ps...)
  325. return _u
  326. }
  327. // Select allows selecting one or more fields (columns) of the returned entity.
  328. // The default is selecting all fields defined in the entity schema.
  329. func (_u *IdentityAdoptionDecisionUpdateOne) Select(field string, fields ...string) *IdentityAdoptionDecisionUpdateOne {
  330. _u.fields = append([]string{field}, fields...)
  331. return _u
  332. }
  333. // Save executes the query and returns the updated IdentityAdoptionDecision entity.
  334. func (_u *IdentityAdoptionDecisionUpdateOne) Save(ctx context.Context) (*IdentityAdoptionDecision, error) {
  335. _u.defaults()
  336. return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
  337. }
  338. // SaveX is like Save, but panics if an error occurs.
  339. func (_u *IdentityAdoptionDecisionUpdateOne) SaveX(ctx context.Context) *IdentityAdoptionDecision {
  340. node, err := _u.Save(ctx)
  341. if err != nil {
  342. panic(err)
  343. }
  344. return node
  345. }
  346. // Exec executes the query on the entity.
  347. func (_u *IdentityAdoptionDecisionUpdateOne) Exec(ctx context.Context) error {
  348. _, err := _u.Save(ctx)
  349. return err
  350. }
  351. // ExecX is like Exec, but panics if an error occurs.
  352. func (_u *IdentityAdoptionDecisionUpdateOne) ExecX(ctx context.Context) {
  353. if err := _u.Exec(ctx); err != nil {
  354. panic(err)
  355. }
  356. }
  357. // defaults sets the default values of the builder before save.
  358. func (_u *IdentityAdoptionDecisionUpdateOne) defaults() {
  359. if _, ok := _u.mutation.UpdatedAt(); !ok {
  360. v := identityadoptiondecision.UpdateDefaultUpdatedAt()
  361. _u.mutation.SetUpdatedAt(v)
  362. }
  363. }
  364. // check runs all checks and user-defined validators on the builder.
  365. func (_u *IdentityAdoptionDecisionUpdateOne) check() error {
  366. if _u.mutation.PendingAuthSessionCleared() && len(_u.mutation.PendingAuthSessionIDs()) > 0 {
  367. return errors.New(`ent: clearing a required unique edge "IdentityAdoptionDecision.pending_auth_session"`)
  368. }
  369. return nil
  370. }
  371. func (_u *IdentityAdoptionDecisionUpdateOne) sqlSave(ctx context.Context) (_node *IdentityAdoptionDecision, err error) {
  372. if err := _u.check(); err != nil {
  373. return _node, err
  374. }
  375. _spec := sqlgraph.NewUpdateSpec(identityadoptiondecision.Table, identityadoptiondecision.Columns, sqlgraph.NewFieldSpec(identityadoptiondecision.FieldID, field.TypeInt64))
  376. id, ok := _u.mutation.ID()
  377. if !ok {
  378. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "IdentityAdoptionDecision.id" for update`)}
  379. }
  380. _spec.Node.ID.Value = id
  381. if fields := _u.fields; len(fields) > 0 {
  382. _spec.Node.Columns = make([]string, 0, len(fields))
  383. _spec.Node.Columns = append(_spec.Node.Columns, identityadoptiondecision.FieldID)
  384. for _, f := range fields {
  385. if !identityadoptiondecision.ValidColumn(f) {
  386. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  387. }
  388. if f != identityadoptiondecision.FieldID {
  389. _spec.Node.Columns = append(_spec.Node.Columns, f)
  390. }
  391. }
  392. }
  393. if ps := _u.mutation.predicates; len(ps) > 0 {
  394. _spec.Predicate = func(selector *sql.Selector) {
  395. for i := range ps {
  396. ps[i](selector)
  397. }
  398. }
  399. }
  400. if value, ok := _u.mutation.UpdatedAt(); ok {
  401. _spec.SetField(identityadoptiondecision.FieldUpdatedAt, field.TypeTime, value)
  402. }
  403. if value, ok := _u.mutation.AdoptDisplayName(); ok {
  404. _spec.SetField(identityadoptiondecision.FieldAdoptDisplayName, field.TypeBool, value)
  405. }
  406. if value, ok := _u.mutation.AdoptAvatar(); ok {
  407. _spec.SetField(identityadoptiondecision.FieldAdoptAvatar, field.TypeBool, value)
  408. }
  409. if _u.mutation.PendingAuthSessionCleared() {
  410. edge := &sqlgraph.EdgeSpec{
  411. Rel: sqlgraph.O2O,
  412. Inverse: true,
  413. Table: identityadoptiondecision.PendingAuthSessionTable,
  414. Columns: []string{identityadoptiondecision.PendingAuthSessionColumn},
  415. Bidi: false,
  416. Target: &sqlgraph.EdgeTarget{
  417. IDSpec: sqlgraph.NewFieldSpec(pendingauthsession.FieldID, field.TypeInt64),
  418. },
  419. }
  420. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  421. }
  422. if nodes := _u.mutation.PendingAuthSessionIDs(); len(nodes) > 0 {
  423. edge := &sqlgraph.EdgeSpec{
  424. Rel: sqlgraph.O2O,
  425. Inverse: true,
  426. Table: identityadoptiondecision.PendingAuthSessionTable,
  427. Columns: []string{identityadoptiondecision.PendingAuthSessionColumn},
  428. Bidi: false,
  429. Target: &sqlgraph.EdgeTarget{
  430. IDSpec: sqlgraph.NewFieldSpec(pendingauthsession.FieldID, field.TypeInt64),
  431. },
  432. }
  433. for _, k := range nodes {
  434. edge.Target.Nodes = append(edge.Target.Nodes, k)
  435. }
  436. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  437. }
  438. if _u.mutation.IdentityCleared() {
  439. edge := &sqlgraph.EdgeSpec{
  440. Rel: sqlgraph.M2O,
  441. Inverse: true,
  442. Table: identityadoptiondecision.IdentityTable,
  443. Columns: []string{identityadoptiondecision.IdentityColumn},
  444. Bidi: false,
  445. Target: &sqlgraph.EdgeTarget{
  446. IDSpec: sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64),
  447. },
  448. }
  449. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  450. }
  451. if nodes := _u.mutation.IdentityIDs(); len(nodes) > 0 {
  452. edge := &sqlgraph.EdgeSpec{
  453. Rel: sqlgraph.M2O,
  454. Inverse: true,
  455. Table: identityadoptiondecision.IdentityTable,
  456. Columns: []string{identityadoptiondecision.IdentityColumn},
  457. Bidi: false,
  458. Target: &sqlgraph.EdgeTarget{
  459. IDSpec: sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64),
  460. },
  461. }
  462. for _, k := range nodes {
  463. edge.Target.Nodes = append(edge.Target.Nodes, k)
  464. }
  465. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  466. }
  467. _node = &IdentityAdoptionDecision{config: _u.config}
  468. _spec.Assign = _node.assignValues
  469. _spec.ScanValues = _node.scanValues
  470. if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
  471. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  472. err = &NotFoundError{identityadoptiondecision.Label}
  473. } else if sqlgraph.IsConstraintError(err) {
  474. err = &ConstraintError{msg: err.Error(), wrap: err}
  475. }
  476. return nil, err
  477. }
  478. _u.mutation.done = true
  479. return _node, nil
  480. }