summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-04-23 07:30:30 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-04-23 07:30:30 +0000
commit5a9a208b7a72a1ce6b73ac4bbc93b8468da1b891 (patch)
tree3c36b9c517ac04eaece5ac8ad6859bb855615d00
parent0a66eabc8ab9d11e131101c861a781810067c09e (diff)
queryset-refactor: The change in [7438] didn't fix #7036 properly. This 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
-rw-r--r--django/db/backends/oracle/query.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/django/db/backends/oracle/query.py b/django/db/backends/oracle/query.py
index 699398a254..49f695ed94 100644
--- a/django/db/backends/oracle/query.py
+++ b/django/db/backends/oracle/query.py
@@ -29,7 +29,7 @@ def query_class(QueryClass, Database):
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 query_class(QueryClass, Database):
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 query_class(QueryClass, Database):
# 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