[Django] #30988: Deprecate the barely documented InvalidQuery exception.

9 views
Skip to first unread message

Django

unread,
Nov 15, 2019, 4:19:51 PM11/15/19
to django-...@googlegroups.com
#30988: Deprecate the barely documented InvalidQuery exception.
-------------------------------------+-------------------------------------
Reporter: Simon | Owner: nobody
Charette |
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
The `django.db.models.query.InvalidQuery` exception is
[https://docs.djangoproject.com/en/2.2/topics/db/sql/#deferring-model-
fields only mentioned once by name in the documentation] without reference
to its defining module.

It's used for the documented `QuerySet.raw` usage and
[https://github.com/django/django/blob/4527d5db0f0a939439b9373f7a9a4eee3386afff/django/db/models/query_utils.py#L23
abused] for
[https://github.com/django/django/blob/4527d5db0f0a939439b9373f7a9a4eee3386afff/django/db/models/query_utils.py#L221-L254
field deferring select related misuse].

I suggest we replace the documented usage by raising `FieldDoesNotExist`
instead and the latter undocumented abuse by raising `FieldError` while
providing a deprecation shim to warn on usages of `except InvalidQuery`.

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

Django

unread,
Nov 18, 2019, 1:53:00 AM11/18/19
to django-...@googlegroups.com
#30988: Deprecate the barely documented InvalidQuery exception.
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
Type: | Charette
Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(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 felixxm):

* owner: nobody => Simon Charette
* status: new => assigned
* has_patch: 0 => 1
* stage: Unreviewed => Accepted


Comment:

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

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

Django

unread,
Nov 18, 2019, 8:57:58 AM11/18/19
to django-...@googlegroups.com
#30988: Deprecate the barely documented InvalidQuery exception.
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
Type: | Charette
Cleanup/optimization | Status: closed

Component: Database layer | Version: master
(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:"11e327a3ff84e16ceace13ea6ec408a93ca9e72c" 11e327a3]:
{{{
#!CommitTicketReference repository=""
revision="11e327a3ff84e16ceace13ea6ec408a93ca9e72c"
Fixed #30988 -- Deprecated the InvalidQuery exception.

It was barely documented without pointers at its defining location and
was abused to prevent misuse of the QuerySet field deferring feature.
}}}

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

Django

unread,
Jan 14, 2021, 2:12:19 PM1/14/21
to django-...@googlegroups.com
#30988: Deprecate the barely documented InvalidQuery exception.
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
Type: | Charette
Cleanup/optimization | Status: closed
Component: Database layer | Version: master
(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
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"68e3ca13d771a8f08a8d1c272308cd44b4dcfa76" 68e3ca13]:
{{{
#!CommitTicketReference repository=""
revision="68e3ca13d771a8f08a8d1c272308cd44b4dcfa76"
Refs #30988 -- Removed InvalidQuery exception per deprecation timeline.
}}}

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

Reply all
Reply to author
Forward
0 new messages