[Django] #32321: Add system checks for invalid model field names for functional indexes in Meta.indexes.

21 views
Skip to first unread message

Django

unread,
Jan 5, 2021, 1:49:06 AM1/5/21
to django-...@googlegroups.com
#32321: Add system checks for invalid model field names for functional indexes in
Meta.indexes.
-------------------------------------+-------------------------------------
Reporter: Mariusz | Owner: nobody
Felisiak |
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: 3.1
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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()`.

I attached tests.

--
Ticket URL: <https://code.djangoproject.com/ticket/32321>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 5, 2021, 1:50:00 AM1/5/21
to django-...@googlegroups.com
#32321: Add system checks for invalid model field names for functional indexes in
Meta.indexes.
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: 3.1
(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
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* Attachment "tests_32321.diff" added.

Tests.

Django

unread,
Jan 5, 2021, 4:13:10 PM1/5/21
to django-...@googlegroups.com
#32321: Add system checks for invalid model field names for functional indexes in
Meta.indexes.
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: Database layer | Version: 3.1
(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 Hasan Ramezani):

Mariusz,
When I try to run the
[https://code.djangoproject.com/timeline?from=2021-01-05T00%3A49%3A56-06%3A00&precision=second
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`?

--
Ticket URL: <https://code.djangoproject.com/ticket/32321#comment:1>

Django

unread,
Jan 6, 2021, 1:26:14 AM1/6/21
to django-...@googlegroups.com
#32321: Add system checks for invalid model field names for functional indexes in
Meta.indexes.
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Someday/Maybe

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Someday/Maybe


Old description:

> 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()`.
>
> I attached tests.

New description:

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.

--

Comment:

Sorry Hasan, I should mark this ticket as "someday", it's a follow up to
#26167. It will be valid after merging
[https://github.com/django/django/pull/11929 PR].

--
Ticket URL: <https://code.djangoproject.com/ticket/32321#comment:2>

Django

unread,
Jan 13, 2021, 2:46:18 PM1/13/21
to django-...@googlegroups.com
#32321: Add system checks for invalid model field names for functional indexes in
Meta.indexes.
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: Database layer | Version: 3.1
(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
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* stage: Someday/Maybe => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/32321#comment:3>

Django

unread,
Jan 13, 2021, 3:05:49 PM1/13/21
to django-...@googlegroups.com
#32321: Add system checks for invalid model field names for functional indexes in
Meta.indexes.
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: Hasan
Type: | Ramezani
Cleanup/optimization | Status: assigned

Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* owner: nobody => Hasan Ramezani
* status: new => assigned
* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/13886 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/32321#comment:4>

Django

unread,
Jan 14, 2021, 6:47:36 AM1/14/21
to django-...@googlegroups.com
#32321: Add system checks for invalid model field names for functional indexes in
Meta.indexes.
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: Hasan
Type: | Ramezani
Cleanup/optimization | Status: closed

Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"f75037731800b7206759768dcdf2fed9e3e3d4ab" f750377]:
{{{
#!CommitTicketReference repository=""
revision="f75037731800b7206759768dcdf2fed9e3e3d4ab"
Fixed #32321 -- Added system checks for invalid model field names in
functional indexes.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32321#comment:5>

Reply all
Reply to author
Forward
0 new messages