Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fix #19263 #808

Closed
wants to merge 1 commit into from

2 participants

@biern

No description provided.

@HonzaKral
Collaborator

Sorry, this is not a fix for the problem, as discussed in person, closing this PR.

@HonzaKral HonzaKral closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 23, 2013
  1. @biern
This page is out of date. Refresh to see the latest.
View
4 django/db/models/query.py
@@ -209,6 +209,10 @@ def __getitem__(self, k):
stop = int(k.stop)
else:
stop = None
+
+ if start is not None and start == stop:
+ return self.none()
+
qs.query.set_limits(start, stop)
return k.step and list(qs)[::k.step] or qs
View
2  django/db/models/sql/compiler.py
@@ -64,8 +64,6 @@ def as_sql(self, with_limits=True, with_col_aliases=False):
If 'with_limits' is False, any limit/offset information is not included
in the query.
"""
- if with_limits and self.query.low_mark == self.query.high_mark:
- return '', ()
self.pre_sql_setup()
# After executing the query, we must get rid of any joins the query
View
8 tests/regressiontests/queries/tests.py
@@ -2021,6 +2021,9 @@ def setUp(self):
Article.objects.create(name='three', created=datetime.datetime.now())
Article.objects.create(name='four', created=datetime.datetime.now())
+ spam = Food.objects.create(name='spam')
+ Eaten.objects.create(meal='spam with cheese', food=spam)
+
def test_tickets_7698_10202(self):
# People like to slice with '0' as the high-water mark.
self.assertQuerysetEqual(Article.objects.all()[0:0], [])
@@ -2035,6 +2038,11 @@ def test_tickets_7698_10202(self):
def test_empty_resultset_sql(self):
# ticket #12192
self.assertNumQueries(0, lambda: list(Number.objects.all()[1:1]))
+ # ticket #19263 - testing subqueries
+ self.assertNumQueries(0, lambda: list(Eaten.objects.filter(
+ food__in=Food.objects.all()[0:0])))
+ self.assertNumQueries(1, lambda: list(Eaten.objects.exclude(
+ food__in=Food.objects.all()[0:0])))
class EscapingTests(TestCase):
Something went wrong with that request. Please try again.