From 231eb1d3ac8da25c37a748785966ce543eea9fbe Mon Sep 17 00:00:00 2001 From: Justin Bronn Date: Wed, 24 Feb 2010 21:59:27 +0000 Subject: [PATCH] [1.1.X] Fixed #12828 -- The table quoting function is now argument `get_geo_where_clause`. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12587 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/gis/db/backend/mysql/query.py | 5 +---- django/contrib/gis/db/backend/oracle/query.py | 4 +--- django/contrib/gis/db/backend/postgis/query.py | 5 +---- django/contrib/gis/db/backend/spatialite/query.py | 4 +--- django/contrib/gis/db/models/sql/where.py | 2 +- 5 files changed, 5 insertions(+), 15 deletions(-) diff --git a/django/contrib/gis/db/backend/mysql/query.py b/django/contrib/gis/db/backend/mysql/query.py index 2fa984f325..1631a678e4 100644 --- a/django/contrib/gis/db/backend/mysql/query.py +++ b/django/contrib/gis/db/backend/mysql/query.py @@ -7,9 +7,6 @@ indices may only be used on MyISAM tables -- if you need transactions, take a look at PostGIS. """ -from django.db import connection -qn = connection.ops.quote_name - # To ease implementation, WKT is passed to/from MySQL. GEOM_FROM_TEXT = 'GeomFromText' GEOM_FROM_WKB = 'GeomFromWKB' @@ -40,7 +37,7 @@ MYSQL_GIS_TERMS = MYSQL_GIS_FUNCTIONS.keys() MYSQL_GIS_TERMS += MISC_TERMS MYSQL_GIS_TERMS = dict((term, None) for term in MYSQL_GIS_TERMS) # Making dictionary -def get_geo_where_clause(table_alias, name, lookup_type, geo_annot): +def get_geo_where_clause(table_alias, name, lookup_type, geo_annot, qn): "Returns the SQL WHERE clause for use in MySQL spatial SQL construction." # Getting the quoted field as `geo_col`. geo_col = '%s.%s' % (qn(table_alias), qn(name)) diff --git a/django/contrib/gis/db/backend/oracle/query.py b/django/contrib/gis/db/backend/oracle/query.py index dcf6f67ae2..46d4623db8 100644 --- a/django/contrib/gis/db/backend/oracle/query.py +++ b/django/contrib/gis/db/backend/oracle/query.py @@ -9,10 +9,8 @@ """ import re from decimal import Decimal -from django.db import connection from django.contrib.gis.db.backend.util import SpatialFunction from django.contrib.gis.measure import Distance -qn = connection.ops.quote_name # The GML, distance, transform, and union procedures. AREA = 'SDO_GEOM.SDO_AREA' @@ -110,7 +108,7 @@ ORACLE_SPATIAL_TERMS += MISC_TERMS ORACLE_SPATIAL_TERMS = dict((term, None) for term in ORACLE_SPATIAL_TERMS) # Making dictionary for fast lookups #### The `get_geo_where_clause` function for Oracle #### -def get_geo_where_clause(table_alias, name, lookup_type, geo_annot): +def get_geo_where_clause(table_alias, name, lookup_type, geo_annot, qn): "Returns the SQL WHERE clause for use in Oracle spatial SQL construction." # Getting the quoted table name as `geo_col`. geo_col = '%s.%s' % (qn(table_alias), qn(name)) diff --git a/django/contrib/gis/db/backend/postgis/query.py b/django/contrib/gis/db/backend/postgis/query.py index 7491676057..a3f29d1fad 100644 --- a/django/contrib/gis/db/backend/postgis/query.py +++ b/django/contrib/gis/db/backend/postgis/query.py @@ -5,13 +5,10 @@ import re from decimal import Decimal -from django.db import connection from django.conf import settings from django.contrib.gis.measure import Distance from django.contrib.gis.db.backend.util import SpatialOperation, SpatialFunction -qn = connection.ops.quote_name - # Get the PostGIS version information. # To avoid the need to do a database query to determine the PostGIS version # each time the server starts up, one can optionally specify a @@ -250,7 +247,7 @@ def num_params(lookup_type, val): else: return exactly_two(val) #### The `get_geo_where_clause` function for PostGIS. #### -def get_geo_where_clause(table_alias, name, lookup_type, geo_annot): +def get_geo_where_clause(table_alias, name, lookup_type, geo_annot, qn): "Returns the SQL WHERE clause for use in PostGIS SQL construction." # Getting the quoted field as `geo_col`. geo_col = '%s.%s' % (qn(table_alias), qn(name)) diff --git a/django/contrib/gis/db/backend/spatialite/query.py b/django/contrib/gis/db/backend/spatialite/query.py index 462722fa5d..10c8825f37 100644 --- a/django/contrib/gis/db/backend/spatialite/query.py +++ b/django/contrib/gis/db/backend/spatialite/query.py @@ -4,10 +4,8 @@ """ import re from decimal import Decimal -from django.db import connection from django.contrib.gis.measure import Distance from django.contrib.gis.db.backend.util import SpatialOperation, SpatialFunction -qn = connection.ops.quote_name GEOM_SELECT = 'AsText(%s)' @@ -115,7 +113,7 @@ SPATIALITE_TERMS += MISC_TERMS # Adding any other miscellaneous terms (e.g., 'is SPATIALITE_TERMS = dict((term, None) for term in SPATIALITE_TERMS) # Making a dictionary for fast lookups #### The `get_geo_where_clause` function for SpatiaLite. #### -def get_geo_where_clause(table_alias, name, lookup_type, geo_annot): +def get_geo_where_clause(table_alias, name, lookup_type, geo_annot, qn): "Returns the SQL WHERE clause for use in SpatiaLite SQL construction." # Getting the quoted field as `geo_col`. geo_col = '%s.%s' % (qn(table_alias), qn(name)) diff --git a/django/contrib/gis/db/models/sql/where.py b/django/contrib/gis/db/models/sql/where.py index 105cbfbec5..4ac325fa30 100644 --- a/django/contrib/gis/db/models/sql/where.py +++ b/django/contrib/gis/db/models/sql/where.py @@ -87,7 +87,7 @@ class GeoWhereNode(WhereNode): # will be populated in the GeoFieldSQL object returned by the # GeometryField. alias, col, db_type = obj - gwc = get_geo_where_clause(alias, col, lookup_type, value_annot) + gwc = get_geo_where_clause(alias, col, lookup_type, value_annot, qn) return gwc % value_annot.where, params else: raise TypeError('Invalid lookup type: %r' % lookup_type)