Commit 6c1a0581 authored by Tim Graham's avatar Tim Graham
Browse files

Added a feature flag for add_srs_entry support; refs #22632 and #23504.

parent d8ee1378
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@ class BaseSpatialFeatures(object):
    # Does the database contain a SpatialRefSys model to store SRID information?
    has_spatialrefsys_table = True

    # Does the backend support the django.contrib.gis.utils.add_srs_entry() utility?
    supports_add_srs_entry = True

    # Reference implementation of 3D functions is:
    # http://postgis.net/docs/PostGIS_Special_Functions_Index.html#PostGIS_3D_Functions
    supports_3d_functions = False
+1 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ from django.contrib.gis.db.backends.mysql.operations import MySQLOperations

class DatabaseFeatures(BaseSpatialFeatures, MySQLDatabaseFeatures):
    has_spatialrefsys_table = False
    supports_add_srs_entry = False
    supports_distances_lookups = False
    supports_transform = False
    supports_real_shape_operations = False
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ from django.contrib.gis.db.backends.oracle.operations import OracleOperations


class DatabaseFeatures(BaseSpatialFeatures, OracleDatabaseFeatures):
    pass
    supports_add_srs_entry = False


class DatabaseWrapper(OracleDatabaseWrapper):
+1 −0
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ class SpatialRefSysTest(unittest.TestCase):
            for i in range(3):
                self.assertAlmostEqual(ellps1[i], ellps2[i], prec[i])

    @skipUnlessDBFeature('supports_add_srs_entry')
    def test_add_entry(self):
        """
        Test adding a new entry in the SpatialRefSys model using the
+2 −3
Original line number Diff line number Diff line
@@ -39,9 +39,8 @@ def add_srs_entry(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None,
    if not hasattr(connection.ops, 'spatial_version'):
        raise Exception('The `add_srs_entry` utility only works '
                        'with spatial backends.')
    if connection.ops.oracle or connection.ops.mysql:
        raise Exception('This utility does not support the '
                        'Oracle or MySQL spatial backends.')
    if not connection.features.supports_add_srs_entry:
        raise Exception('This utility does not support your database backend.')
    SpatialRefSys = connection.ops.spatial_ref_sys()

    # If argument is not a `SpatialReference` instance, use it as parameter