Opened 7 years ago

Closed 7 years ago

#12690 closed (fixed)

Oracle related lookup query fails in geodjango

Reported by: jtiai Owned by: nobody
Component: GIS Version: master
Severity: Keywords: oracle query orm lookup
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation:
Needs tests: Patch needs improvement:
Easy pickings: UI/UX:


MyModel.objects.filter(geomfield__relate=(geom, 'anyinteract') fails with exception:

Traceback (most recent call last): 
File "/home/KEYPRO/jtiai/src/django-workspaces/keycom/keygwt-core/keygwt_core/gis/services/", line 104, in get_by_bounding_box count = qs.count()
File "/home/KEYPRO/jtiai/src/django-workspaces/keycom/django-trunk/django/db/models/", line 324, in count return self.query.get_count(using=self.db)
File "/home/KEYPRO/jtiai/src/django-workspaces/keycom/django-trunk/django/db/models/sql/", line 369, in get_count number = obj.get_aggregation(using=using)[None]
File "/home/KEYPRO/jtiai/src/django-workspaces/keycom/django-trunk/django/contrib/gis/db/models/sql/", line 80, in get_aggregation return super(GeoQuery, self).get_aggregation(using)
File "/home/KEYPRO/jtiai/src/django-workspaces/keycom/django-trunk/django/db/models/sql/", line 341, in get_aggregation result = query.get_compiler(using).execute_sql(SINGLE)
File "/home/KEYPRO/jtiai/src/django-workspaces/keycom/django-trunk/django/db/models/sql/", line 674, in execute_sql cursor.execute(sql, params)
File "/home/KEYPRO/jtiai/src/django-workspaces/keycom/django-trunk/django/db/backends/", line 22, in execute sql = self.db.ops.last_executed_query(self.cursor, sql, params)
File "/home/KEYPRO/jtiai/src/django-workspaces/keycom/django-trunk/django/db/backends/", line 215, in last_executed_query return smart_unicode(sql) % u_params TypeError: not all arguments converted during string formatting 

Reason is that sql string contains only one parameter placeholder, but u_params tuple contains two:

>>> print sql
>>> print u_params
(u'POLYGON ((3393119.6060000001452863 6673712.9181599998846650, 3393122.0120799997821450 6673712.9181599998846650, 3393122.0120799997821450 6673716.2352799996733665, 3393119.6060000001452863 6673716.2352799996733665, 3393119.6060000001452863 6673712.9181599998846650))', u'anyinteract')

There is also typo, \'mask=anyinteract)\' should be \'mask=anyinteract\')

Change History (1)

comment:1 Changed 7 years ago by jbronn

  • Resolution set to fixed
  • Status changed from new to closed

(In [12300]) 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.

Note: See TracTickets for help on using tickets.
Back to Top