Opened 2 years ago

Closed 2 years ago

#27573 closed Bug (fixed)

Distance function returns Distance object instead of raw value on MySQL

Reported by: Sergey Fedoseev Owned by: Sergey Fedoseev
Component: GIS Version: 1.9
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


On MySQL, a raw float value is returned, as it’s not possible to automatically determine the unit of the field.


In [3]: City.objects.annotate(d=Distance('point', Point(0, 0, srid=4326))).first().d
Out[3]: Distance(m=1.41421356237)

I see two ways how to fix it:

  1. made Distance function to return raw values on MySQL
  2. raise NotImplemented if Distance function is applied to geodetic field

Change History (4)

comment:1 Changed 2 years ago by Sergey Fedoseev

Owner: changed from nobody to Sergey Fedoseev
Status: newassigned

comment:2 Changed 2 years ago by Tim Graham

Triage Stage: UnreviewedAccepted

comment:3 Changed 2 years ago by Sergey Fedoseev

Has patch: set

comment:4 Changed 2 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In 898e623:

Fixed #27573 -- Made Distance on geodetic coordinates return a raw value on MySQL.

Note: See TracTickets for help on using tickets.
Back to Top