100 | | # `get_columns` needs to be called before `get_ordering` to |
101 | | # populate `_select_alias`. |
102 | | self.pre_sql_setup() |
103 | | self.get_columns() |
104 | | ordering = self.get_ordering() |
| 100 | self.extra_where = list(self.extra_where) |
| 101 | self.extra_where.extend(('ROWNUM > %d' % self.low_mark, )) |
| 102 | if self.high_mark is not None: |
| 103 | self.extra_where.extend(('ROWNUM <= %d' % self.high_mark, )) |
| 104 | self.extra_where = tuple(self.extra_where) |
106 | | # Oracle's ROW_NUMBER() function requires an ORDER BY clause. |
107 | | if ordering: |
108 | | rn_orderby = ', '.join(ordering) |
109 | | else: |
110 | | # Create a default ORDER BY since none was specified. |
111 | | qn = self.quote_name_unless_alias |
112 | | opts = self.model._meta |
113 | | rn_orderby = '%s.%s' % (qn(opts.db_table), |
114 | | qn(opts.fields[0].db_column or opts.fields[0].column)) |
115 | | |
116 | | # Ensure the base query SELECTs our special "_RN" column |
117 | | self.extra_select['_RN'] = ('ROW_NUMBER() OVER (ORDER BY %s)' |
118 | | % rn_orderby, '') |