#31002: Query on annotated spatial fields
---------------------------------+------------------------------------
     Reporter:  VasileiosBouzas  |                    Owner:  nobody
         Type:  Bug              |                   Status:  new
    Component:  GIS              |                  Version:  2.2
     Severity:  Normal           |               Resolution:
     Keywords:                   |             Triage Stage:  Accepted
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+------------------------------------
Changes (by Simon Charette):

 * stage:  Unreviewed => Accepted


Comment:

 Likely caused by our badly defined `Expression/Lookup.as_sql` signature
 where we sometimes return `params` as a `list` and sometimes as a `tuple`.

 Given `Subquery.as_sql` returns them as a tuple, through `Query.as_sql`,
 we likely want to adjust `GISLookup.as_sql` here.

 Could you give the following patch a try Vasileios

 {{{#!diff
 diff --git a/django/contrib/gis/db/models/lookups.py
 b/django/contrib/gis/db/models/lookups.py
 index f2af05d9c1..e9c3fc55dd 100644
 --- a/django/contrib/gis/db/models/lookups.py
 +++ b/django/contrib/gis/db/models/lookups.py
 @@ -75,9 +75,9 @@ class GISLookup(Lookup):
          return connection.ops.gis_operators[self.lookup_name]

      def as_sql(self, compiler, connection):
 -        lhs_sql, sql_params = self.process_lhs(compiler, connection)
 +        lhs_sql, lhs_params = self.process_lhs(compiler, connection)
          rhs_sql, rhs_params = self.process_rhs(compiler, connection)
 -        sql_params.extend(rhs_params)
 +        sql_params = tuple(lhs_params) + tuple(rhs_params)

          template_params = {'lhs': lhs_sql, 'rhs': rhs_sql, 'value': '%s',
 **self.template_params}
          rhs_op = self.get_rhs_op(connection, rhs_sql)
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31002#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.f16ad57db16035e4e16ac816985c18b5%40djangoproject.com.

Reply via email to