Commit 6e5651e5 authored by Aymeric Augustin's avatar Aymeric Augustin
Browse files

Gave unique names to SpatialRefSysModels.

Prevented clashes in the app registry.

Fixed #22790. Thanks timo for the report.
parent d8f6b55a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
"""
Base/mixin classes for the spatial backend database operations and the
`SpatialRefSys` model the backend.
`<Backend>SpatialRefSys` model.
"""
import re

+4 −2
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ from django.utils.encoding import python_2_unicode_compatible


@python_2_unicode_compatible
class GeometryColumns(models.Model):
class OracleGeometryColumns(models.Model):
    "Maps to the Oracle USER_SDO_GEOM_METADATA table."
    table_name = models.CharField(max_length=32)
    column_name = models.CharField(max_length=1024)
@@ -21,6 +21,7 @@ class GeometryColumns(models.Model):
    # TODO: Add support for `diminfo` column (type MDSYS.SDO_DIM_ARRAY).

    class Meta:
        app_label = 'gis'
        db_table = 'USER_SDO_GEOM_METADATA'
        managed = False

@@ -44,7 +45,7 @@ class GeometryColumns(models.Model):
        return '%s - %s (SRID: %s)' % (self.table_name, self.column_name, self.srid)


class SpatialRefSys(models.Model, SpatialRefSysMixin):
class OracleSpatialRefSys(models.Model, SpatialRefSysMixin):
    "Maps to the Oracle MDSYS.CS_SRS table."
    cs_name = models.CharField(max_length=68)
    srid = models.IntegerField(primary_key=True)
@@ -57,6 +58,7 @@ class SpatialRefSys(models.Model, SpatialRefSysMixin):
    objects = models.GeoManager()

    class Meta:
        app_label = 'gis'
        db_table = 'CS_SRS'
        managed = False

+4 −4
Original line number Diff line number Diff line
@@ -289,12 +289,12 @@ class OracleOperations(DatabaseOperations, BaseSpatialOperations):

    # Routines for getting the OGC-compliant models.
    def geometry_columns(self):
        from django.contrib.gis.db.backends.oracle.models import GeometryColumns
        return GeometryColumns
        from django.contrib.gis.db.backends.oracle.models import OracleGeometryColumns
        return OracleGeometryColumns

    def spatial_ref_sys(self):
        from django.contrib.gis.db.backends.oracle.models import SpatialRefSys
        return SpatialRefSys
        from django.contrib.gis.db.backends.oracle.models import OracleSpatialRefSys
        return OracleSpatialRefSys

    def modify_insert_params(self, placeholders, params):
        """Drop out insert parameters for NULL placeholder. Needed for Oracle Spatial
+2 −2
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ from django.utils.encoding import python_2_unicode_compatible


@python_2_unicode_compatible
class GeometryColumns(models.Model):
class PostGISGeometryColumns(models.Model):
    """
    The 'geometry_columns' table from the PostGIS. See the PostGIS
    documentation at Ch. 4.2.2.
@@ -47,7 +47,7 @@ class GeometryColumns(models.Model):
                self.coord_dimension, self.type, self.srid)


class SpatialRefSys(models.Model, SpatialRefSysMixin):
class PostGISSpatialRefSys(models.Model, SpatialRefSysMixin):
    """
    The 'spatial_ref_sys' table from PostGIS. See the PostGIS
    documentaiton at Ch. 4.2.1.
+3 −3
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ from django.db.utils import ProgrammingError
from django.utils import six
from django.utils.functional import cached_property

from .models import GeometryColumns, SpatialRefSys
from .models import PostGISGeometryColumns, PostGISSpatialRefSys


#### Classes used in constructing PostGIS spatial SQL ####
@@ -571,7 +571,7 @@ class PostGISOperations(DatabaseOperations, BaseSpatialOperations):

    # Routines for getting the OGC-compliant models.
    def geometry_columns(self):
        return GeometryColumns
        return PostGISGeometryColumns

    def spatial_ref_sys(self):
        return SpatialRefSys
        return PostGISSpatialRefSys
Loading