dialect/sql/sqlgraph: skip setting last-insert-id if was provided (#1291)

Fixed #1290. Issue in BulkCreate(<T>) for m2m edges
This commit is contained in:
Ariel Mashraki
2021-03-02 11:59:20 +02:00
committed by GitHub
parent 73df26b92b
commit 8a8bfe7de6
2 changed files with 10 additions and 3 deletions

View File

@@ -964,7 +964,10 @@ func (c *creator) batchInsert(ctx context.Context, tx dialect.ExecQuerier, inser
return err
}
for i, node := range c.Nodes {
node.ID.Value = ids[i]
// ID field was provided by the user.
if node.ID.Value == nil {
node.ID.Value = ids[i]
}
}
return nil
}