Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Malcolm Tredinnick authored April 23, 2008

Showing 1 changed file with 16 additions and 3 deletions. Show diff stats Hide diff stats

  1. 19  django/db/backends/oracle/query.py
19  django/db/backends/oracle/query.py
@@ -29,7 +29,7 @@ def resolve_columns(self, row, fields=()):
29 29
             from django.db.models.fields import DateField, DateTimeField, \
30 30
                  TimeField, BooleanField, NullBooleanField, DecimalField, Field
31 31
             index_start = len(self.extra_select.keys())
32  
-            values = []
  32
+            values = list(row[:index_start])
33 33
             for value, field in map(None, row[index_start:], fields):
34 34
                 if isinstance(value, Database.LOB):
35 35
                     value = value.read()
@@ -108,8 +108,7 @@ def as_sql(self, with_limits=True):
108 108
                 rn_orderby = '%s.%s' % (qn(opts.db_table), qn(opts.fields[0].db_column or opts.fields[0].column))
109 109
 
110 110
             # Getting the selection SQL and the params, which has the `rn`
111  
-            # extra selection SQL; we pop `rn` after this completes so we do
112  
-            # not get the attribute on the returned models.
  111
+            # extra selection SQL.
113 112
             self.extra_select['rn'] = 'ROW_NUMBER() OVER (ORDER BY %s )' % rn_orderby
114 113
             sql, params= super(OracleQuery, self).as_sql(with_limits=False)
115 114
 
@@ -125,6 +124,20 @@ def as_sql(self, with_limits=True):
125 124
             # Returning the SQL w/params.
126 125
             return ' '.join(result), params
127 126
 
  127
+        def set_limits(self, low=None, high=None):
  128
+            super(OracleQuery, self).set_limits(low, high)
  129
+
  130
+            # We need to select the row number for the LIMIT/OFFSET sql.
  131
+            # A placeholder is added to extra_select now, because as_sql is
  132
+            # too late to be modifying extra_select.  However, the actual sql
  133
+            # depends on the ordering, so that is generated in as_sql.
  134
+            self.extra_select['rn'] = '1'
  135
+
  136
+        def clear_limits(self):
  137
+            super(OracleQuery, self).clear_limits()
  138
+            if 'rn' in self.extra_select:
  139
+                del self.extra_select['rn']
  140
+
128 141
     _classes[QueryClass] = OracleQuery
129 142
     return OracleQuery
130 143
 

0 notes on commit 5a9a208

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