#34949: Fails to create unique constraints
-------------------------------------+-------------------------------------
Reporter: Roman Odaisky | Owner: Jordan
| Bae
Type: Bug | Status: assigned
Component: Database layer | Version: dev
(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
-------------------------------------+-------------------------------------
Comment (by Roman Odaisky):
Perhaps the easiest way of implementing this would be something along the
lines of
{{{
class Meta:
constraints = [
models.UniqueConstraint(fields=["e"], include=["f"],
if_has_features=["supports_covering_indexes"]),
models.UniqueConstraint(fields=["e"],
unless_has_features=["supports_covering_indexes"]),
]
indexes = [
models.Index(fields=["e", "f"],
unless_has_features=["supports_covering_indexes"]),
]
}}}
The only question that would remain would be, what if the DB gains support
for a feature it previously lacked.
--
Ticket URL: <https://code.djangoproject.com/ticket/34949#comment:6>
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/0107018ce994212b-f768c6df-fc02-42f2-9875-ee26d75c3140-000000%40eu-central-1.amazonses.com.