all: replace save with exec when the model is not needed

This commit is contained in:
Ariel Mashraki
2021-09-01 22:07:48 +03:00
committed by Ariel Mashraki
parent 7015647528
commit f0d985f542
8 changed files with 51 additions and 54 deletions

View File

@@ -47,14 +47,13 @@ func Do(ctx context.Context, client *ent.Client) error {
SetName("ST").
SetCity(tlv).
SaveX(ctx)
// This operation will fail because "ST"
// is already created under "TLV".
_, err := client.Street.
// This operation fails because "ST"
// was already created under "TLV".
if err := client.Street.
Create().
SetName("ST").
SetCity(tlv).
Save(ctx)
if err == nil {
Exec(ctx); err == nil {
return fmt.Errorf("expecting creation to fail")
}
// Add a street "ST" to "NYC".