[Django] #29118: Uncertainty in proper signature for resolve_expression method

9 views
Skip to first unread message

Django

unread,
Feb 6, 2018, 10:15:34 PM2/6/18
to django-...@googlegroups.com
#29118: Uncertainty in proper signature for resolve_expression method
-------------------------------------+-------------------------------------
Reporter: Raphael | Owner: nobody
Gaschignard |
Type: Bug | Status: new
Component: Database | Version: 2.0
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 |
-------------------------------------+-------------------------------------
In {{{BaseExpression}}} we have the following:


{{{
def resolve_expression(self, query=None, allow_joins=True, reuse=None,
summarize=False, for_save=False):
...
}}}

Here we have a couple default arguments. A decent number of callsites for
this method only provide positional arguments. The {{{Exists}}} subclass
assumes keyword-only arguments:

{{{
def resolve_expression(self, query=None, **kwargs):
# As a performance optimization, remove ordering since EXISTS
doesn't
# care about it, just whether or not a row matches.
self.queryset = self.queryset.order_by()
return super(Exists, self).resolve_expression(query, **kwargs)
}}}

I've submitted a patch ([https://github.com/django/django/pull/9671]) that
adds support for positional arguments for {{{Exists.resolve_expression}}},
but perhaps the intention was for the base method to be keyword-only.

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

Django

unread,
Feb 10, 2018, 6:23:06 PM2/10/18
to django-...@googlegroups.com
#29118: QuerySet.order_by(Exists(...)) crashes
-------------------------------------+-------------------------------------
Reporter: Raphael Gaschignard | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 2.0
(models, ORM) |
Severity: Normal | 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):

* has_patch: 0 => 1
* stage: Unreviewed => Ready for checkin


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

Django

unread,
Feb 10, 2018, 7:00:33 PM2/10/18
to django-...@googlegroups.com
#29118: QuerySet.order_by(Exists(...)) crashes
-------------------------------------+-------------------------------------
Reporter: Raphael Gaschignard | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 2.0
(models, ORM) |
Severity: Normal | 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 Tim Graham <timograham@…>):

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


Comment:

In [changeset:"bf26f66029bca94b007a2452679ac004598364a6" bf26f66]:
{{{
#!CommitTicketReference repository=""
revision="bf26f66029bca94b007a2452679ac004598364a6"
Fixed #29118 -- Fixed crash with QuerySet.order_by(Exists(...)).
}}}

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

Django

unread,
Feb 10, 2018, 7:01:04 PM2/10/18
to django-...@googlegroups.com
#29118: QuerySet.order_by(Exists(...)) crashes
-------------------------------------+-------------------------------------
Reporter: Raphael Gaschignard | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 2.0
(models, ORM) |
Severity: Normal | 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 Tim Graham <timograham@…>):

In [changeset:"9b5ba2168c737c376a85f13d15808615b21b0b3a" 9b5ba216]:
{{{
#!CommitTicketReference repository=""
revision="9b5ba2168c737c376a85f13d15808615b21b0b3a"
[2.0.x] Fixed #29118 -- Fixed crash with QuerySet.order_by(Exists(...)).

Backport of bf26f66029bca94b007a2452679ac004598364a6 from master
}}}

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

Reply all
Reply to author
Forward
0 new messages