#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):
> This means with this error message you have intentionally completely
removed the functionality to use bulk_create together with a ForeignKey on
all databases which are not able to set the pk in bulk_create!
Why? This error message is only raised when a related object **is not
saved**. The current behavior of `bulk_create()` and `bulk_update()`
reflects the `save()` behavior.
> If this is really intended I'm OK with it and need to workaround this.
(even thought I do not understand why there should be a data-loss problem
in this case (with a uuid as to_field of the ForeignKey))
As far as I'm aware there is still a data loss possibility 🤔, because the
assigned UUID may not exists in the database at the end. We cannot
guarantee that the assigned UUID will be stored in the database as it
comes from an unsaved object.
> (I also do not understand your last sentence: I do not have any already
saved reporter in my test case (but in my real case). But as detected now
it even fails without the ignore_conflicts, see above)
My advise is to save `reporter` instances before attaching them to an
`article`.
--
Ticket URL: <https://code.djangoproject.com/ticket/33649#comment:3>
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/010701803cca0c73-1bacf381-47a8-47a1-b26e-bd75cee6807b-000000%40eu-central-1.amazonses.com.