#14483: Implement subqueries in geodjango spatial lookup ---------------------------------+------------------------------------------ Reporter: milosu | Owner: nobody Status: new | Milestone: Component: GIS | Version: 1.2 Keywords: geodjango, subquery | Stage: Unreviewed Has_patch: 1 | ---------------------------------+------------------------------------------ Currently only GEOS geometry objects can be used in the GeoQuerySet spatial field lookups. Sometimes the geometry objects are very large geometries on its own and the resulting SQL statement that includes EWKB of the geometry is very large (lets say 30 mega bytes in my case).
Attached patch extends GeoDjango ORM to support subqueries in spatial lookups, so that it is possible to make a query like: {{{ qset = Address.objects.filter(location__within = District.objects.filter(name='Boston area').values('area')) }}} so that the resulting spatial SQL looks like: {{{ SELECT "spatial_subquery_address"."id", "spatial_subquery_address"."city", "spatial_subquery_address"."location" FROM "spatial_subquery_address" WHERE ST_Within("spatial_subquery_address"."location", (SELECT U0."area" FROM "spatial_subquery_district" U0 WHERE U0."name" = Boston area )) }}} See attached regression test for this enhancement. Patch was built against slightly modified Django 1.2.3 so that it will not apply cleanly, but I hope jbronn or someone else should get the idea from my attached version. -- Ticket URL: <http://code.djangoproject.com/ticket/14483> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.