{{{
Traceback (most recent call last):
File "/media/sf_django/django_gis_bug/test_gis_bug/tests.py", line 16,
in test_gis_bug
features.first()
File "/home/alex/.virtualenvs/django_test/local/lib/python2.7/site-
packages/django/db/models/query.py", line 564, in first
objects = list((self if self.ordered else self.order_by('pk'))[:1])
File "/home/alex/.virtualenvs/django_test/local/lib/python2.7/site-
packages/django/db/models/query.py", line 250, in __iter__
self._fetch_all()
File "/home/alex/.virtualenvs/django_test/local/lib/python2.7/site-
packages/django/db/models/query.py", line 1105, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/home/alex/.virtualenvs/django_test/local/lib/python2.7/site-
packages/django/db/models/query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
File "/home/alex/.virtualenvs/django_test/local/lib/python2.7/site-
packages/django/db/models/sql/compiler.py", line 886, in execute_sql
raise original_exception
ProgrammingError: function st_lengthspheroid(geometry, unknown, unknown)
does not exist
LINE 1: ...ug_feature"."id", "test_gis_bug_feature"."shape", ST_LengthS...
^
HINT: No function matches the given name and argument types. You might
need to add explicit type casts.
}}}
\\
It happens on access to the query attribute of the QuerySet class. On
every access an additional parameter gets added to the st_lengthspheroid
function. \\
models.py
{{{
from django.contrib.gis.db import models
class Feature(models.Model):
shape = models.LineStringField()
}}}
\\
to test
{{{
from django.contrib.gis.db.models.functions import Length
from .models import Feature
features = Feature.objects.annotate(length=Length('shape'))
# This action adds an additional parameter to the st_lengthspheroid
# function every time you call the str function on the queryset
str(features.query)
# As a result it raises ProgrammingError, but it must pass without an
error.
features.first()
}}}
I created an app with a test case:
[https://github.com/rafick1983/django_gis_bug]
--
Ticket URL: <https://code.djangoproject.com/ticket/28353>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* stage: Unreviewed => Accepted
* component: Database layer (models, ORM) => GIS
--
Ticket URL: <https://code.djangoproject.com/ticket/28353#comment:1>
* owner: nobody => Sergey Fedoseev
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/28353#comment:2>
Comment (by Sergey Fedoseev):
[https://github.com/django/django/pull/8705 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/28353#comment:3>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"3905cfa1a578275323bfbfbef09f5aee05b33301" 3905cfa1]:
{{{
#!CommitTicketReference repository=""
revision="3905cfa1a578275323bfbfbef09f5aee05b33301"
Fixed #28353 -- Fixed some GIS functions when queryset is evaluated more
than once.
Reverted test for refs #27603 in favor of using FuncTestMixin.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28353#comment:4>