Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InsertMulti() does not update primary key field #327

Open
mikestefanello opened this issue Feb 25, 2022 · 1 comment
Open

InsertMulti() does not update primary key field #327

mikestefanello opened this issue Feb 25, 2022 · 1 comment

Comments

@mikestefanello
Copy link

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.

@AlekSi
Copy link
Member

AlekSi commented Feb 26, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants