summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Bronn <jbronn@gmail.com>2012-10-05 18:41:50 -0700
committerJustin Bronn <jbronn@gmail.com>2012-10-05 18:41:50 -0700
commitcd99c12f05b10cb1b3a07b7b4fcd9fb89785f7a8 (patch)
tree6da08da549d2753726d2dd7a8c9519eefc6e2930
parent84f9741664dadb3185c3d8822b720b340374066e (diff)
Fixed `F()` expression regressions in GeoDjango caused by recent datastructure changes in `SQLEvaluator`.
-rw-r--r--django/contrib/gis/db/backends/base.py10
-rw-r--r--django/contrib/gis/db/backends/mysql/operations.py2
-rw-r--r--django/contrib/gis/db/backends/oracle/operations.py2
-rw-r--r--django/contrib/gis/db/backends/postgis/operations.py2
-rw-r--r--django/contrib/gis/db/backends/spatialite/operations.py2
5 files changed, 14 insertions, 4 deletions
diff --git a/django/contrib/gis/db/backends/base.py b/django/contrib/gis/db/backends/base.py
index 2b8924d92e..0bd598997c 100644
--- a/django/contrib/gis/db/backends/base.py
+++ b/django/contrib/gis/db/backends/base.py
@@ -116,6 +116,16 @@ class BaseSpatialOperations(object):
"""
raise NotImplementedError
+ def get_expression_column(self, evaluator):
+ """
+ Helper method to return the quoted column string from the evaluator
+ for its expression.
+ """
+ for expr, col_tup in evaluator.cols:
+ if expr is evaluator.expression:
+ return '%s.%s' % tuple(map(self.quote_name, col_tup))
+ raise Exception("Could not find the column for the expression.")
+
# Spatial SQL Construction
def spatial_aggregate_sql(self, agg):
raise NotImplementedError('Aggregate support not implemented for this spatial backend.')
diff --git a/django/contrib/gis/db/backends/mysql/operations.py b/django/contrib/gis/db/backends/mysql/operations.py
index 7152f4682d..0c1be624f1 100644
--- a/django/contrib/gis/db/backends/mysql/operations.py
+++ b/django/contrib/gis/db/backends/mysql/operations.py
@@ -44,7 +44,7 @@ class MySQLOperations(DatabaseOperations, BaseSpatialOperations):
modify the placeholder based on the contents of the given value.
"""
if hasattr(value, 'expression'):
- placeholder = '%s.%s' % tuple(map(self.quote_name, value.cols[value.expression]))
+ placeholder = placeholder % self.get_expression_column(value)
else:
placeholder = '%s(%%s)' % self.from_text
return placeholder
diff --git a/django/contrib/gis/db/backends/oracle/operations.py b/django/contrib/gis/db/backends/oracle/operations.py
index 392feb129b..35a4d9491d 100644
--- a/django/contrib/gis/db/backends/oracle/operations.py
+++ b/django/contrib/gis/db/backends/oracle/operations.py
@@ -213,7 +213,7 @@ class OracleOperations(DatabaseOperations, BaseSpatialOperations):
placeholder = '%s'
# No geometry value used for F expression, substitue in
# the column name instead.
- return placeholder % '%s.%s' % tuple(map(self.quote_name, value.cols[value.expression]))
+ return placeholder % self.get_expression_column(value)
else:
if transform_value(value, f.srid):
return '%s(SDO_GEOMETRY(%%s, %s), %s)' % (self.transform, value.srid, f.srid)
diff --git a/django/contrib/gis/db/backends/postgis/operations.py b/django/contrib/gis/db/backends/postgis/operations.py
index 18a59d1240..ff9110de01 100644
--- a/django/contrib/gis/db/backends/postgis/operations.py
+++ b/django/contrib/gis/db/backends/postgis/operations.py
@@ -381,7 +381,7 @@ class PostGISOperations(DatabaseOperations, BaseSpatialOperations):
# If this is an F expression, then we don't really want
# a placeholder and instead substitute in the column
# of the expression.
- placeholder = placeholder % '%s.%s' % tuple(map(self.quote_name, value.cols[value.expression]))
+ placeholder = placeholder % self.get_expression_column(value)
return placeholder
diff --git a/django/contrib/gis/db/backends/spatialite/operations.py b/django/contrib/gis/db/backends/spatialite/operations.py
index 80f05ef076..5f76501ef1 100644
--- a/django/contrib/gis/db/backends/spatialite/operations.py
+++ b/django/contrib/gis/db/backends/spatialite/operations.py
@@ -208,7 +208,7 @@ class SpatiaLiteOperations(DatabaseOperations, BaseSpatialOperations):
placeholder = '%s'
# No geometry value used for F expression, substitue in
# the column name instead.
- return placeholder % '%s.%s' % tuple(map(self.quote_name, value.cols[value.expression]))
+ return placeholder % self.get_expression_column(value)
else:
if transform_value(value, f.srid):
# Adding Transform() to the SQL placeholder.