Skip to content

Commit 59415b7

Browse files
committed
[1.10.x] Fixed #27014 -- Fixed annotations with database functions on PostGIS.
Thanks Sean Mc Allister for providing a test. Backport of 89f17e7 from master
1 parent 814ae92 commit 59415b7

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

django/contrib/gis/db/backends/postgis/adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def __init__(self, obj, geography=False):
1515
"""
1616
Initialize on the spatial object.
1717
"""
18-
self.is_geometry = isinstance(obj, Geometry)
18+
self.is_geometry = isinstance(obj, (Geometry, PostGISAdapter))
1919

2020
# Getting the WKB (in string form, to allow easy pickling of
2121
# the adaptor) and the SRID from the geometry or raster.

docs/releases/1.10.1.txt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
===========================
2+
Django 1.10.1 release notes
3+
===========================
4+
5+
*Under development*
6+
7+
Django 1.10.1 fixes several bugs in 1.10.
8+
9+
Bugfixes
10+
========
11+
12+
* Fixed a crash in MySQL connections where ``SELECT @@SQL_AUTO_IS_NULL``
13+
doesn't return a result (:ticket:`26991`).
14+
15+
* Allowed ``User.is_authenticated`` and ``User.is_anonymous`` properties to be
16+
compared using ``==`` and ``!=`` (:ticket:`26988`).
17+
18+
* Removed the broken ``BaseCommand.usage()`` method which was for
19+
``optparse`` support (:ticket:`27000`).
20+
21+
* Fixed a checks framework crash with an empty ``Meta.default_permissions``
22+
(:ticket:`26997`).
23+
24+
* Fixed a regression in the number of queries when using ``RadioSelect`` with a
25+
``ModelChoiceField`` form field (:ticket:`27001`).
26+
27+
* Fixed a crash if ``request.META['CONTENT_LENGTH']`` is an empty string
28+
(:ticket:`27005`).
29+
30+
* Fixed the ``isnull`` lookup on a ``ForeignKey`` with its ``to_field``
31+
pointing to a ``CharField`` (:ticket:`26983`).
32+
33+
* Prevented the ``migrate`` command from raising
34+
``InconsistentMigrationHistory`` in the presence of unapplied squashed
35+
migrations (:ticket:`27004`).
36+
37+
* Fixed a regression in ``Client.force_login()`` which required specifying a
38+
``backend`` rather than automatically using the first one if multiple
39+
backends are configured (:ticket:`27027`).
40+
41+
* Made ``QuerySet.bulk_create()`` properly initialize model instances on
42+
backends, such as PostgreSQL, that support returning the IDs of the created
43+
records so that many-to-many relationships can be used on the new objects
44+
(:ticket:`27026`).
45+
46+
* Fixed crash of ``django.views.static.serve()`` with ``show_indexes`` enabled
47+
(:ticket:`26973`).
48+
49+
* Fixed ``ClearableFileInput`` to avoid the ``required`` HTML attribute when
50+
initial data exists (:ticket:`27037`).
51+
52+
* Fixed annotations with database functions when combined with lookups on
53+
PostGIS (:ticket:`27014`).

tests/gis_tests/geogapp/tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ def test_distance_function(self):
123123
qs = Zipcode.objects.annotate(distance=Distance('poly', htown.point))
124124
for z, ref in zip(qs, ref_dists):
125125
self.assertAlmostEqual(z.distance.m, ref, 2)
126+
# Distance function in combination with a lookup.
127+
hzip = Zipcode.objects.get(code='77002')
128+
self.assertEqual(qs.get(distance__lte=0), hzip)
126129

127130
@skipUnlessDBFeature("has_Area_function", "supports_distance_geodetic")
128131
def test_geography_area(self):

0 commit comments

Comments
 (0)