diff --git a/django/contrib/gis/db/backends/base.py b/django/contrib/gis/db/backends/base.py index 61c89fbf2b..bbf38b0242 100644 --- a/django/contrib/gis/db/backends/base.py +++ b/django/contrib/gis/db/backends/base.py @@ -18,6 +18,7 @@ class BaseSpatialOperations(object): geography_operators = {} geography_functions = {} gis_terms = {} + truncate_params = {} # Quick booleans for the type of this spatial backend, and # an attribute for the spatial database version tuple (if applicable) diff --git a/django/contrib/gis/db/backends/oracle/operations.py b/django/contrib/gis/db/backends/oracle/operations.py index 4599904c63..b444bb2899 100644 --- a/django/contrib/gis/db/backends/oracle/operations.py +++ b/django/contrib/gis/db/backends/oracle/operations.py @@ -57,7 +57,7 @@ class SDORelate(SpatialFunction): "Class for using SDO_RELATE." masks = 'TOUCH|OVERLAPBDYDISJOINT|OVERLAPBDYINTERSECT|EQUAL|INSIDE|COVEREDBY|CONTAINS|COVERS|ANYINTERACT|ON' mask_regex = re.compile(r'^(%s)(\+(%s))*$' % (masks, masks), re.I) - sql_template = "%(function)s(%(geo_col)s, %(geometry)s, 'mask=%(mask)s)' = 'TRUE'" + sql_template = "%(function)s(%(geo_col)s, %(geometry)s, 'mask=%(mask)s') = 'TRUE'" relate_func = 'SDO_RELATE' def __init__(self, mask): if not self.mask_regex.match(mask): @@ -128,6 +128,8 @@ class OracleOperations(DatabaseOperations, BaseSpatialOperations): gis_terms += geometry_functions.keys() gis_terms = dict([(term, None) for term in gis_terms]) + truncate_params = {'relate' : None} + def __init__(self, connection): super(OracleOperations, self).__init__() self.connection = connection diff --git a/django/contrib/gis/db/models/fields.py b/django/contrib/gis/db/models/fields.py index 0a78ce2292..0fd4c8b14d 100644 --- a/django/contrib/gis/db/models/fields.py +++ b/django/contrib/gis/db/models/fields.py @@ -165,7 +165,7 @@ class GeometryField(Field): except GeometryException: raise ValueError('Could not create geometry from lookup value.') else: - raise ValueError('Cannot use parameter of `%s` type as lookup parameter.' % type(value)) + raise ValueError('Cannot use object with type %s for a geometry lookup parameter.' % type(geom).__name__) # Assigning the SRID value. geom.srid = self.get_srid(geom) @@ -228,6 +228,10 @@ class GeometryField(Field): if lookup_type in connection.ops.distance_functions: # Getting the distance parameter in the units of the field. params += self.get_distance(value[1:], lookup_type, connection) + elif lookup_type in connection.ops.truncate_params: + # Lookup is one where SQL parameters aren't needed from the + # given lookup value. + pass else: params += value[1:] elif isinstance(value, SQLEvaluator): diff --git a/django/contrib/gis/tests/geoapp/tests.py b/django/contrib/gis/tests/geoapp/tests.py index a3f8fb1b01..24a7c1c02f 100644 --- a/django/contrib/gis/tests/geoapp/tests.py +++ b/django/contrib/gis/tests/geoapp/tests.py @@ -426,7 +426,6 @@ class GeoModelTest(TestCase): @no_mysql def test15_relate(self): "Testing the 'relate' lookup type." - return # To make things more interesting, we will have our Texas reference point in # different SRIDs. pnt1 = fromstr('POINT (649287.0363174 4177429.4494686)', srid=2847) @@ -434,7 +433,7 @@ class GeoModelTest(TestCase): # Not passing in a geometry as first param shoud # raise a type error when initializing the GeoQuerySet - self.assertRaises(ValueError, Country.objects.filter(mpoly__relate=(23, 'foo')).count) + self.assertRaises(ValueError, Country.objects.filter, mpoly__relate=(23, 'foo')) # Making sure the right exception is raised for the given # bad arguments.