entc/gen: ignore query execution on empty batch (#648)

This commit is contained in:
Ariel Mashraki
2020-07-29 18:07:14 +03:00
committed by GitHub
parent d42a5581b9
commit f677112e18
55 changed files with 219 additions and 111 deletions

View File

@@ -205,8 +205,10 @@ func (pcb *PetCreateBulk) Save(ctx context.Context) ([]*Pet, error) {
mutators[i] = mut
}(i, ctx)
}
if _, err := mutators[0].Mutate(ctx, pcb.builders[0].mutation); err != nil {
return nil, err
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, pcb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}

View File

@@ -218,8 +218,10 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
mutators[i] = mut
}(i, ctx)
}
if _, err := mutators[0].Mutate(ctx, ucb.builders[0].mutation); err != nil {
return nil, err
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, ucb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}