#34491: Unable to have constraints with same name on different models
------------------------------------------------+------------------------
Reporter: Matheus Cansian | Owner: nobody
Type: Bug | Status: new
Component: Core (System checks) | Version: 4.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
PR 11278 (ticket #30396) added system checks to enforce uniqueness of
indexes and constraints names. The issue is that (at least for PostgreSQL)
the check is too strict. The namespace for table constraints (such as
CHECK, UNIQUE, FK) is the table itself. This means that you could have the
same name for a constraint if they are on different tables. Unfortunately,
this system check prevents you for doing that, forcing you to add the
unnecessary ''%(app_label)s_%(class)s'' to every constraint name.
Considering two models (ModelA and ModelB) both with one CheckConstraint
with the same name "test_constraint". The system check would return the
following error:
{{{
?: (models.E032) constraint name 'test_constraint' is not unique among
models: app.ModelA, app.ModelB.
}}}
https://github.com/django/django/pull/11278
--
Ticket URL: <https://code.djangoproject.com/ticket/34491>
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/010701877c999441-1db5f0c8-8841-49e5-8427-c2c7f9fd6117-000000%40eu-central-1.amazonses.com.