#26112: Aggregate Sum of GIS Aggregates fails
----------------------------+------------------------
     Reporter:  yellowcap   |      Owner:  yellowcap
         Type:  Bug         |     Status:  new
    Component:  GIS         |    Version:  1.9
     Severity:  Normal      |   Keywords:  aggregates
 Triage Stage:  Unreviewed  |  Has patch:  1
Easy pickings:  0           |      UI/UX:  0
----------------------------+------------------------
 There is an error when trying to compute a regular aggregate value from  a
 GIS aggregate output. To take an example from the GIS geoapp tests, the
 following query fails.

 {{{
 from django.db.models import Sum
 from django.contrib.gis.db.models.functions import Area, Intersection

 Country.objects.annotate(intersum=Sum(Area(Intersection('mpoly', geom))))
 }}}

 I tracked this down to the `from_db_value` function in the GeometryField
 class here:

 
https://github.com/django/django/blob/master/django/contrib/gis/db/models/fields.py#L259

 The problem seems to be that the `Area` function returns a float, but the
 field is expecting a value that can be converted to a Geometry.

 I'll open a pull request with a regression test and a proposed solution,
 basically checking if the value is a float or int.

--
Ticket URL: <https://code.djangoproject.com/ticket/26112>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.bb47a87ec6e8e9bafa82c38d9e28df5f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to