summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnssi Kääriäinen <anssi.kaariainen@thl.fi>2015-04-15 08:46:19 +0300
committerClaude Paroz <claude@2xlibre.net>2015-04-16 09:40:47 +0200
commitfb5c7748daa25a40bfc62834acb5731c71a6b713 (patch)
tree5877111da84c70ab16ff8c22563c5606d80d13f4 /tests
parentbcf700b4e3393d8e72920ae64aa421c5651f8935 (diff)
Fixed #24615 -- ordering by expression not part of SELECT
Fixed queries where an expression was used in order_by() but the expression wasn't in the query's select clause (for example the expression could be masked by .values() call) Thanks to Trac alias MattBlack85 for the report.
Diffstat (limited to 'tests')
-rw-r--r--tests/gis_tests/distapp/tests.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/gis_tests/distapp/tests.py b/tests/gis_tests/distapp/tests.py
index b9ba7e4df8..1889f2d9f9 100644
--- a/tests/gis_tests/distapp/tests.py
+++ b/tests/gis_tests/distapp/tests.py
@@ -1,6 +1,6 @@
from __future__ import unicode_literals
-from django.contrib.gis.geos import HAS_GEOS
+from django.contrib.gis.geos import HAS_GEOS, Point
from django.contrib.gis.measure import D # alias for Distance
from django.db import connection
from django.db.models import Q
@@ -383,3 +383,10 @@ class DistanceTest(TestCase):
z = SouthTexasZipcode.objects.distance(htown.point).area().get(name='78212')
self.assertIsNone(z.distance)
self.assertIsNone(z.area)
+
+ @skipUnlessDBFeature("has_distance_method")
+ def test_distance_order_by(self):
+ qs = SouthTexasCity.objects.distance(Point(3, 3)).order_by(
+ 'distance'
+ ).values_list('name', flat=True).filter(name__in=('San Antonio', 'Pearland'))
+ self.assertQuerysetEqual(qs, ['San Antonio', 'Pearland'], lambda x: x)