Skip to content

Commit

Permalink
[1.10.x] Fixed #27014 -- Fixed annotations with database functions on…
Browse files Browse the repository at this point in the history
… PostGIS.

Thanks Sean Mc Allister for providing a test.

Backport of 89f17e7 from master
  • Loading branch information
yellowcap committed Sep 19, 2016
1 parent 814ae92 commit 59415b7
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django/contrib/gis/db/backends/postgis/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, obj, geography=False):
"""
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
# the adaptor) and the SRID from the geometry or raster.
Expand Down
53 changes: 53 additions & 0 deletions docs/releases/1.10.1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
===========================
Django 1.10.1 release notes
===========================

*Under development*

Django 1.10.1 fixes several bugs in 1.10.

Bugfixes
========

* Fixed a crash in MySQL connections where ``SELECT @@SQL_AUTO_IS_NULL``
doesn't return a result (:ticket:`26991`).

* Allowed ``User.is_authenticated`` and ``User.is_anonymous`` properties to be
compared using ``==`` and ``!=`` (:ticket:`26988`).

* Removed the broken ``BaseCommand.usage()`` method which was for
``optparse`` support (:ticket:`27000`).

* Fixed a checks framework crash with an empty ``Meta.default_permissions``
(:ticket:`26997`).

* Fixed a regression in the number of queries when using ``RadioSelect`` with a
``ModelChoiceField`` form field (:ticket:`27001`).

* Fixed a crash if ``request.META['CONTENT_LENGTH']`` is an empty string
(:ticket:`27005`).

* Fixed the ``isnull`` lookup on a ``ForeignKey`` with its ``to_field``
pointing to a ``CharField`` (:ticket:`26983`).

* Prevented the ``migrate`` command from raising
``InconsistentMigrationHistory`` in the presence of unapplied squashed
migrations (:ticket:`27004`).

* Fixed a regression in ``Client.force_login()`` which required specifying a
``backend`` rather than automatically using the first one if multiple
backends are configured (:ticket:`27027`).

* Made ``QuerySet.bulk_create()`` properly initialize model instances on
backends, such as PostgreSQL, that support returning the IDs of the created
records so that many-to-many relationships can be used on the new objects
(:ticket:`27026`).

* Fixed crash of ``django.views.static.serve()`` with ``show_indexes`` enabled
(:ticket:`26973`).

* Fixed ``ClearableFileInput`` to avoid the ``required`` HTML attribute when
initial data exists (:ticket:`27037`).

* Fixed annotations with database functions when combined with lookups on
PostGIS (:ticket:`27014`).
3 changes: 3 additions & 0 deletions tests/gis_tests/geogapp/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ def test_distance_function(self):
qs = Zipcode.objects.annotate(distance=Distance('poly', htown.point))
for z, ref in zip(qs, ref_dists):
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")
def test_geography_area(self):
Expand Down

0 comments on commit 59415b7

Please sign in to comment.