Skip to content

Commit

Permalink
Refs #28643 -- Skipped ATan2() workaround on SpatiaLite 5+.
Browse files Browse the repository at this point in the history
  • Loading branch information
ngnpope authored and timgraham committed Nov 30, 2018
1 parent 0d724ce commit c3bbf1f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions django/db/models/functions/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ class ATan2(OutputFieldMixin, Func):
arity = 2

def as_sqlite(self, compiler, connection, **extra_context):
if not getattr(connection.ops, 'spatialite', False) or connection.ops.spatial_version < (4, 3, 0):
if not getattr(connection.ops, 'spatialite', False) or not (
(4, 3, 0) <= connection.ops.spatial_version < (5, 0, 0)
):
return self.as_sql(compiler, connection)
# This function is usually ATan2(y, x), returning the inverse tangent
# of y / x, but it's ATan2(x, y) on SpatiaLite 4.3+.
# of y / x, but it's ATan2(x, y) on SpatiaLite >= 4.3.0, < 5.0.0.
# Cast integers to float to avoid inconsistent/buggy behavior if the
# arguments are mixed between integer and float or decimal.
# https://www.gaia-gis.it/fossil/libspatialite/tktview?name=0f72cca3a2
Expand Down

0 comments on commit c3bbf1f

Please sign in to comment.