[Django] #30120: Query syntax error with condition and distinct combination

5 views
Skip to first unread message

Django

unread,
Jan 20, 2019, 2:34:56 PM1/20/19
to django-...@googlegroups.com
#30120: Query syntax error with condition and distinct combination
-------------------------------------+-------------------------------------
Reporter: Claude | Owner: nobody
Paroz |
Type: Bug | Status: new
Component: Database | Version: 2.2
layer (models, ORM) |
Severity: Release | Keywords:
blocker |
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
A `Count` annotation containing both a `Case` condition and a
`distinct=True` param produces a query error on Django 2.2 (whatever the
db backend). A space is missing at least (`... COUNT(DISTINCTCASE WHEN
...`).

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

Django

unread,
Jan 20, 2019, 2:35:42 PM1/20/19
to django-...@googlegroups.com
#30120: Query syntax error with condition and distinct combination
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

* Attachment "query_test.diff" added.

Failing test example

Django

unread,
Jan 20, 2019, 2:45:36 PM1/20/19
to django-...@googlegroups.com
#30120: Query syntax error with condition and distinct combination
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: nobody
Type: Bug | Status: new

Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

Bisected to [bc05547cd8c1dd511c6b6a6c873a1bc63417b111] Fixed #28658 --
Added DISTINCT handling to the Aggregate class.

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

Django

unread,
Jan 20, 2019, 5:58:24 PM1/20/19
to django-...@googlegroups.com
#30120: Query syntax error with condition and distinct combination
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Simon
| Charette
Type: Bug | Status: assigned

Component: Database layer | Version: 2.2
(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: nobody => Simon Charette
* status: new => assigned
* stage: Unreviewed => Accepted


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

Django

unread,
Jan 20, 2019, 7:22:47 PM1/20/19
to django-...@googlegroups.com
#30120: Query syntax error with condition and distinct combination
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 2.2
(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/30120#comment:3>

Django

unread,
Jan 21, 2019, 3:46:20 AM1/21/19
to django-...@googlegroups.com
#30120: Query syntax error with condition and distinct combination
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 2.2
(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 Claude Paroz):

* stage: Accepted => Ready for checkin


Comment:

Thanks for the quick fix!

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

Django

unread,
Jan 21, 2019, 9:25:29 AM1/21/19
to django-...@googlegroups.com
#30120: Query syntax error with condition and distinct combination
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Simon
| Charette
Type: Bug | Status: closed

Component: Database layer | Version: 2.2
(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 Tim Graham <timograham@…>):

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


Comment:

In [changeset:"6516e49262546238d02f6ca37b74ee0e67dead0a" 6516e492]:
{{{
#!CommitTicketReference repository=""
revision="6516e49262546238d02f6ca37b74ee0e67dead0a"
[2.2.x] Fixed #30120 -- Fixed invalid SQL in distinct aggregate.

Regression in bc05547cd8c1dd511c6b6a6c873a1bc63417b111 (refs #28658).
Backport of 65858119d23e37872505a4476e7141c33981fb50 from master.
}}}

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

Django

unread,
Jan 21, 2019, 9:25:31 AM1/21/19
to django-...@googlegroups.com
#30120: Query syntax error with condition and distinct combination
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Simon
| Charette
Type: Bug | Status: closed
Component: Database layer | Version: 2.2
(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 Tim Graham <timograham@…>):

In [changeset:"65858119d23e37872505a4476e7141c33981fb50" 65858119]:
{{{
#!CommitTicketReference repository=""
revision="65858119d23e37872505a4476e7141c33981fb50"


Fixed #30120 -- Fixed invalid SQL in distinct aggregate.

Regression in bc05547cd8c1dd511c6b6a6c873a1bc63417b111 (refs #28658).
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30120#comment:6>

Reply all
Reply to author
Forward
0 new messages