#35551: Unique checks skipped when changing primary key
-------------------------------------+-------------------------------------
Reporter: Csirmaz Bendegúz | Owner: Csirmaz
| Bendegúz
Type: Bug | Status: assigned
Component: contrib.admin | Version: dev
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
-------------------------------------+-------------------------------------
Description changed by Csirmaz Bendegúz:
Old description:
> 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)
> }}}
>
> 1. Create Dummy (1), Dummy (2).
> 2. Change Dummy (2)'s Id field -> 1
> 3. No error, unique checks skipped
> 4. Change Dummy (1)'s Id field -> 3
> 5. A new Dummy (1) is created (why?)
>
> I believe step 5 should never happen, since step 3 should fail with a
> unique check error.
New description:
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)
}}}
1. Create Dummy (1), Dummy (2).
2. Change Dummy (2)'s Id field -> 1
3. No error, unique checks skipped
4. Change Dummy (1)'s Id field -> 3
5. A new Dummy (1) is created (1 and 3 are duplicates)
I believe step 5 should never happen, since step 3 should fail with a
unique check error.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/35551#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/010701904ac0b9e0-c8905bd6-e64a-4b76-b9ed-43ab0f0ec9e4-000000%40eu-central-1.amazonses.com.