Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed `F()` expression regressions in GeoDjango caused by recent data…

…structure changes in `SQLEvaluator`.
  • Loading branch information...
commit cd99c12f05b10cb1b3a07b7b4fcd9fb89785f7a8 1 parent 84f9741
@jbronn jbronn authored
View
10 django/contrib/gis/db/backends/base.py
@@ -116,6 +116,16 @@ def get_geom_placeholder(self, f, value):
"""
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.')
View
2  django/contrib/gis/db/backends/mysql/operations.py
@@ -44,7 +44,7 @@ def get_geom_placeholder(self, value, srid):
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
View
2  django/contrib/gis/db/backends/oracle/operations.py
@@ -213,7 +213,7 @@ def transform_value(val, srid):
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)
View
2  django/contrib/gis/db/backends/postgis/operations.py
@@ -381,7 +381,7 @@ def get_geom_placeholder(self, f, value):
# 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
View
2  django/contrib/gis/db/backends/spatialite/operations.py
@@ -208,7 +208,7 @@ def transform_value(value, srid):
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.
Please sign in to comment.
Something went wrong with that request. Please try again.