Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #12690 -- Fixed SQL template used for Oracle's with `SDO_RELATE…

…` function, added `truncate_params` attribute to spatial backend, and re-enabled the `relate` lookup tests. Thanks, jtiai, for the bug report.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12300 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 474ce51ffd9e7f0963d666bdb429f00b04cdaee3 1 parent a260980
@jbronn jbronn authored
View
1  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)
View
4 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
View
6 django/contrib/gis/db/models/fields.py
@@ -165,7 +165,7 @@ def get_prep_value(self, value):
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 @@ def get_db_prep_lookup(self, lookup_type, value, connection, prepared=False):
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):
View
3  django/contrib/gis/tests/geoapp/tests.py
@@ -426,7 +426,6 @@ def test14_equals(self):
@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 @@ def test15_relate(self):
# 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.

0 comments on commit 474ce51

Please sign in to comment.
Something went wrong with that request. Please try again.