Removed deprecated GeoManager from inspectdb/ogrinspect output.
refs ea27e26b09
This commit is contained in:
parent
f2e4c7aca4
commit
b27547f9d1
|
@ -4,7 +4,6 @@ from django.core.management.commands.inspectdb import \
|
|||
|
||||
class Command(InspectDBCommand):
|
||||
db_module = 'django.contrib.gis.db'
|
||||
gis_tables = {}
|
||||
|
||||
def get_field_type(self, connection, table_name, row):
|
||||
field_type, field_params, field_notes = super(Command, self).get_field_type(connection, table_name, row)
|
||||
|
@ -14,18 +13,4 @@ class Command(InspectDBCommand):
|
|||
# from the `get_geometry_type` routine for the spatial backend.
|
||||
field_type, geo_params = connection.introspection.get_geometry_type(table_name, geo_col)
|
||||
field_params.update(geo_params)
|
||||
# Adding the table name and column to the `gis_tables` dictionary, this
|
||||
# allows us to track which tables need a GeoManager.
|
||||
if table_name in self.gis_tables:
|
||||
self.gis_tables[table_name].append(geo_col)
|
||||
else:
|
||||
self.gis_tables[table_name] = [geo_col]
|
||||
return field_type, field_params, field_notes
|
||||
|
||||
def get_meta(self, table_name, constraints):
|
||||
meta_lines = super(Command, self).get_meta(table_name, constraints)
|
||||
if table_name in self.gis_tables:
|
||||
# If the table is a geographic one, then we need make
|
||||
# GeoManager the default manager for the model.
|
||||
meta_lines.insert(0, ' objects = models.GeoManager()')
|
||||
return meta_lines
|
||||
|
|
|
@ -232,7 +232,6 @@ def _ogrinspect(data_source, model_name, geom_name='geom', layer_key=0, srid=Non
|
|||
srid_str = 'srid=%s' % srid
|
||||
|
||||
yield ' %s = models.%s(%s)' % (geom_name, geom_field, srid_str)
|
||||
yield ' objects = models.GeoManager()'
|
||||
|
||||
if name_field:
|
||||
yield ''
|
||||
|
|
|
@ -40,7 +40,6 @@ class InspectDbTests(TestCase):
|
|||
else:
|
||||
self.assertIn('geom = models.GeometryField(', output)
|
||||
self.assertIn('point = models.GeometryField(', output)
|
||||
self.assertIn('objects = models.GeoManager()', output)
|
||||
|
||||
@skipUnlessDBFeature("supports_3d_storage")
|
||||
def test_3d_columns(self):
|
||||
|
@ -59,7 +58,6 @@ class InspectDbTests(TestCase):
|
|||
self.assertIn('point = models.GeometryField(', output)
|
||||
self.assertIn('line = models.GeometryField(', output)
|
||||
self.assertIn('poly = models.GeometryField(', output)
|
||||
self.assertIn('objects = models.GeoManager()', output)
|
||||
|
||||
|
||||
@skipUnless(HAS_GDAL, "OGRInspectTest needs GDAL support")
|
||||
|
@ -82,7 +80,6 @@ class OGRInspectTest(TestCase):
|
|||
' int = models.{}()'.format('BigIntegerField' if GDAL_VERSION >= (2, 0) else 'FloatField'),
|
||||
' str = models.CharField(max_length=80)',
|
||||
' geom = models.PolygonField(srid=-1)',
|
||||
' objects = models.GeoManager()',
|
||||
]
|
||||
|
||||
self.assertEqual(model_def, '\n'.join(expected))
|
||||
|
@ -110,7 +107,6 @@ class OGRInspectTest(TestCase):
|
|||
' density = models.FloatField()',
|
||||
' created = models.DateField()',
|
||||
' geom = models.PointField(srid=-1)',
|
||||
' objects = models.GeoManager()',
|
||||
]
|
||||
|
||||
self.assertEqual(model_def, '\n'.join(expected))
|
||||
|
@ -147,9 +143,8 @@ class OGRInspectTest(TestCase):
|
|||
self.assertIn(' f_char = models.CharField(max_length=10)', model_def)
|
||||
self.assertIn(' f_date = models.DateField()', model_def)
|
||||
|
||||
self.assertIsNotNone(re.search(
|
||||
r' geom = models.PolygonField\(([^\)])*\)\n' # Some backends may have srid=-1
|
||||
r' objects = models.GeoManager\(\)', model_def))
|
||||
# Some backends may have srid=-1
|
||||
self.assertIsNotNone(re.search(r' geom = models.PolygonField\(([^\)])*\)', model_def))
|
||||
|
||||
def test_management_command(self):
|
||||
shp_file = os.path.join(TEST_DATA, 'cities', 'cities.shp')
|
||||
|
|
Loading…
Reference in New Issue