Ticket #10159: geowherenode_expressions_fix.diff
File geowherenode_expressions_fix.diff, 1.7 KB (added by , 16 years ago) |
---|
-
django/contrib/gis/db/models/sql/where.py
1 1 import datetime 2 from django.db import connection 2 3 from django.db.models.fields import Field 4 from django.db.models.sql.expressions import SQLEvaluator 3 5 from django.db.models.sql.where import WhereNode 4 6 from django.contrib.gis.db.backend import get_geo_where_clause, SpatialBackend 7 qn = connection.ops.quote_name 5 8 6 9 class GeoAnnotation(object): 7 10 """ … … 37 40 # Not a geographic field, so call `WhereNode.add`. 38 41 return super(GeoWhereNode, self).add(data, connector) 39 42 else: 40 # `GeometryField.get_db_prep_lookup` returns a where clause41 # substitution array in addition to the parameters.42 where, params = field.get_db_prep_lookup(lookup_type, value)43 43 44 if isinstance(value, SQLEvaluator): 45 # If an expression is used, we are getting a database column so 46 # we we don't send to get_db_prep_lookup. 47 where = ['%s.%s' % tuple(map(qn, value.cols[value.expression]))] 48 params = () 49 else: 50 # `GeometryField.get_db_prep_lookup` returns a where clause 51 # substitution array in addition to the parameters. 52 where, params = field.get_db_prep_lookup(lookup_type, value) 53 44 54 # The annotation will be a `GeoAnnotation` object that 45 55 # will contain the necessary geometry field metadata for 46 56 # the `get_geo_where_clause` to construct the appropriate