entc/gen: update mutation-id on post mutation

This commit is contained in:
Ariel Mashraki
2021-05-31 20:18:55 +03:00
committed by Ariel Mashraki
parent ca7aa4b742
commit 11567a3926
131 changed files with 408 additions and 202 deletions

View File

@@ -83,6 +83,7 @@ func (cc *CarCreate) Save(ctx context.Context) (*Car, error) {
}
cc.mutation = mutation
node, err = cc.sqlSave(ctx)
mutation.id = &node.ID
mutation.done = true
return node, err
})
@@ -214,6 +215,7 @@ func (ccb *CarCreateBulk) Save(ctx context.Context) ([]*Car, error) {
}
}
}
mutation.id = &nodes[i].ID
mutation.done = true
if err != nil {
return nil, err

View File

@@ -72,6 +72,7 @@ func (gc *GroupCreate) Save(ctx context.Context) (*Group, error) {
}
gc.mutation = mutation
node, err = gc.sqlSave(ctx)
mutation.id = &node.ID
mutation.done = true
return node, err
})
@@ -196,6 +197,7 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) {
}
}
}
mutation.id = &nodes[i].ID
mutation.done = true
if err != nil {
return nil, err

View File

@@ -120,8 +120,8 @@ func (m CarMutation) Tx() (*Tx, error) {
return tx, nil
}
// ID returns the ID value in the mutation. Note that the ID
// is only available if it was provided to the builder.
// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *CarMutation) ID() (id int, exists bool) {
if m.id == nil {
return
@@ -530,8 +530,8 @@ func (m GroupMutation) Tx() (*Tx, error) {
return tx, nil
}
// ID returns the ID value in the mutation. Note that the ID
// is only available if it was provided to the builder.
// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *GroupMutation) ID() (id int, exists bool) {
if m.id == nil {
return
@@ -914,8 +914,8 @@ func (m UserMutation) Tx() (*Tx, error) {
return tx, nil
}
// ID returns the ID value in the mutation. Note that the ID
// is only available if it was provided to the builder.
// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *UserMutation) ID() (id int, exists bool) {
if m.id == nil {
return

View File

@@ -103,6 +103,7 @@ func (uc *UserCreate) Save(ctx context.Context) (*User, error) {
}
uc.mutation = mutation
node, err = uc.sqlSave(ctx)
mutation.id = &node.ID
mutation.done = true
return node, err
})
@@ -266,6 +267,7 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
}
}
}
mutation.id = &nodes[i].ID
mutation.done = true
if err != nil {
return nil, err