Fixed #10807 - `GeoWhereNode` no longer passes `Constraint` objects to where they shouldn't go.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10559 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
9a9c552f6f
commit
bd8afb1894
|
@ -76,17 +76,18 @@ class GeoWhereNode(WhereNode):
|
||||||
# the `get_geo_where_clause` to construct the appropriate
|
# the `get_geo_where_clause` to construct the appropriate
|
||||||
# spatial SQL when `make_atom` is called.
|
# spatial SQL when `make_atom` is called.
|
||||||
annotation = GeoAnnotation(field, value, where)
|
annotation = GeoAnnotation(field, value, where)
|
||||||
return super(WhereNode, self).add((obj, lookup_type, annotation, params), connector)
|
return super(WhereNode, self).add(((alias, col, field.db_type()), lookup_type, annotation, params), connector)
|
||||||
|
|
||||||
def make_atom(self, child, qn):
|
def make_atom(self, child, qn):
|
||||||
lvalue, lookup_type, value_annot, params = child
|
obj, lookup_type, value_annot, params = child
|
||||||
|
|
||||||
if isinstance(value_annot, GeoAnnotation):
|
if isinstance(value_annot, GeoAnnotation):
|
||||||
if lookup_type in SpatialBackend.gis_terms:
|
if lookup_type in SpatialBackend.gis_terms:
|
||||||
# Getting the geographic where clause; substitution parameters
|
# Getting the geographic where clause; substitution parameters
|
||||||
# will be populated in the GeoFieldSQL object returned by the
|
# will be populated in the GeoFieldSQL object returned by the
|
||||||
# GeometryField.
|
# GeometryField.
|
||||||
gwc = get_geo_where_clause(lvalue.alias, lvalue.col, lookup_type, value_annot)
|
alias, col, db_type = obj
|
||||||
|
gwc = get_geo_where_clause(alias, col, lookup_type, value_annot)
|
||||||
return gwc % value_annot.where, params
|
return gwc % value_annot.where, params
|
||||||
else:
|
else:
|
||||||
raise TypeError('Invalid lookup type: %r' % lookup_type)
|
raise TypeError('Invalid lookup type: %r' % lookup_type)
|
||||||
|
|
|
@ -210,6 +210,18 @@ class RelatedGeoModelTest(unittest.TestCase):
|
||||||
self.assertEqual(val_dict['id'], c_id)
|
self.assertEqual(val_dict['id'], c_id)
|
||||||
self.assertEqual(val_dict['location__id'], l_id)
|
self.assertEqual(val_dict['location__id'], l_id)
|
||||||
|
|
||||||
|
def test10_combine(self):
|
||||||
|
"Testing the combination of two GeoQuerySets. See #10807."
|
||||||
|
buf1 = City.objects.get(name='Aurora').location.point.buffer(0.1)
|
||||||
|
buf2 = City.objects.get(name='Kecksburg').location.point.buffer(0.1)
|
||||||
|
qs1 = City.objects.filter(location__point__within=buf1)
|
||||||
|
qs2 = City.objects.filter(location__point__within=buf2)
|
||||||
|
combined = qs1 | qs2
|
||||||
|
names = [c.name for c in combined]
|
||||||
|
self.assertEqual(2, len(names))
|
||||||
|
self.failUnless('Aurora' in names)
|
||||||
|
self.failUnless('Kecksburg' in names)
|
||||||
|
|
||||||
# TODO: Related tests for KML, GML, and distance lookups.
|
# TODO: Related tests for KML, GML, and distance lookups.
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
|
|
Loading…
Reference in New Issue