Permalink
Browse files

Fixed Oracle backend failure in test suite for modeltests.queries. It…

…em.objects.all()[0:0] was optimizing out the limits clause and returning all rows.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8069 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
mboersma committed Jul 24, 2008
1 parent f5801e5 commit 96d141dfdac5b9913277e2b5d47b412c85453169
Showing with 5 additions and 4 deletions.
  1. +5 −4 django/db/backends/oracle/query.py
@@ -87,9 +87,11 @@ 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.
"""
+
# The `do_offset` flag indicates whether we need to construct
# the SQL needed to use limit/offset w/Oracle.
- do_offset = with_limits and (self.high_mark or self.low_mark)
+ do_offset = with_limits and (self.high_mark is not None
+ or self.low_mark)
# If no offsets, just return the result of the base class
# `as_sql`.
@@ -117,7 +119,7 @@ def as_sql(self, with_limits=True, with_col_aliases=False):
# Getting the selection SQL and the params, which has the `rn`
# extra selection SQL.
self.extra_select['rn'] = 'ROW_NUMBER() OVER (ORDER BY %s )' % rn_orderby
- sql, params= super(OracleQuery, self).as_sql(with_limits=False,
+ sql, params = super(OracleQuery, self).as_sql(with_limits=False,
with_col_aliases=True)
# Constructing the result SQL, using the initial select SQL
@@ -126,7 +128,7 @@ def as_sql(self, with_limits=True, with_col_aliases=False):
# Place WHERE condition on `rn` for the desired range.
result.append('WHERE rn > %d' % self.low_mark)
- if self.high_mark:
+ if self.high_mark is not None:
result.append('AND rn <= %d' % self.high_mark)
# Returning the SQL w/params.
@@ -148,4 +150,3 @@ def clear_limits(self):
_classes[QueryClass] = OracleQuery
return OracleQuery
-

0 comments on commit 96d141d

Please sign in to comment.