Ticket #7036: 7036_redux.diff

File 7036_redux.diff, 2.0 KB (added by Erin Kelly, 17 years ago)
  • django/db/backends/oracle/query.py

     
    2929            from django.db.models.fields import DateField, DateTimeField, \
    3030                 TimeField, BooleanField, NullBooleanField, DecimalField, Field
    3131            index_start = len(self.extra_select.keys())
    32             values = []
     32            values = list(row[:index_start])
    3333            for value, field in map(None, row[index_start:], fields):
    3434                if isinstance(value, Database.LOB):
    3535                    value = value.read()
     
    108108                rn_orderby = '%s.%s' % (qn(opts.db_table), qn(opts.fields[0].db_column or opts.fields[0].column))
    109109
    110110            # 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.
    113112            self.extra_select['rn'] = 'ROW_NUMBER() OVER (ORDER BY %s )' % rn_orderby
    114113            sql, params= super(OracleQuery, self).as_sql(with_limits=False)
    115114
     
    125124            # Returning the SQL w/params.
    126125            return ' '.join(result), params
    127126
     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
    128141    _classes[QueryClass] = OracleQuery
    129142    return OracleQuery
    130143
Back to Top