authidentitychannel_update.go 20 KB

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