[1.10.x] Fixed #27014 -- Fixed annotations with database functions on PostGIS.
Thanks Sean Mc Allister for providing a test.
Backport of 89f17e7caf
from master
This commit is contained in:
parent
7d11d61087
commit
201198136d
|
@ -15,7 +15,7 @@ class PostGISAdapter(object):
|
||||||
"""
|
"""
|
||||||
Initialize on the spatial object.
|
Initialize on the spatial object.
|
||||||
"""
|
"""
|
||||||
self.is_geometry = isinstance(obj, Geometry)
|
self.is_geometry = isinstance(obj, (Geometry, PostGISAdapter))
|
||||||
|
|
||||||
# Getting the WKB (in string form, to allow easy pickling of
|
# Getting the WKB (in string form, to allow easy pickling of
|
||||||
# the adaptor) and the SRID from the geometry or raster.
|
# the adaptor) and the SRID from the geometry or raster.
|
||||||
|
|
|
@ -48,3 +48,6 @@ Bugfixes
|
||||||
|
|
||||||
* Fixed ``ClearableFileInput`` to avoid the ``required`` HTML attribute when
|
* Fixed ``ClearableFileInput`` to avoid the ``required`` HTML attribute when
|
||||||
initial data exists (:ticket:`27037`).
|
initial data exists (:ticket:`27037`).
|
||||||
|
|
||||||
|
* Fixed annotations with database functions when combined with lookups on
|
||||||
|
PostGIS (:ticket:`27014`).
|
||||||
|
|
|
@ -144,6 +144,9 @@ class GeographyFunctionTests(TestCase):
|
||||||
qs = Zipcode.objects.annotate(distance=Distance('poly', htown.point))
|
qs = Zipcode.objects.annotate(distance=Distance('poly', htown.point))
|
||||||
for z, ref in zip(qs, ref_dists):
|
for z, ref in zip(qs, ref_dists):
|
||||||
self.assertAlmostEqual(z.distance.m, ref, 2)
|
self.assertAlmostEqual(z.distance.m, ref, 2)
|
||||||
|
# Distance function in combination with a lookup.
|
||||||
|
hzip = Zipcode.objects.get(code='77002')
|
||||||
|
self.assertEqual(qs.get(distance__lte=0), hzip)
|
||||||
|
|
||||||
@skipUnlessDBFeature("has_Area_function", "supports_distance_geodetic")
|
@skipUnlessDBFeature("has_Area_function", "supports_distance_geodetic")
|
||||||
def test_geography_area(self):
|
def test_geography_area(self):
|
||||||
|
|
Loading…
Reference in New Issue