userallowedgroup_create.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  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/group"
  12. "github.com/Wei-Shaw/sub2api/ent/user"
  13. "github.com/Wei-Shaw/sub2api/ent/userallowedgroup"
  14. )
  15. // UserAllowedGroupCreate is the builder for creating a UserAllowedGroup entity.
  16. type UserAllowedGroupCreate struct {
  17. config
  18. mutation *UserAllowedGroupMutation
  19. hooks []Hook
  20. conflict []sql.ConflictOption
  21. }
  22. // SetUserID sets the "user_id" field.
  23. func (_c *UserAllowedGroupCreate) SetUserID(v int64) *UserAllowedGroupCreate {
  24. _c.mutation.SetUserID(v)
  25. return _c
  26. }
  27. // SetGroupID sets the "group_id" field.
  28. func (_c *UserAllowedGroupCreate) SetGroupID(v int64) *UserAllowedGroupCreate {
  29. _c.mutation.SetGroupID(v)
  30. return _c
  31. }
  32. // SetCreatedAt sets the "created_at" field.
  33. func (_c *UserAllowedGroupCreate) SetCreatedAt(v time.Time) *UserAllowedGroupCreate {
  34. _c.mutation.SetCreatedAt(v)
  35. return _c
  36. }
  37. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  38. func (_c *UserAllowedGroupCreate) SetNillableCreatedAt(v *time.Time) *UserAllowedGroupCreate {
  39. if v != nil {
  40. _c.SetCreatedAt(*v)
  41. }
  42. return _c
  43. }
  44. // SetUser sets the "user" edge to the User entity.
  45. func (_c *UserAllowedGroupCreate) SetUser(v *User) *UserAllowedGroupCreate {
  46. return _c.SetUserID(v.ID)
  47. }
  48. // SetGroup sets the "group" edge to the Group entity.
  49. func (_c *UserAllowedGroupCreate) SetGroup(v *Group) *UserAllowedGroupCreate {
  50. return _c.SetGroupID(v.ID)
  51. }
  52. // Mutation returns the UserAllowedGroupMutation object of the builder.
  53. func (_c *UserAllowedGroupCreate) Mutation() *UserAllowedGroupMutation {
  54. return _c.mutation
  55. }
  56. // Save creates the UserAllowedGroup in the database.
  57. func (_c *UserAllowedGroupCreate) Save(ctx context.Context) (*UserAllowedGroup, error) {
  58. _c.defaults()
  59. return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
  60. }
  61. // SaveX calls Save and panics if Save returns an error.
  62. func (_c *UserAllowedGroupCreate) SaveX(ctx context.Context) *UserAllowedGroup {
  63. v, err := _c.Save(ctx)
  64. if err != nil {
  65. panic(err)
  66. }
  67. return v
  68. }
  69. // Exec executes the query.
  70. func (_c *UserAllowedGroupCreate) Exec(ctx context.Context) error {
  71. _, err := _c.Save(ctx)
  72. return err
  73. }
  74. // ExecX is like Exec, but panics if an error occurs.
  75. func (_c *UserAllowedGroupCreate) ExecX(ctx context.Context) {
  76. if err := _c.Exec(ctx); err != nil {
  77. panic(err)
  78. }
  79. }
  80. // defaults sets the default values of the builder before save.
  81. func (_c *UserAllowedGroupCreate) defaults() {
  82. if _, ok := _c.mutation.CreatedAt(); !ok {
  83. v := userallowedgroup.DefaultCreatedAt()
  84. _c.mutation.SetCreatedAt(v)
  85. }
  86. }
  87. // check runs all checks and user-defined validators on the builder.
  88. func (_c *UserAllowedGroupCreate) check() error {
  89. if _, ok := _c.mutation.UserID(); !ok {
  90. return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "UserAllowedGroup.user_id"`)}
  91. }
  92. if _, ok := _c.mutation.GroupID(); !ok {
  93. return &ValidationError{Name: "group_id", err: errors.New(`ent: missing required field "UserAllowedGroup.group_id"`)}
  94. }
  95. if _, ok := _c.mutation.CreatedAt(); !ok {
  96. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "UserAllowedGroup.created_at"`)}
  97. }
  98. if len(_c.mutation.UserIDs()) == 0 {
  99. return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "UserAllowedGroup.user"`)}
  100. }
  101. if len(_c.mutation.GroupIDs()) == 0 {
  102. return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "UserAllowedGroup.group"`)}
  103. }
  104. return nil
  105. }
  106. func (_c *UserAllowedGroupCreate) sqlSave(ctx context.Context) (*UserAllowedGroup, error) {
  107. if err := _c.check(); err != nil {
  108. return nil, err
  109. }
  110. _node, _spec := _c.createSpec()
  111. if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
  112. if sqlgraph.IsConstraintError(err) {
  113. err = &ConstraintError{msg: err.Error(), wrap: err}
  114. }
  115. return nil, err
  116. }
  117. return _node, nil
  118. }
  119. func (_c *UserAllowedGroupCreate) createSpec() (*UserAllowedGroup, *sqlgraph.CreateSpec) {
  120. var (
  121. _node = &UserAllowedGroup{config: _c.config}
  122. _spec = sqlgraph.NewCreateSpec(userallowedgroup.Table, nil)
  123. )
  124. _spec.OnConflict = _c.conflict
  125. if value, ok := _c.mutation.CreatedAt(); ok {
  126. _spec.SetField(userallowedgroup.FieldCreatedAt, field.TypeTime, value)
  127. _node.CreatedAt = value
  128. }
  129. if nodes := _c.mutation.UserIDs(); len(nodes) > 0 {
  130. edge := &sqlgraph.EdgeSpec{
  131. Rel: sqlgraph.M2O,
  132. Inverse: false,
  133. Table: userallowedgroup.UserTable,
  134. Columns: []string{userallowedgroup.UserColumn},
  135. Bidi: false,
  136. Target: &sqlgraph.EdgeTarget{
  137. IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
  138. },
  139. }
  140. for _, k := range nodes {
  141. edge.Target.Nodes = append(edge.Target.Nodes, k)
  142. }
  143. _node.UserID = nodes[0]
  144. _spec.Edges = append(_spec.Edges, edge)
  145. }
  146. if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 {
  147. edge := &sqlgraph.EdgeSpec{
  148. Rel: sqlgraph.M2O,
  149. Inverse: false,
  150. Table: userallowedgroup.GroupTable,
  151. Columns: []string{userallowedgroup.GroupColumn},
  152. Bidi: false,
  153. Target: &sqlgraph.EdgeTarget{
  154. IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
  155. },
  156. }
  157. for _, k := range nodes {
  158. edge.Target.Nodes = append(edge.Target.Nodes, k)
  159. }
  160. _node.GroupID = nodes[0]
  161. _spec.Edges = append(_spec.Edges, edge)
  162. }
  163. return _node, _spec
  164. }
  165. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  166. // of the `INSERT` statement. For example:
  167. //
  168. // client.UserAllowedGroup.Create().
  169. // SetUserID(v).
  170. // OnConflict(
  171. // // Update the row with the new values
  172. // // the was proposed for insertion.
  173. // sql.ResolveWithNewValues(),
  174. // ).
  175. // // Override some of the fields with custom
  176. // // update values.
  177. // Update(func(u *ent.UserAllowedGroupUpsert) {
  178. // SetUserID(v+v).
  179. // }).
  180. // Exec(ctx)
  181. func (_c *UserAllowedGroupCreate) OnConflict(opts ...sql.ConflictOption) *UserAllowedGroupUpsertOne {
  182. _c.conflict = opts
  183. return &UserAllowedGroupUpsertOne{
  184. create: _c,
  185. }
  186. }
  187. // OnConflictColumns calls `OnConflict` and configures the columns
  188. // as conflict target. Using this option is equivalent to using:
  189. //
  190. // client.UserAllowedGroup.Create().
  191. // OnConflict(sql.ConflictColumns(columns...)).
  192. // Exec(ctx)
  193. func (_c *UserAllowedGroupCreate) OnConflictColumns(columns ...string) *UserAllowedGroupUpsertOne {
  194. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  195. return &UserAllowedGroupUpsertOne{
  196. create: _c,
  197. }
  198. }
  199. type (
  200. // UserAllowedGroupUpsertOne is the builder for "upsert"-ing
  201. // one UserAllowedGroup node.
  202. UserAllowedGroupUpsertOne struct {
  203. create *UserAllowedGroupCreate
  204. }
  205. // UserAllowedGroupUpsert is the "OnConflict" setter.
  206. UserAllowedGroupUpsert struct {
  207. *sql.UpdateSet
  208. }
  209. )
  210. // SetUserID sets the "user_id" field.
  211. func (u *UserAllowedGroupUpsert) SetUserID(v int64) *UserAllowedGroupUpsert {
  212. u.Set(userallowedgroup.FieldUserID, v)
  213. return u
  214. }
  215. // UpdateUserID sets the "user_id" field to the value that was provided on create.
  216. func (u *UserAllowedGroupUpsert) UpdateUserID() *UserAllowedGroupUpsert {
  217. u.SetExcluded(userallowedgroup.FieldUserID)
  218. return u
  219. }
  220. // SetGroupID sets the "group_id" field.
  221. func (u *UserAllowedGroupUpsert) SetGroupID(v int64) *UserAllowedGroupUpsert {
  222. u.Set(userallowedgroup.FieldGroupID, v)
  223. return u
  224. }
  225. // UpdateGroupID sets the "group_id" field to the value that was provided on create.
  226. func (u *UserAllowedGroupUpsert) UpdateGroupID() *UserAllowedGroupUpsert {
  227. u.SetExcluded(userallowedgroup.FieldGroupID)
  228. return u
  229. }
  230. // UpdateNewValues updates the mutable fields using the new values that were set on create.
  231. // Using this option is equivalent to using:
  232. //
  233. // client.UserAllowedGroup.Create().
  234. // OnConflict(
  235. // sql.ResolveWithNewValues(),
  236. // ).
  237. // Exec(ctx)
  238. func (u *UserAllowedGroupUpsertOne) UpdateNewValues() *UserAllowedGroupUpsertOne {
  239. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  240. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  241. if _, exists := u.create.mutation.CreatedAt(); exists {
  242. s.SetIgnore(userallowedgroup.FieldCreatedAt)
  243. }
  244. }))
  245. return u
  246. }
  247. // Ignore sets each column to itself in case of conflict.
  248. // Using this option is equivalent to using:
  249. //
  250. // client.UserAllowedGroup.Create().
  251. // OnConflict(sql.ResolveWithIgnore()).
  252. // Exec(ctx)
  253. func (u *UserAllowedGroupUpsertOne) Ignore() *UserAllowedGroupUpsertOne {
  254. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  255. return u
  256. }
  257. // DoNothing configures the conflict_action to `DO NOTHING`.
  258. // Supported only by SQLite and PostgreSQL.
  259. func (u *UserAllowedGroupUpsertOne) DoNothing() *UserAllowedGroupUpsertOne {
  260. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  261. return u
  262. }
  263. // Update allows overriding fields `UPDATE` values. See the UserAllowedGroupCreate.OnConflict
  264. // documentation for more info.
  265. func (u *UserAllowedGroupUpsertOne) Update(set func(*UserAllowedGroupUpsert)) *UserAllowedGroupUpsertOne {
  266. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  267. set(&UserAllowedGroupUpsert{UpdateSet: update})
  268. }))
  269. return u
  270. }
  271. // SetUserID sets the "user_id" field.
  272. func (u *UserAllowedGroupUpsertOne) SetUserID(v int64) *UserAllowedGroupUpsertOne {
  273. return u.Update(func(s *UserAllowedGroupUpsert) {
  274. s.SetUserID(v)
  275. })
  276. }
  277. // UpdateUserID sets the "user_id" field to the value that was provided on create.
  278. func (u *UserAllowedGroupUpsertOne) UpdateUserID() *UserAllowedGroupUpsertOne {
  279. return u.Update(func(s *UserAllowedGroupUpsert) {
  280. s.UpdateUserID()
  281. })
  282. }
  283. // SetGroupID sets the "group_id" field.
  284. func (u *UserAllowedGroupUpsertOne) SetGroupID(v int64) *UserAllowedGroupUpsertOne {
  285. return u.Update(func(s *UserAllowedGroupUpsert) {
  286. s.SetGroupID(v)
  287. })
  288. }
  289. // UpdateGroupID sets the "group_id" field to the value that was provided on create.
  290. func (u *UserAllowedGroupUpsertOne) UpdateGroupID() *UserAllowedGroupUpsertOne {
  291. return u.Update(func(s *UserAllowedGroupUpsert) {
  292. s.UpdateGroupID()
  293. })
  294. }
  295. // Exec executes the query.
  296. func (u *UserAllowedGroupUpsertOne) Exec(ctx context.Context) error {
  297. if len(u.create.conflict) == 0 {
  298. return errors.New("ent: missing options for UserAllowedGroupCreate.OnConflict")
  299. }
  300. return u.create.Exec(ctx)
  301. }
  302. // ExecX is like Exec, but panics if an error occurs.
  303. func (u *UserAllowedGroupUpsertOne) ExecX(ctx context.Context) {
  304. if err := u.create.Exec(ctx); err != nil {
  305. panic(err)
  306. }
  307. }
  308. // UserAllowedGroupCreateBulk is the builder for creating many UserAllowedGroup entities in bulk.
  309. type UserAllowedGroupCreateBulk struct {
  310. config
  311. err error
  312. builders []*UserAllowedGroupCreate
  313. conflict []sql.ConflictOption
  314. }
  315. // Save creates the UserAllowedGroup entities in the database.
  316. func (_c *UserAllowedGroupCreateBulk) Save(ctx context.Context) ([]*UserAllowedGroup, error) {
  317. if _c.err != nil {
  318. return nil, _c.err
  319. }
  320. specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
  321. nodes := make([]*UserAllowedGroup, len(_c.builders))
  322. mutators := make([]Mutator, len(_c.builders))
  323. for i := range _c.builders {
  324. func(i int, root context.Context) {
  325. builder := _c.builders[i]
  326. builder.defaults()
  327. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  328. mutation, ok := m.(*UserAllowedGroupMutation)
  329. if !ok {
  330. return nil, fmt.Errorf("unexpected mutation type %T", m)
  331. }
  332. if err := builder.check(); err != nil {
  333. return nil, err
  334. }
  335. builder.mutation = mutation
  336. var err error
  337. nodes[i], specs[i] = builder.createSpec()
  338. if i < len(mutators)-1 {
  339. _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
  340. } else {
  341. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  342. spec.OnConflict = _c.conflict
  343. // Invoke the actual operation on the latest mutation in the chain.
  344. if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
  345. if sqlgraph.IsConstraintError(err) {
  346. err = &ConstraintError{msg: err.Error(), wrap: err}
  347. }
  348. }
  349. }
  350. if err != nil {
  351. return nil, err
  352. }
  353. mutation.done = true
  354. return nodes[i], nil
  355. })
  356. for i := len(builder.hooks) - 1; i >= 0; i-- {
  357. mut = builder.hooks[i](mut)
  358. }
  359. mutators[i] = mut
  360. }(i, ctx)
  361. }
  362. if len(mutators) > 0 {
  363. if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
  364. return nil, err
  365. }
  366. }
  367. return nodes, nil
  368. }
  369. // SaveX is like Save, but panics if an error occurs.
  370. func (_c *UserAllowedGroupCreateBulk) SaveX(ctx context.Context) []*UserAllowedGroup {
  371. v, err := _c.Save(ctx)
  372. if err != nil {
  373. panic(err)
  374. }
  375. return v
  376. }
  377. // Exec executes the query.
  378. func (_c *UserAllowedGroupCreateBulk) Exec(ctx context.Context) error {
  379. _, err := _c.Save(ctx)
  380. return err
  381. }
  382. // ExecX is like Exec, but panics if an error occurs.
  383. func (_c *UserAllowedGroupCreateBulk) ExecX(ctx context.Context) {
  384. if err := _c.Exec(ctx); err != nil {
  385. panic(err)
  386. }
  387. }
  388. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  389. // of the `INSERT` statement. For example:
  390. //
  391. // client.UserAllowedGroup.CreateBulk(builders...).
  392. // OnConflict(
  393. // // Update the row with the new values
  394. // // the was proposed for insertion.
  395. // sql.ResolveWithNewValues(),
  396. // ).
  397. // // Override some of the fields with custom
  398. // // update values.
  399. // Update(func(u *ent.UserAllowedGroupUpsert) {
  400. // SetUserID(v+v).
  401. // }).
  402. // Exec(ctx)
  403. func (_c *UserAllowedGroupCreateBulk) OnConflict(opts ...sql.ConflictOption) *UserAllowedGroupUpsertBulk {
  404. _c.conflict = opts
  405. return &UserAllowedGroupUpsertBulk{
  406. create: _c,
  407. }
  408. }
  409. // OnConflictColumns calls `OnConflict` and configures the columns
  410. // as conflict target. Using this option is equivalent to using:
  411. //
  412. // client.UserAllowedGroup.Create().
  413. // OnConflict(sql.ConflictColumns(columns...)).
  414. // Exec(ctx)
  415. func (_c *UserAllowedGroupCreateBulk) OnConflictColumns(columns ...string) *UserAllowedGroupUpsertBulk {
  416. _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
  417. return &UserAllowedGroupUpsertBulk{
  418. create: _c,
  419. }
  420. }
  421. // UserAllowedGroupUpsertBulk is the builder for "upsert"-ing
  422. // a bulk of UserAllowedGroup nodes.
  423. type UserAllowedGroupUpsertBulk struct {
  424. create *UserAllowedGroupCreateBulk
  425. }
  426. // UpdateNewValues updates the mutable fields using the new values that
  427. // were set on create. Using this option is equivalent to using:
  428. //
  429. // client.UserAllowedGroup.Create().
  430. // OnConflict(
  431. // sql.ResolveWithNewValues(),
  432. // ).
  433. // Exec(ctx)
  434. func (u *UserAllowedGroupUpsertBulk) UpdateNewValues() *UserAllowedGroupUpsertBulk {
  435. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  436. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  437. for _, b := range u.create.builders {
  438. if _, exists := b.mutation.CreatedAt(); exists {
  439. s.SetIgnore(userallowedgroup.FieldCreatedAt)
  440. }
  441. }
  442. }))
  443. return u
  444. }
  445. // Ignore sets each column to itself in case of conflict.
  446. // Using this option is equivalent to using:
  447. //
  448. // client.UserAllowedGroup.Create().
  449. // OnConflict(sql.ResolveWithIgnore()).
  450. // Exec(ctx)
  451. func (u *UserAllowedGroupUpsertBulk) Ignore() *UserAllowedGroupUpsertBulk {
  452. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  453. return u
  454. }
  455. // DoNothing configures the conflict_action to `DO NOTHING`.
  456. // Supported only by SQLite and PostgreSQL.
  457. func (u *UserAllowedGroupUpsertBulk) DoNothing() *UserAllowedGroupUpsertBulk {
  458. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  459. return u
  460. }
  461. // Update allows overriding fields `UPDATE` values. See the UserAllowedGroupCreateBulk.OnConflict
  462. // documentation for more info.
  463. func (u *UserAllowedGroupUpsertBulk) Update(set func(*UserAllowedGroupUpsert)) *UserAllowedGroupUpsertBulk {
  464. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  465. set(&UserAllowedGroupUpsert{UpdateSet: update})
  466. }))
  467. return u
  468. }
  469. // SetUserID sets the "user_id" field.
  470. func (u *UserAllowedGroupUpsertBulk) SetUserID(v int64) *UserAllowedGroupUpsertBulk {
  471. return u.Update(func(s *UserAllowedGroupUpsert) {
  472. s.SetUserID(v)
  473. })
  474. }
  475. // UpdateUserID sets the "user_id" field to the value that was provided on create.
  476. func (u *UserAllowedGroupUpsertBulk) UpdateUserID() *UserAllowedGroupUpsertBulk {
  477. return u.Update(func(s *UserAllowedGroupUpsert) {
  478. s.UpdateUserID()
  479. })
  480. }
  481. // SetGroupID sets the "group_id" field.
  482. func (u *UserAllowedGroupUpsertBulk) SetGroupID(v int64) *UserAllowedGroupUpsertBulk {
  483. return u.Update(func(s *UserAllowedGroupUpsert) {
  484. s.SetGroupID(v)
  485. })
  486. }
  487. // UpdateGroupID sets the "group_id" field to the value that was provided on create.
  488. func (u *UserAllowedGroupUpsertBulk) UpdateGroupID() *UserAllowedGroupUpsertBulk {
  489. return u.Update(func(s *UserAllowedGroupUpsert) {
  490. s.UpdateGroupID()
  491. })
  492. }
  493. // Exec executes the query.
  494. func (u *UserAllowedGroupUpsertBulk) Exec(ctx context.Context) error {
  495. if u.create.err != nil {
  496. return u.create.err
  497. }
  498. for i, b := range u.create.builders {
  499. if len(b.conflict) != 0 {
  500. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the UserAllowedGroupCreateBulk instead", i)
  501. }
  502. }
  503. if len(u.create.conflict) == 0 {
  504. return errors.New("ent: missing options for UserAllowedGroupCreateBulk.OnConflict")
  505. }
  506. return u.create.Exec(ctx)
  507. }
  508. // ExecX is like Exec, but panics if an error occurs.
  509. func (u *UserAllowedGroupUpsertBulk) ExecX(ctx context.Context) {
  510. if err := u.create.Exec(ctx); err != nil {
  511. panic(err)
  512. }
  513. }