Skip to content

Commit

Permalink
Gave unique names to SpatialRefSysModels.
Browse files Browse the repository at this point in the history
Prevented clashes in the app registry.

Fixed #22790. Thanks timo for the report.
  • Loading branch information
aaugustin committed Jun 8, 2014
1 parent d8f6b55 commit 6e5651e
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion django/contrib/gis/db/backends/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Base/mixin classes for the spatial backend database operations and the
`SpatialRefSys` model the backend.
`<Backend>SpatialRefSys` model.
"""
import re

Expand Down
6 changes: 4 additions & 2 deletions django/contrib/gis/db/backends/oracle/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@


@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)
srid = models.IntegerField(primary_key=True)
# TODO: Add support for `diminfo` column (type MDSYS.SDO_DIM_ARRAY).

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

Expand All @@ -44,7 +45,7 @@ def __str__(self):
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)
Expand All @@ -57,6 +58,7 @@ class SpatialRefSys(models.Model, SpatialRefSysMixin):
objects = models.GeoManager()

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

Expand Down
8 changes: 4 additions & 4 deletions django/contrib/gis/db/backends/oracle/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,12 @@ def spatial_aggregate_sql(self, agg):

# 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
Expand Down
4 changes: 2 additions & 2 deletions django/contrib/gis/db/backends/postgis/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


@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.
Expand Down Expand Up @@ -47,7 +47,7 @@ def __str__(self):
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.
Expand Down
6 changes: 3 additions & 3 deletions django/contrib/gis/db/backends/postgis/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
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 ####
Expand Down Expand Up @@ -571,7 +571,7 @@ def spatial_aggregate_sql(self, agg):

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

def spatial_ref_sys(self):
return SpatialRefSys
return PostGISSpatialRefSys
6 changes: 4 additions & 2 deletions django/contrib/gis/db/backends/spatialite/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


@python_2_unicode_compatible
class GeometryColumns(models.Model):
class SpatialiteGeometryColumns(models.Model):
"""
The 'geometry_columns' table from SpatiaLite.
"""
Expand All @@ -19,6 +19,7 @@ class GeometryColumns(models.Model):
spatial_index_enabled = models.IntegerField()

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

Expand All @@ -44,7 +45,7 @@ def __str__(self):
self.coord_dimension, self.type, self.srid)


class SpatialRefSys(models.Model, SpatialRefSysMixin):
class SpatialiteSpatialRefSys(models.Model, SpatialRefSysMixin):
"""
The 'spatial_ref_sys' table from SpatiaLite.
"""
Expand All @@ -64,5 +65,6 @@ def wkt(self):
return SpatialReference(self.proj4text).wkt

class Meta:
app_label = 'gis'
db_table = 'spatial_ref_sys'
managed = False
8 changes: 4 additions & 4 deletions django/contrib/gis/db/backends/spatialite/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,9 @@ def spatial_lookup_sql(self, lvalue, lookup_type, value, field, qn):

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

def spatial_ref_sys(self):
from django.contrib.gis.db.backends.spatialite.models import SpatialRefSys
return SpatialRefSys
from django.contrib.gis.db.backends.spatialite.models import SpatialiteSpatialRefSys
return SpatialiteSpatialRefSys
6 changes: 3 additions & 3 deletions django/contrib/gis/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ def no_spatialite(func):

HAS_SPATIALREFSYS = True
if oracle and 'gis' in settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE']:
from django.contrib.gis.db.backends.oracle.models import SpatialRefSys
from django.contrib.gis.db.backends.oracle.models import OracleSpatialRefSys as SpatialRefSys
elif postgis:
from django.contrib.gis.db.backends.postgis.models import SpatialRefSys
from django.contrib.gis.db.backends.postgis.models import PostGISSpatialRefSys as SpatialRefSys
elif spatialite:
from django.contrib.gis.db.backends.spatialite.models import SpatialRefSys
from django.contrib.gis.db.backends.spatialite.models import SpatialiteSpatialRefSys as SpatialRefSys
else:
HAS_SPATIALREFSYS = False
SpatialRefSys = None
Expand Down

0 comments on commit 6e5651e

Please sign in to comment.