--
Ticket URL: <https://code.djangoproject.com/ticket/18414>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* cc: paluho@… (added)
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/18414#comment:1>
* stage: Unreviewed => Accepted
Comment:
`QuerySet.exists()` should throw an exception for this case, and possibly
for any case involving slicing - I don't think it was designed to be
correct in the presence of LIMIT/OFFSET. However, for the moment probably
best to limit to the distinct()+slicing()+exists() combination.
--
Ticket URL: <https://code.djangoproject.com/ticket/18414#comment:2>
* cc: bitrut@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/18414#comment:3>
* owner: nobody => err
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/18414#comment:4>
* has_patch: 0 => 1
Comment:
Here is my pull request: https://github.com/django/django/pull/161
--
Ticket URL: <https://code.djangoproject.com/ticket/18414#comment:5>
Comment (by akaariai):
The pull request doesn't seem to do what Luke asked - it disallows the
usage in any filtered situation, not just in conjunction with .distinct().
It seems likely there are users relying on this currently.
As for fixing the distinct() + limit + .exists() - it should be done by
not doing select distinct(1) but instead select distinct {normal select
fields} instead. I wonder if this would be straightforward to do?
--
Ticket URL: <https://code.djangoproject.com/ticket/18414#comment:6>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/18414#comment:7>
Comment (by akaariai):
It seems this will be relatively easy to fix, just do
{{{
if not q.distinct:
q.clear_select_clause()
}}}
instead of always doing clear_select_clause(). I'll test this & commit if
things seem to work OK.
--
Ticket URL: <https://code.djangoproject.com/ticket/18414#comment:8>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"93cc6dcdac6fc3e506640fa38dd1798c3cd61cff"]:
{{{
#!CommitTicketReference repository=""
revision="93cc6dcdac6fc3e506640fa38dd1798c3cd61cff"
Fixed #18414 -- qs.exists() for sliced distinct queries
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/18414#comment:9>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"d2263b7b87a2af5dcd6964937b157b7e1cf2881f" d2263b7b]:
{{{
#!CommitTicketReference repository=""
revision="d2263b7b87a2af5dcd6964937b157b7e1cf2881f"
Refs #18414 -- Added tests for selected columns of sliced distinct
querysets.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/18414#comment:10>