#28683: Problems with the GIS Length annotation function
(django.contrib.gis.db.models.functions.Length)
--------------------------------------------+------------------------------
               Reporter:  Kordian Kowalski  |          Owner:  nobody
                   Type:  Bug               |         Status:  new
              Component:  GIS               |        Version:  1.11
               Severity:  Normal            |       Keywords:  gis geometry
           Triage Stage:  Unreviewed        |      Has patch:  0
    Needs documentation:  0                 |    Needs tests:  0
Patch needs improvement:  0                 |  Easy pickings:  0
                  UI/UX:  0                 |
--------------------------------------------+------------------------------
 In my use case, I am creating a Prefetch object that includes an
 annotation with the GIS Length function as its base queryset.
 The prefetch object is then being reused in multiple requests.
 Only the first request succeeds, all subsequent requests fail with
 following error messages:
 `django.db.utils.ProgrammingError: function st_length(geography, boolean,
 boolean) does not exist`
 `django.db.utils.ProgrammingError: function st_length(geography, boolean,
 boolean, boolean) does not exist`
 `django.db.utils.ProgrammingError: function st_length(geography, boolean,
 boolean, boolean, boolean) does not exist`
 As you can see, there is an additional boolean value being passed in each
 request.
 I have narrowed down the issue to the following line
 (django/contrib/gis/db/models/functions.py:347) :
 {{{
 def as_postgresql(self, compiler, connection):
     (...)
     self.source_expressions.append(Value(self.spheroid))
 }}}
 The additional boolean seems to be appended to params list every time the
 prefetch object is compiled.
 Also it seems that the problem may be affecting only postgres backends.

 Steps to reproduce:
 - create a model with a `django.contrib.gis.db.models.GeometryField`
 - create a queryset with Length annotation: `qs =
 MyModel.objects.annotate(my_length=Length('geometry'))`
 - run `qs.all()` multiple times, all subsequent requests after the first
 one will fail with the aforementioned message.

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

Reply via email to