Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #10807 - `GeoWhereNode` no longer passes `Constraint` objects t…

…o where they shouldn't go.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10559 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit bd8afb18940b3e4f711b714dd20abf1053e31e70 1 parent 9a9c552
@jbronn jbronn authored
View
7 django/contrib/gis/db/models/sql/where.py
@@ -76,17 +76,18 @@ def add(self, data, connector):
# the `get_geo_where_clause` to construct the appropriate
# spatial SQL when `make_atom` is called.
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):
- lvalue, lookup_type, value_annot, params = child
+ obj, lookup_type, value_annot, params = child
if isinstance(value_annot, GeoAnnotation):
if lookup_type in SpatialBackend.gis_terms:
# Getting the geographic where clause; substitution parameters
# will be populated in the GeoFieldSQL object returned by the
# 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
else:
raise TypeError('Invalid lookup type: %r' % lookup_type)
View
12 django/contrib/gis/tests/relatedapp/tests.py
@@ -210,6 +210,18 @@ def test09_pk_relations(self):
self.assertEqual(val_dict['id'], c_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.
def suite():
Please sign in to comment.
Something went wrong with that request. Please try again.