Opened 9 years ago
Closed 9 years ago
#26112 closed Bug (fixed)
Aggregate Sum of GIS Aggregates fails
Reported by: | Daniel Wiesmann | Owned by: | Daniel Wiesmann |
---|---|---|---|
Component: | GIS | Version: | dev |
Severity: | Normal | Keywords: | aggregates |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
There is an error when trying to compute a regular aggregate value from a GIS Area 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 Country.objects.annotate(areasum=Sum(Area('mpoly')))
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.
Change History (11)
comment:1 by , 9 years ago
Description: | modified (diff) |
---|
comment:2 by , 9 years ago
Description: | modified (diff) |
---|
comment:3 by , 9 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 9 years ago
Patch needs improvement: | set |
---|
comment:5 by , 9 years ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
Version: | 1.9 → master |
comment:7 by , 9 years ago
Has patch: | unset |
---|---|
Resolution: | fixed |
Status: | closed → new |
Triage Stage: | Ready for checkin → Accepted |
The new test fails on Oracle:
File "/home/tim/code/django/tests/gis_tests/geoapp/test_functions.py", line 243, in test_area_with_regular_aggregate for c in qs: ... ORA-22901: cannot compare VARRAY or LOB attributes of an object type
comment:9 by , 9 years ago
Has patch: | set |
---|
When I submitted the PR I was doubtful about it being the right solution, but now I've convinced myself that it is.
comment:11 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
PR