From e600364f7ddc77c45339bee5527f2e3898e7b126 Mon Sep 17 00:00:00 2001 From: Justin Bronn Date: Wed, 5 Nov 2008 18:15:48 +0000 Subject: [PATCH] Fixed `resolve_columns` so that pagination works again on Oracle GeoQuerySets; properly set svn:ignore on `sitemaps` subdir. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9338 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/gis/db/models/sql/query.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/django/contrib/gis/db/models/sql/query.py b/django/contrib/gis/db/models/sql/query.py index f3e9fb25ca..92c26fa126 100644 --- a/django/contrib/gis/db/models/sql/query.py +++ b/django/contrib/gis/db/models/sql/query.py @@ -172,11 +172,21 @@ class GeoQuery(sql.Query): """ values = [] aliases = self.extra_select.keys() - index_start = len(aliases) - values = [self.convert_values(v, self.extra_select_fields.get(a, None)) - for v, a in izip(row[:index_start], aliases)] + + # Have to set a starting row number offset that is used for + # determining the correct starting row index -- needed for + # doing pagination with Oracle. + rn_offset = 0 if SpatialBackend.oracle: - # This is what happens normally in Oracle's `resolve_columns`. + if self.high_mark is not None or self.low_mark: rn_offset = 1 + index_start = rn_offset + len(aliases) + + # Converting any extra selection values (e.g., geometries and + # distance objects added by GeoQuerySet methods). + values = [self.convert_values(v, self.extra_select_fields.get(a, None)) + for v, a in izip(row[rn_offset:index_start], aliases)] + if SpatialBackend.oracle: + # This is what happens normally in OracleQuery's `resolve_columns`. for value, field in izip(row[index_start:], fields): values.append(self.convert_values(value, field)) else: @@ -187,7 +197,7 @@ class GeoQuery(sql.Query): """ Using the same routines that Oracle does we can convert our extra selection objects into Geometry and Distance objects. - TODO: Laziness. + TODO: Make converted objects 'lazy' for less overhead. """ if SpatialBackend.oracle: # Running through Oracle's first.