mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
all: replace save with exec when the model is not needed
This commit is contained in:
committed by
Ariel Mashraki
parent
7015647528
commit
f0d985f542
@@ -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".
|
||||
|
||||
Reference in New Issue
Block a user