1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed #33794 -- Fixed string-casting of GIS queries on PostgreSQL.

Regression in 64c3f049ea.
This commit is contained in:
Claude Paroz 2022-06-21 09:53:44 +02:00 committed by Mariusz Felisiak
parent a0608c4b11
commit de74a74b4b
2 changed files with 9 additions and 1 deletions

View File

@ -42,7 +42,7 @@ class PostGISAdapter:
return hash(self.ewkb)
def __str__(self):
return self.getquoted()
return self.getquoted().decode()
@classmethod
def _fix_polygon(cls, poly):

View File

@ -212,6 +212,14 @@ class GeoModelTest(TestCase):
with self.assertNumQueries(0): # Ensure point isn't deferred.
self.assertIsInstance(cities2[0].point, Point)
def test_gis_query_as_string(self):
"""GIS queries can be represented as strings."""
query = City.objects.filter(point__within=Polygon.from_bbox((0, 0, 2, 2)))
self.assertIn(
connection.ops.quote_name(City._meta.db_table),
str(query.query),
)
def test_dumpdata_loaddata_cycle(self):
"""
Test a dumpdata/loaddata cycle with geographic data.