summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndrew Brown <brownan@gmail.com>2019-08-07 12:54:40 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-08-16 06:50:33 +0200
commit8a281aa7fe76a9da2284f943964a9413697cff1f (patch)
treeac0de078a534bee0635a799eee1eaa045cd74480 /tests
parent8289fc55fff879df273cb95fdd1b039447f85783 (diff)
Fixed #30687 -- Fixed using of OuterRef() expressions in distance lookups.
Diffstat (limited to 'tests')
-rw-r--r--tests/gis_tests/distapp/tests.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/gis_tests/distapp/tests.py b/tests/gis_tests/distapp/tests.py
index 67558582dc..d84e829868 100644
--- a/tests/gis_tests/distapp/tests.py
+++ b/tests/gis_tests/distapp/tests.py
@@ -6,7 +6,7 @@ from django.contrib.gis.db.models.functions import (
from django.contrib.gis.geos import GEOSGeometry, LineString, Point
from django.contrib.gis.measure import D # alias for Distance
from django.db import NotSupportedError, connection
-from django.db.models import F, Q
+from django.db.models import Exists, F, OuterRef, Q
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from ..utils import (
@@ -224,6 +224,16 @@ class DistanceTest(TestCase):
with self.assertRaisesMessage(ValueError, msg):
AustraliaCity.objects.filter(point__distance_lte=(Point(0, 0), D(m=100))).exists()
+ @skipUnlessDBFeature('supports_dwithin_lookup')
+ def test_dwithin_subquery(self):
+ """dwithin lookup in a subquery using OuterRef as a parameter."""
+ qs = CensusZipcode.objects.annotate(
+ annotated_value=Exists(SouthTexasCity.objects.filter(
+ point__dwithin=(OuterRef('poly'), D(m=10)),
+ ))
+ ).filter(annotated_value=True)
+ self.assertEqual(self.get_names(qs), ['77002', '77025', '77401'])
+
'''
=============================