#33649: bulk_create() with ignore_conflicts=True and ForeignKey fails
-------------------------------------+-------------------------------------
Reporter: Markus Friedrich | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: bulk_create | Triage Stage:
ForeignKey ignore_conflicts | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Mariusz Felisiak):
> So the error is wrong in this case.
Rows are saved in the database, but object instances don't have primary
keys, so they are not associated with saved rows. Again, you can fix this
by re-fetching new objects from the database before assigning them to a
related model.
> And in my view at least for lower level functions like bulk_create
(which are for performance tuning) no error should be raised if its
unclear for Django if there is really an error. Its up to the caller to
ensure that things are right, at least for lower level functions.
I don't agree, `bulk_create()` and `bulk_update()` are supported and
documented APIs. I see no reason to leave users on their own in this
particular case.
You can start a discussion on DevelopersMailingList if you don't agree,
where you'll reach a wider audience and see what other think. Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/33649#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701803fff6111-44f7087f-52f7-4205-afc9-421de5d77e04-000000%40eu-central-1.amazonses.com.