Ticket #5012: negative_sliced_querysets_oracle.2.patch
File negative_sliced_querysets_oracle.2.patch, 2.6 KB (added by , 17 years ago) |
---|
-
django/db/backends/oracle/base.py
183 183 184 184 def get_limit_offset_sql(limit, offset=None): 185 185 # Limits and offset are too complicated to be handled here. 186 # Instead, they are handled in django/db/backends/oracle/query.py.186 # Instead, they are handled in the OracleQuerySet class. 187 187 return "" 188 188 189 189 def get_random_function_sql(): … … 310 310 311 311 class OracleQuerySet(DefaultQuerySet): 312 312 313 def iterator(self):313 def _iterator(self): 314 314 "Performs the SELECT database lookup of this QuerySet." 315 315 316 316 from django.db.models.query import get_cached_row … … 328 328 select, sql, params = self._get_sql_clause() 329 329 except EmptyResultSet: 330 330 raise StopIteration 331 if self._limit == 0: 332 raise StopIteration 331 333 if not full_query: 332 334 full_query = "SELECT %s%s\n%s" % \ 333 335 ((self._distinct and "DISTINCT " or ""), … … 405 407 406 408 # ORDER BY clause 407 409 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): 410 for f in handle_legacy_orderlist(self._get_ordering()): 413 411 if f == '?': # Special case. 414 412 order_by.append(backend.get_random_function_sql()) 415 413 else: … … 452 450 order_by_clause = " OVER (ORDER BY %s )" % (", ".join(order_by)) 453 451 else: 454 452 #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'" 453 #So we need to define a stable order-by, since none was provided. 454 order_by_clause = " OVER (ORDER BY 1)" 462 455 456 # limit_and_offset_clause 463 457 if self._offset is not None: 464 458 offset = int(self._offset) 465 459 else: