go-reform/reform

InsertMulti() does not update primary key field

mikestefanello opened this issue · 1 comments

Is your feature request related to a problem? Please describe.
When bulk-inserting via Querier.InsertMulti the primary key field on the structs are not updated with the key it was assigned after inserting. This seems on purpose since a comment on the method notes this behavior. This makes it difficult to use, especially if you plan to assign those IDs to foreign-key fields of another set of structs to bulk-insert. I'm open to attempting to add this functionality, but wanted to first see if there's a specific reason why this was excluded or cannot be done.

Describe the solution you'd like
The structs have their primary key field populated after bulk-inserting.

Describe alternatives you've considered
None yet.

wanted to first see if there's a specific reason why this was excluded or cannot be done

That's because I don't know how to implement that functionality with databases and drivers that use LastInsertId() (like MySQL) and don't want to implement only for some databases/drivers (like PostgreSQL), but not others.