#11741 closed (fixed)
PostgreSQL/PostGIS backend table quoting bug in nested queries
Reported by: | Owned by: | jbronn | |
---|---|---|---|
Component: | GIS | Version: | dev |
Severity: | Keywords: | PostGIS Postgresql | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Attachments (1)
Change History (7)
comment:1 by , 15 years ago
by , 15 years ago
Attachment: | django-gis.diff added |
---|
comment:2 by , 15 years ago
I think the attached diffs will fix the problem. GeoWhereNode can pass the quote function through to get_geo_where_clause.
comment:3 by , 15 years ago
milestone: | → 1.2 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Version: | 1.1 → SVN |
Confirmed as a bug. A patch to fix this will be available after multi-db support lands.
comment:4 by , 15 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:5 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
The issue looks to be that the global quote_name shouldn't be use there, but instead Query.quote_name_unless_alias.