Ticket #5012: negative_sliced_querysets_oracle.patch
File negative_sliced_querysets_oracle.patch, 2.9 KB (added by , 17 years ago) |
---|
-
django/db/backends/oracle/base.py
30 30 # Import copy of _thread_local.py from Python 2.4 31 31 from django.utils._threading_local import local 32 32 33 try: 34 reversed 35 except NameError: 36 from django.utils.itercompat import reversed # Python 2.3 fallback 37 33 38 class DatabaseWrapper(local): 34 39 def __init__(self, **kwargs): 35 40 self.connection = None … … 183 188 184 189 def get_limit_offset_sql(limit, offset=None): 185 190 # Limits and offset are too complicated to be handled here. 186 # Instead, they are handled in django/db/backends/oracle/query.py.191 # Instead, they are handled in the OracleQuerySet class. 187 192 return "" 188 193 189 194 def get_random_function_sql(): … … 310 315 311 316 class OracleQuerySet(DefaultQuerySet): 312 317 313 def iterator(self):318 def _iterator(self): 314 319 "Performs the SELECT database lookup of this QuerySet." 315 320 316 321 from django.db.models.query import get_cached_row … … 328 333 select, sql, params = self._get_sql_clause() 329 334 except EmptyResultSet: 330 335 raise StopIteration 336 if self._limit == 0: 337 raise StopIteration 331 338 if not full_query: 332 339 full_query = "SELECT %s%s\n%s" % \ 333 340 ((self._distinct and "DISTINCT " or ""), … … 405 412 406 413 # ORDER BY clause 407 414 order_by = [] 408 if self._order_by is not None: 409 ordering_to_use = self._order_by 410 else: 411 ordering_to_use = opts.ordering 412 for f in handle_legacy_orderlist(ordering_to_use): 415 for f in handle_legacy_orderlist(self._get_ordering()): 413 416 if f == '?': # Special case. 414 417 order_by.append(backend.get_random_function_sql()) 415 418 else: … … 452 455 order_by_clause = " OVER (ORDER BY %s )" % (", ".join(order_by)) 453 456 else: 454 457 #Oracle's row_number() function always requires an order-by clause. 455 #So we need to define a default order-by, since none was provided. 456 order_by_clause = " OVER (ORDER BY %s.%s)" % \ 457 (backend.quote_name(opts.db_table), 458 backend.quote_name(opts.fields[0].db_column or opts.fields[0].column)) 459 # limit_and_offset_clause 460 if self._limit is None: 461 assert self._offset is None, "'offset' is not allowed without 'limit'" 458 #So we need to define a stable order-by, since none was provided. 459 order_by_clause = " OVER (ORDER BY 1)" 462 460 461 # limit_and_offset_clause 463 462 if self._offset is not None: 464 463 offset = int(self._offset) 465 464 else: