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

@@ -129,8 +129,10 @@ func ({{ $receiver }} *{{ $builder }}) Save(ctx context.Context) ([]*{{ $.Name }
mutators[i] = mut
}(i, ctx)
}
if _, err := mutators[0].Mutate(ctx, {{ $receiver }}.builders[0].mutation); err != nil {
return nil, err
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, {{ $receiver }}.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
@@ -143,4 +145,4 @@ func ({{ $receiver }} *{{ $builder }}) SaveX(ctx context.Context) []*{{ $.Name }
}
return v
}
{{ end }}
{{ end }}