1
0
mirror of https://github.com/django/django.git synced 2025-07-05 18:29:11 +00:00

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
This commit is contained in:
Malcolm Tredinnick 2008-04-23 07:30:30 +00:00
parent 0a66eabc8a
commit 5a9a208b7a

View File

@ -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