-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refs #26112 -- Fixed aggregate GIS test on Oracle #6041
Conversation
buildbot, test on oracle. |
3rd time was a charm. |
Its true that the sum is not necessary in the test case, as there is no additional grouping. But I came across this bug when trying to do sum over grouped values, using something along the lines of
To cover these situations, the I am not familiar with oracle, does the problem arise because |
There are two problems: The easy one is that on Oracle, unlike other backends, Per the Sum, I was for some reason under the impression that |
Your intuition about For the test to be more explicit, one could also do the following:
I suppose that the query above should also work in oracle as is, without having to override the @shaib sorry for insisting, I guess I still don't understand why the query fails on oracle, hence my question. |
@yellowcap no need to apologize, asking questions is good.
W.r.t. Decimals: Your query would indeed work on Oracle as it is, without overriding the Actually, when I wrote my last comment, I didn't realize the float in question came from the |
@jtiai, can you advise on this? |
At least in Oracle area from multipolygon should result a single, combined area from all polygons in geometry. As a resulting values I think it's precise enough to return floats. In extreme cases when very big polygons would be used it might cause losing a precision but I guess in normal activity that won't be a problem. |
14fb955
to
8acace5
Compare
@claudep @jtiai following advice from @jtiai I changed the While at it, shouldn't we document these field types? |
buildbot, test on Oracle. |
There is no failure in the default test, Jenkins got confused and thought the py2.7/mysql-gis test was cancelled but in fact it was successful. |
@@ -505,6 +509,10 @@ Miscellaneous | |||
argument of the ``render_options()`` method is also removed, making | |||
``selected_choices`` the first argument. | |||
|
|||
* On Oracle/GIS, the :class:`django.contrib.gis.db.models.functions.Area` | |||
aggregate function used to return a ``decimal.Decimal`` value (of square |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"used to" -> "now returns float instead of decimal.Decimal."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Changed to:
now returns float instead of decimal.Decimal
(it is still wrapped in a measure of square meters).
Does the test change sufficiently cover the change? At least a comment in the test seems warranted. |
Comment added. |
Made sure the test doesn't try to aggregate over MultiPolygonField and made AreaField turn decimals into floats on the way from the DB. Thanks Daniel Wiesmann, Jani Tiainen and Tim Graham for review and discussion.
merged in bb51dc9, thanks! |
Thanks for committing, I was sort of waiting for input from the geodjango gurus about making |
Sorry Shai for being unresponsive on this one. I admit that Oracle stuff doesn't thrill me. Making |
@claudep your time is your own and it's certainly your choice where to spend it, no need to apologize there. Thanks for taking a look. |
This fixes the test -- but is it the right fix?
Is it OK in this case that
Sum
still aggregates over (single) records? This aggregation necessitates the unintuitive and expensive (causes a database round-trip per row later)defer()
call.Should the
Area
function be modified to return aFloatField
on Oracle?