diff --git django/contrib/gis/db/backends/adapter.py django/contrib/gis/db/backends/adapter.py
index 9766ef0..ca77124 100644
|
|
class WKTAdapter(object):
|
8 | 8 | self.srid = geom.srid |
9 | 9 | |
10 | 10 | def __eq__(self, other): |
| 11 | if not isinstance(other, WKTAdapter): |
| 12 | return False |
11 | 13 | return self.wkt == other.wkt and self.srid == other.srid |
12 | 14 | |
13 | 15 | def __str__(self): |
diff --git django/contrib/gis/db/backends/postgis/adapter.py django/contrib/gis/db/backends/postgis/adapter.py
index 3f8603e..c9b9841 100644
|
|
class PostGISAdapter(object):
|
21 | 21 | raise Exception('Error implementing psycopg2 protocol. Is psycopg2 installed?') |
22 | 22 | |
23 | 23 | def __eq__(self, other): |
| 24 | if not isinstance(other, PostGISAdapter): |
| 25 | return False |
24 | 26 | return (self.ewkb == other.ewkb) and (self.srid == other.srid) |
25 | 27 | |
26 | 28 | def __str__(self): |
diff --git django/contrib/gis/tests/geoapp/test_regress.py django/contrib/gis/tests/geoapp/test_regress.py
index 6b914da..454596e 100644
|
|
|
1 | 1 | import unittest |
2 | 2 | from django.contrib.gis.tests.utils import no_mysql, no_spatialite |
3 | 3 | from django.contrib.gis.shortcuts import render_to_kmz |
4 | | from models import City |
| 4 | from models import City, State |
5 | 5 | |
6 | 6 | class GeoRegressionTests(unittest.TestCase): |
7 | 7 | |
… |
… |
class GeoRegressionTests(unittest.TestCase):
|
35 | 35 | extent = City.objects.filter(name='Pueblo').extent() |
36 | 36 | for ref_val, val in zip(ref_ext, extent): |
37 | 37 | self.assertAlmostEqual(ref_val, val, 4) |
| 38 | |
| 39 | def test04_empty_count(self): |
| 40 | "Testing that PostGISAdapter.__eq__ does check empty strings, see #13670" |
| 41 | # contrived example, but need a geo lookup paired with an id__in lookup |
| 42 | pueblo = City.objects.get(name='Pueblo') |
| 43 | state = State.objects.filter(poly__contains=pueblo.point) |
| 44 | cities_within_state = City.objects.filter(id__in=state) |
| 45 | |
| 46 | # .count() should not throw TypeError in __eq__ |
| 47 | self.assertEqual(cities_within_state.count(), 1) |