Opened 4 years ago
Last modified 4 years ago
#32321 closed Cleanup/optimization
Add system checks for invalid model field names for functional indexes in Meta.indexes. — at Version 2
Reported by: | Mariusz Felisiak | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 3.1 |
Severity: | Normal | Keywords: | |
Cc: | Hannes Ljungberg | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
The current system checks don't cover invalid models fields in functional indexes. This is not straightforward because resolving expressions with non-existent throws FieldError
, so we cannot just collect columns from Query._gen_cols()
.
Follow up to #26167.
I attached tests.
Change History (3)
by , 4 years ago
Attachment: | tests_32321.diff added |
---|
comment:1 by , 4 years ago
Mariusz,
When I try to run the tests that you added to the ticket, I get
ValueError('Index.fields must be a list or tuple.')
it means currently, models.Index
doesn't support models.F('height') / (models.F('weight__abs') + models.Value(5))
and Lower('missing_field').desc()
as index fields
.
Should we add support for these kinds of fields to models.Index
?
comment:2 by , 4 years ago
Description: | modified (diff) |
---|---|
Triage Stage: | Accepted → Someday/Maybe |
Tests.