django-partial-index
django-partial-index copied to clipboard
validate_partial_unique does not check inherited indexes
If you use multi-table inheritance then validate_partial_unique()
doesn't work if Meta
is overridden by the child; any uniqueness constraints on the parent model will be ignored even though they are present in the database.
https://github.com/mattiaslinnap/django-partial-index/blob/a5ddf7a4db9391ec55096fd98e87f4d5b3d6360e/partial_index/mixins.py#L58
For reference:
Django's validate_unique()
traverses the MRO and appends parent indexes to the list of unique indexes to check.
In 2.2 (when django added native support for partial indexes), validate_unique()
didn't change, but _get_unique_checks
gives up entirely on trying to validate the constraints ("Partial unique constraints can't be validated")
In other words, there's no forward compatibility to be aware of, but traversing the Meta classes in the MRO is consistent with existing django behaviour for non-partial uniqueness.