From 33e817a6d8b163aa6e8a2fb15d7269d1ecbbcf59 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 17 Sep 2014 17:58:20 -0400 Subject: [PATCH] Added feature flag for geometry_field_introspection; refs #22632 and #23504. --- django/contrib/gis/db/backends/base.py | 2 ++ django/contrib/gis/db/backends/oracle/base.py | 1 + django/contrib/gis/tests/inspectapp/tests.py | 10 +++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/django/contrib/gis/db/backends/base.py b/django/contrib/gis/db/backends/base.py index 570d0a5bae..a132e80661 100644 --- a/django/contrib/gis/db/backends/base.py +++ b/django/contrib/gis/db/backends/base.py @@ -18,6 +18,8 @@ class BaseSpatialFeatures(object): # Does the backend support the django.contrib.gis.utils.add_srs_entry() utility? supports_add_srs_entry = True + # Does the backend introspect GeometryField to its subtypes? + supports_geometry_field_introspection = True # Reference implementation of 3D functions is: # http://postgis.net/docs/PostGIS_Special_Functions_Index.html#PostGIS_3D_Functions diff --git a/django/contrib/gis/db/backends/oracle/base.py b/django/contrib/gis/db/backends/oracle/base.py index eaa1ebebe7..c1b48bccfa 100644 --- a/django/contrib/gis/db/backends/oracle/base.py +++ b/django/contrib/gis/db/backends/oracle/base.py @@ -10,6 +10,7 @@ from django.contrib.gis.db.backends.oracle.operations import OracleOperations class DatabaseFeatures(BaseSpatialFeatures, OracleDatabaseFeatures): supports_add_srs_entry = False + supports_geometry_field_introspection = False class DatabaseWrapper(OracleDatabaseWrapper): diff --git a/django/contrib/gis/tests/inspectapp/tests.py b/django/contrib/gis/tests/inspectapp/tests.py index 04da3c4de8..cf64cee071 100644 --- a/django/contrib/gis/tests/inspectapp/tests.py +++ b/django/contrib/gis/tests/inspectapp/tests.py @@ -5,7 +5,7 @@ import re from unittest import skipUnless from django.core.management import call_command -from django.db import connections +from django.db import connection, connections from django.test import TestCase, skipUnlessDBFeature from django.contrib.gis.gdal import HAS_GDAL from django.contrib.gis.geometry.test_data import TEST_DATA @@ -30,8 +30,12 @@ class InspectDbTests(TestCase): table_name_filter=lambda tn: tn.startswith('inspectapp_'), stdout=out) output = out.getvalue() - self.assertIn('geom = models.PolygonField()', output) - self.assertIn('point = models.PointField()', output) + if connection.features.supports_geometry_field_introspection: + self.assertIn('geom = models.PolygonField()', output) + self.assertIn('point = models.PointField()', output) + else: + self.assertIn('geom = models.GeometryField(', output) + self.assertIn('point = models.GeometryField(', output) self.assertIn('objects = models.GeoManager()', output)