#33414: Diamond inheritance causes duplicated PK error when creating an object,
if
the primary key field has a default.
-------------------------------------+-------------------------------------
Reporter: Yu Li | Owner: Yu Li
Type: Bug | Status: assigned
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):
* cc: Simon Charette (added)
* stage: Unreviewed => Accepted
Comment:
Thanks for the report. I was able to reproduce this issue.
> This assumption looks weird to me: why only when there IS a default pk
you can skip update?
This is an optimization to skip `UPDATE` when inherited primary key has a
default (see babd4126853e48594b61e8db71a83d7bdd929b9c and #29129).
> Why not just skip update as long as we know we are inserting? (via
self._state.adding)
As far as I'm aware, this would be contrary to the currently
[https://docs.djangoproject.com/en/4.0/ref/models/instances/#how-django-
knows-to-update-vs-insert documented] process.
> I think the solution is to simply move the check to save_base. And don't
do this check in _save_parents.
This breaks optimization added in
babd4126853e48594b61e8db71a83d7bdd929b9c, see
`basic.tests.ModelInstanceCreationTests.test_save_parent_primary_with_default`.
> Is this project completely community supported?
Yes.
> Is there a project lead I can discuss with to confirm my suspicion?
Thank you.
No, we don't have a project lead. You can join the DevelopersMailingList
and share your ideas. You can also interact on the
[https://forum.djangoproject.com/ Django forum] and the #django-dev IRC
channel.
--
Ticket URL: <https://code.djangoproject.com/ticket/33414#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/066.726d0c1562501f4fddf77d8beb53c31f%40djangoproject.com.