-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Cannot use bulk_create to create multiple entities with a foreign key relationship #2162
Comments
Peewee introduced an efficiency measure in |
Fixed. Note that this would only have worked with postgres, thanks to postgres' ability to return autogenerated IDs after a bulk insert query. So this is kinda under "yeah, it works, but it's a little weird" category. At any rate it should be working again on master. I've added a regression test which reproduced the issue and now passes. |
Thanks for the quick turnaround! I tried it out in the example I put together and everything seems to be working. |
Sorry to bother you. I am using mysql and what should I do to fix the same problem? Any clues? |
While making some changes to our ETL pipeline, my team and I noticed that some new errors have appeared. It looks like there was an issue that was introduced in version. 3.13.3. It's also possible we were relying on some undocumented behavior.
What we're trying to do is instantiate a set of entities before writing them to the database in a single transaction with the
bulk_create
method. One set of these entities has a foreign key to entities in the second set. On version 3.13.1, we don't see any errors thrown in our code. But on version 3.13.3, there is an error.Here's a snippet of the example I put together reproducing the issue. You can find the full example here.
On 3.13.1, this works without an error. On 3.13.3, I get the following error:
Could someone help investigate this error? Our project will be stuck on 3.13.1 until we can find a fix.
The text was updated successfully, but these errors were encountered: