#31351: Need warning when UniqueConstraint with condition is used but
supports_partial_indexes is False
-------------------------------------+-------------------------------------
Reporter: Matthijs Kooijman | Owner: Ichlasul
Type: | Affan
Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Ichlasul Affan):
Replying to [ticket:31351 Matthijs Kooijman]:
> Databases that support supports_partial_indexes allow using a
`UniqueConstraint` with a `condition` specified (implemented in #29547 and
#30062). However, when such constraints are specified, but the database
(e.g. Mysql/Mariadb or older versions of sqlite) does not support partial
indexes, these constraints are silently ignored.
>
> It would be better if this would give a warning, similar to the warning
for `CheckConstraints` at
https://github.com/django/django/blob/9358da704ea9ba55f22df912e47b54eb85d5c97e/django/db/models/base.py#L1838-L1862
>
> I have observed this with 2.2.10, but looking at the code, this has not
changed since then, so I'm setting version to master.
>
> This is probably a fairly trivial change, but I'm not in the opportunity
to provide a PR in the near future.
Firstly, I'm sorry I am new contributor to Django. When I explored further
on the code, the warning checks for specific DBMS' ability to check
constraints using `connection.features.support_table_check_constraints`.
Unfortunately, I think that similiar type of variable would be available
on some database connectors for this case (unique constraint with
conditions). Would you mind if I just add the warning regardless of what
kind of database users will use?
--
Ticket URL: <https://code.djangoproject.com/ticket/31351#comment:2>
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/074.ddc7199a1e7fe5c6bb7118d66f7df4dc%40djangoproject.com.