#27529: Geographic database functions with two parameters should accept 
expressions
in one or the other arguments
-------------------------------------+-------------------------------------
               Reporter:  Antoine    |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  GIS        |        Version:  1.10
               Severity:  Normal     |       Keywords:  gis geographic
           Triage Stage:             |  queryset
  Unreviewed                         |      Has patch:  0
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 == Context
 With the release of Django 1.9 database functions were introduced to
 simplify measurements, operations, lookups, etc. within the queryset.

 Some of the functions introduced take two arguments : `Difference`,
 `Distance`, `Intersection`, `SymDifference` and `Union`.
 The doc [#point1 (1)] states these functions "Accepts two geographic
 fields or expressions and returns the distance between them".

 == Problem
 As they all inherit from `GeoFuncWithGeoParam` [#point2 (2)], they
 actually expect `expr1` to be an expression (column or value), and `expr2`
 to be a `GEOSGeometry` object, despite stated otherwise.

 If an expression is passed as `expr2`, this error is raised :
 {{{
 In [0]: MyClass.objects.annotate(distance=Distance('field1', 'field2'))

 [...]

 ValueError: Please provide a geometry attribute with a defined SRID.
 }}}

 == Solutions
 1. Edit the doc to mention these limitations
 2. (much better) Fix the code to accept expressions in `expr2` as
 documented (and `GEOSGeometry` objects as expr1). Most of the backends
 support geographic measurements and operations between two fields, so
 there is not much to change.

 Happy to work on a patch if the bug is validated.

 [=#point1 (1)]
 https://docs.djangoproject.com/en/dev/ref/contrib/gis/functions/#distance
 [=#point2 (2)]
 
https://github.com/django/django/blob/1.9/django/contrib/gis/db/models/functions.py#L91

--
Ticket URL: <https://code.djangoproject.com/ticket/27529>
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/051.4e18a0cd7a4551df029c17c2a2c864c7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to