Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

queryset-refactor: The change in [7438] didn't fix #7036 properly. Th…

…is is a

more comprehensive diagnosis and fix from Ian Kelly. Fixed #7036.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7443 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5a9a208b7a72a1ce6b73ac4bbc93b8468da1b891 1 parent 0a66eab
@malcolmt malcolmt authored
Showing with 16 additions and 3 deletions.
  1. +16 −3 django/db/backends/oracle/query.py
View
19 django/db/backends/oracle/query.py
@@ -29,7 +29,7 @@ def resolve_columns(self, row, fields=()):
from django.db.models.fields import DateField, DateTimeField, \
TimeField, BooleanField, NullBooleanField, DecimalField, Field
index_start = len(self.extra_select.keys())
- values = []
+ values = list(row[:index_start])
for value, field in map(None, row[index_start:], fields):
if isinstance(value, Database.LOB):
value = value.read()
@@ -108,8 +108,7 @@ def as_sql(self, with_limits=True):
rn_orderby = '%s.%s' % (qn(opts.db_table), qn(opts.fields[0].db_column or opts.fields[0].column))
# Getting the selection SQL and the params, which has the `rn`
- # extra selection SQL; we pop `rn` after this completes so we do
- # not get the attribute on the returned models.
+ # 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)
@@ -125,6 +124,20 @@ def as_sql(self, with_limits=True):
# Returning the SQL w/params.
return ' '.join(result), params
+ def set_limits(self, low=None, high=None):
+ super(OracleQuery, self).set_limits(low, high)
+
+ # We need to select the row number for the LIMIT/OFFSET sql.
+ # A placeholder is added to extra_select now, because as_sql is
+ # too late to be modifying extra_select. However, the actual sql
+ # depends on the ordering, so that is generated in as_sql.
+ self.extra_select['rn'] = '1'
+
+ def clear_limits(self):
+ super(OracleQuery, self).clear_limits()
+ if 'rn' in self.extra_select:
+ del self.extra_select['rn']
+
_classes[QueryClass] = OracleQuery
return OracleQuery

0 comments on commit 5a9a208

Please sign in to comment.
Something went wrong with that request. Please try again.