Opened 4 years ago
Closed 4 years ago
#32321 closed Cleanup/optimization (fixed)
Add system checks for invalid model field names for functional indexes in Meta.indexes.
Reported by: | Mariusz Felisiak | Owned by: | Hasan Ramezani |
---|---|---|---|
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.
Attachments (1)
Change History (6)
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 |
comment:3 by , 4 years ago
Triage Stage: | Someday/Maybe → Accepted |
---|
Tests.