[Django] #36660: False-positive E012 check error when index contains descending order field

11 views
Skip to first unread message

Django

unread,
Oct 12, 2025, 11:08:18 AM10/12/25
to django-...@googlegroups.com
#36660: False-positive E012 check error when index contains descending order field
-------------------------------------+-------------------------------------
Reporter: Federico Bond | Type: Bug
Status: new | Component: Database
| layer (models, ORM)
Version: 6.0 | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
When a model has an index defined like this:

{{{
class Meta:
indexes = [models.Index(fields=["foo", "-bar"])]
}}}

The system check framework in 6.0a1 will now report the following error:


{{{
foo.FooModel: (models.E012) 'indexes' refers to the nonexistent field
'-bar'.
}}}

Tested with Django 6.0a1. This was not happening in 5.2. Might have
something to do with these
[https://github.com/django/django/commit/8638d8bf74c1a58302c97d4436ad2eb08438145b
changes] but I'm not sure.
--
Ticket URL: <https://code.djangoproject.com/ticket/36660>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 12, 2025, 12:57:34 PM10/12/25
to django-...@googlegroups.com
#36660: False-positive E012 check error when index contains descending order field
-------------------------------------+-------------------------------------
Reporter: Federico Bond | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 6.0
(models, ORM) |
Severity: Release blocker | 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 Simon Charette):

* owner: (none) => Simon Charette
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
* status: new => assigned

Comment:

Thank you for the report!

Confirmed to be a regression caused by
8638d8bf74c1a58302c97d4436ad2eb08438145b's (#36273) lack of
`fields_orders` usage ([https://github.com/django/django/pull/19395/files
#diff-
1c8b882c73bfda668d5451d4578c97191b0ebc0f088d0c0ba2296ab89b428c44L2199
before] and [https://github.com/django/django/pull/19395/files#diff-
0b5bafe2c73718e1b80cd140411dfa403e1b04880ddfba4a7065b9eac5f740c9R117
after]) when calling `_check_local_fields`.
--
Ticket URL: <https://code.djangoproject.com/ticket/36660#comment:1>

Django

unread,
Oct 12, 2025, 1:02:10 PM10/12/25
to django-...@googlegroups.com
#36660: False-positive E012 check error when index contains descending order field
-------------------------------------+-------------------------------------
Reporter: Federico Bond | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 6.0
(models, ORM) |
Severity: Release blocker | 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 Simon Charette):

* has_patch: 0 => 1

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

Django

unread,
Oct 12, 2025, 8:21:11 PM10/12/25
to django-...@googlegroups.com
#36660: False-positive E012 check error when index contains descending order field
-------------------------------------+-------------------------------------
Reporter: Federico Bond | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 6.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Accepted => Ready for checkin

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

Django

unread,
Oct 13, 2025, 9:42:35 AM10/13/25
to django-...@googlegroups.com
#36660: False-positive E012 check error when index contains descending order field
-------------------------------------+-------------------------------------
Reporter: Federico Bond | Owner: Simon
| Charette
Type: Bug | Status: closed
Component: Database layer | Version: 6.0
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by nessita <124304+nessita@…>):

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

Comment:

In [changeset:"edde2891c355103ba455f3fea95cff962e40962c" edde2891]:
{{{#!CommitTicketReference repository=""
revision="edde2891c355103ba455f3fea95cff962e40962c"
Fixed #36660 -- Fixed a regression in descending Index local field checks.

Regression in 8638d8bf74c1a58302c97d4436ad2eb08438145b.

Refs #36273.

Thanks Federico Bond for the report.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36660#comment:4>

Django

unread,
Oct 13, 2025, 9:51:44 AM10/13/25
to django-...@googlegroups.com
#36660: False-positive E012 check error when index contains descending order field
-------------------------------------+-------------------------------------
Reporter: Federico Bond | Owner: Simon
| Charette
Type: Bug | Status: closed
Component: Database layer | Version: 6.0
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Natalia <124304+nessita@…>):

In [changeset:"86e7406cfb839a6c5384e9f72a55ef78eccc9a3c" 86e7406c]:
{{{#!CommitTicketReference repository=""
revision="86e7406cfb839a6c5384e9f72a55ef78eccc9a3c"
[6.0.x] Fixed #36660 -- Fixed a regression in descending Index local field
checks.

Regression in 8638d8bf74c1a58302c97d4436ad2eb08438145b.

Refs #36273.

Thanks Federico Bond for the report.

Backport of edde2891c355103ba455f3fea95cff962e40962c from main.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36660#comment:5>
Reply all
Reply to author
Forward
0 new messages