entc/gen: add support for upsert/on-conflict feature-flag

This commit is contained in:
Ariel Mashraki
2021-08-02 19:19:46 +03:00
committed by Ariel Mashraki
parent a5c931ed13
commit 09c4306378
95 changed files with 9556 additions and 279 deletions

View File

@@ -203,8 +203,9 @@ func (ccb *CityCreateBulk) Save(ctx context.Context) ([]*City, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ccb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, ccb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, ccb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -215,8 +216,10 @@ func (ccb *CityCreateBulk) Save(ctx context.Context) ([]*City, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -208,8 +208,9 @@ func (scb *StreetCreateBulk) Save(ctx context.Context) ([]*Street, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, scb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, scb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, scb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -220,8 +221,10 @@ func (scb *StreetCreateBulk) Save(ctx context.Context) ([]*Street, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -194,8 +194,9 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -206,8 +207,10 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -276,8 +276,9 @@ func (fcb *FileCreateBulk) Save(ctx context.Context) ([]*File, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, fcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, fcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, fcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -288,8 +289,10 @@ func (fcb *FileCreateBulk) Save(ctx context.Context) ([]*File, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -203,8 +203,9 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, gcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, gcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, gcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -215,8 +216,10 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -220,8 +220,9 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -232,8 +233,10 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -219,8 +219,9 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -231,8 +232,10 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -253,8 +253,9 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -265,8 +266,10 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -208,8 +208,9 @@ func (pcb *PetCreateBulk) Save(ctx context.Context) ([]*Pet, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, pcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, pcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, pcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -220,8 +221,10 @@ func (pcb *PetCreateBulk) Save(ctx context.Context) ([]*Pet, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -220,8 +220,9 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -232,8 +233,10 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -241,8 +241,9 @@ func (ncb *NodeCreateBulk) Save(ctx context.Context) ([]*Node, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ncb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, ncb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, ncb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -253,8 +254,10 @@ func (ncb *NodeCreateBulk) Save(ctx context.Context) ([]*Node, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -221,8 +221,9 @@ func (ccb *CardCreateBulk) Save(ctx context.Context) ([]*Card, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ccb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, ccb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, ccb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -233,8 +234,10 @@ func (ccb *CardCreateBulk) Save(ctx context.Context) ([]*Card, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -224,8 +224,9 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -236,8 +237,10 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -224,8 +224,9 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -236,8 +237,10 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -245,8 +245,9 @@ func (ncb *NodeCreateBulk) Save(ctx context.Context) ([]*Node, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ncb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, ncb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, ncb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -257,8 +258,10 @@ func (ncb *NodeCreateBulk) Save(ctx context.Context) ([]*Node, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -189,8 +189,9 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -201,8 +202,10 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -259,8 +259,9 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, gcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, gcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, gcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -271,8 +272,10 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -173,8 +173,9 @@ func (tcb *TenantCreateBulk) Save(ctx context.Context) ([]*Tenant, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, tcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, tcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, tcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -185,8 +186,10 @@ func (tcb *TenantCreateBulk) Save(ctx context.Context) ([]*Tenant, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -273,8 +273,9 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -285,8 +286,10 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -226,8 +226,9 @@ func (ccb *CarCreateBulk) Save(ctx context.Context) ([]*Car, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ccb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, ccb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, ccb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -238,8 +239,10 @@ func (ccb *CarCreateBulk) Save(ctx context.Context) ([]*Car, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -208,8 +208,9 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, gcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, gcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, gcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -220,8 +221,10 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -278,8 +278,9 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -290,8 +291,10 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -242,8 +242,9 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, gcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, gcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, gcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -254,8 +255,10 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -242,8 +242,9 @@ func (pcb *PetCreateBulk) Save(ctx context.Context) ([]*Pet, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, pcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, pcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, pcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -254,8 +255,10 @@ func (pcb *PetCreateBulk) Save(ctx context.Context) ([]*Pet, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -323,8 +323,9 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -335,8 +336,10 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -208,8 +208,9 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
}
@@ -220,8 +221,10 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
}
mutation.id = &nodes[i].ID
mutation.done = true
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {