#35551: Unique checks skipped when changing primary key
----------------------------------+--------------------------------------
Reporter: Csirmaz Bendegúz | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
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?)
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 (why?)
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:1>
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/010701904060c792-5897c552-12c0-42c1-a04a-4304f8382a18-000000%40eu-central-1.amazonses.com.