mirror of
https://github.com/django/django.git
synced 2025-04-26 02:04:38 +00:00
Refs #32380 -- Added test for distance lookups with F() expression.
Fixed in 5935a9aeade517aebdceea989467d2b46c44d96f.
This commit is contained in:
parent
2b4b6c8af0
commit
84ad7f3404
@ -29,6 +29,7 @@ class AustraliaCity(NamedModel):
|
|||||||
point = models.PointField()
|
point = models.PointField()
|
||||||
radius = models.IntegerField(default=10000)
|
radius = models.IntegerField(default=10000)
|
||||||
allowed_distance = models.FloatField(default=0.5)
|
allowed_distance = models.FloatField(default=0.5)
|
||||||
|
ref_point = models.PointField(null=True)
|
||||||
|
|
||||||
|
|
||||||
class CensusZipcode(NamedModel):
|
class CensusZipcode(NamedModel):
|
||||||
|
@ -204,8 +204,10 @@ class DistanceTest(TestCase):
|
|||||||
# With spheroid param
|
# With spheroid param
|
||||||
if connection.features.supports_distance_geodetic:
|
if connection.features.supports_distance_geodetic:
|
||||||
hobart = AustraliaCity.objects.get(name='Hobart')
|
hobart = AustraliaCity.objects.get(name='Hobart')
|
||||||
|
AustraliaCity.objects.update(ref_point=hobart.point)
|
||||||
|
for ref_point in [hobart.point, F('ref_point')]:
|
||||||
qs = AustraliaCity.objects.filter(
|
qs = AustraliaCity.objects.filter(
|
||||||
point__distance_lte=(hobart.point, F('radius') * 70, 'spheroid'),
|
point__distance_lte=(ref_point, F('radius') * 70, 'spheroid'),
|
||||||
).order_by('name')
|
).order_by('name')
|
||||||
self.assertEqual(self.get_names(qs), ['Canberra', 'Hobart', 'Melbourne'])
|
self.assertEqual(self.get_names(qs), ['Canberra', 'Hobart', 'Melbourne'])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user