﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
11741	PostgreSQL/PostGIS backend table quoting bug in nested queries	nino@…	jbronn	"This issue occurs when using a spatial query as a subselect. The spatial predicate's table alias is quoted when it should not be.  

E.g.:
{{{
>>> MyGeoTable.objects.filter(geometry__intersects=geom).values_list('fid', flat=True).distinct().query.as_nested_sql()
('SELECT DISTINCT U0.""ogc_fid"" FROM ""my_geo_table"" U0 WHERE ST_Intersects(""U0"".""split"", %s)', (<django.contrib.gis.db.backend.postgis.adaptor.PostGISAdaptor object at 0xb6618c2c>,))

}}}

In the above ST_Intersects clause, the alias '''U0''' is quoted.  This happens here,I believe:
http://code.djangoproject.com/browser/django/trunk/django/contrib/gis/db/backend/postgis/query.py#L256

I have not patched it yet, as I'm not clear yet how.

"		closed	GIS	dev		fixed	PostGIS Postgresql		Accepted	0	0	0	0	0	0
