Opened 5 months ago
Last modified 5 months ago
#35551 closed Bug
Unique checks skipped when changing primary key — at Version 1
Reported by: | Csirmaz Bendegúz | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I noticed the unique checks are skipped (_perform_unique_checks
) when an object's primary key is changed.
Given:
# models.py class Dummy(models.Model): id = models.IntegerField(primary_key=True) # admin.py admin.site.register(Dummy)
- Create Dummy (1), Dummy (2).
- Change Dummy (2)'s Id field -> 1
- No error, unique checks skipped
- Change Dummy (1)'s Id field -> 3
- A new Dummy (1) is created (why?)
I believe step 5 should never happen, since step 3 should fail with a unique check error.
Note:
See TracTickets
for help on using tickets.