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:42:42 +0200
commit70ff455a35066a1b6e2db03f211f56c7b38285eb (patch)
tree3f8debc69b22f2db6f6a84109fd803a6d2661afe /tests
parentc38d8f0f871e3117c1f8f32d87f3b135b7891412 (diff)
[1.8.x] 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. Backport of fb5c7748da from master.
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)