From 65793d714ca6b03d2cd0fcfeec54652396f7ab48 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sat, 15 Sep 2012 11:56:39 +0200 Subject: [PATCH] Used ST_AsText for testing PostGIS raw query AsText will not be supported in further versions of PostGIS (>=2). --- django/contrib/gis/tests/geoapp/tests.py | 3 ++- docs/ref/contrib/gis/tutorial.txt | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/django/contrib/gis/tests/geoapp/tests.py b/django/contrib/gis/tests/geoapp/tests.py index fbe30e8841..cd3cec3074 100644 --- a/django/contrib/gis/tests/geoapp/tests.py +++ b/django/contrib/gis/tests/geoapp/tests.py @@ -191,7 +191,8 @@ class GeoModelTest(TestCase): cities1 = City.objects.all() # Only PostGIS would support a 'select *' query because of its recognized # HEXEWKB format for geometry fields - cities2 = City.objects.raw('select id, name, asText(point) from geoapp_city') + as_text = 'ST_AsText' if postgis else 'asText' + cities2 = City.objects.raw('select id, name, %s(point) from geoapp_city' % as_text) self.assertEqual(len(cities1), len(list(cities2))) self.assertTrue(isinstance(cities2[0].point, Point)) diff --git a/docs/ref/contrib/gis/tutorial.txt b/docs/ref/contrib/gis/tutorial.txt index 15863aee7b..ec265342b3 100644 --- a/docs/ref/contrib/gis/tutorial.txt +++ b/docs/ref/contrib/gis/tutorial.txt @@ -674,8 +674,8 @@ __ http://spatialreference.org/ref/epsg/32140/ .. admonition:: Raw queries When using :doc:`raw queries `, you should generally wrap - your geometry fields with the ``asText()`` SQL function so as the field - value will be recognized by GEOS:: + your geometry fields with the ``asText()`` SQL function (or ``ST_AsText`` + for PostGIS) so as the field value will be recognized by GEOS:: City.objects.raw('SELECT id, name, asText(point) from myapp_city')