id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 12690 Oracle related lookup query fails in geodjango Jani Tiainen nobody "{{{ 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/service.py"", line 104, in get_by_bounding_box count = qs.count() File ""/home/KEYPRO/jtiai/src/django-workspaces/keycom/django-trunk/django/db/models/query.py"", 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/query.py"", 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/query.py"", 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/query.py"", 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/compiler.py"", line 674, in execute_sql cursor.execute(sql, params) File ""/home/KEYPRO/jtiai/src/django-workspaces/keycom/django-trunk/django/db/backends/util.py"", 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/__init__.py"", 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 'SELECT COUNT(*) FROM ""MYMODEL"" WHERE SDO_RELATE(""MYMODEL"".""GEOMFIELD"", SDO_GEOMETRY(%s, 294914), \'mask=anyinteract)\' = \'TRUE\'' >>> 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\')" closed GIS dev fixed oracle query orm lookup Unreviewed 0 0 0 0 0 0