Refs #16455 -- Added test for using opclasses on indexes for multidimensional geometry fields on PostGIS.
This commit is contained in:
parent
820408d842
commit
c6d88a1872
|
@ -19,6 +19,12 @@ except NotImplementedError:
|
||||||
|
|
||||||
class OperationTestCase(TransactionTestCase):
|
class OperationTestCase(TransactionTestCase):
|
||||||
available_apps = ['gis_tests.gis_migrations']
|
available_apps = ['gis_tests.gis_migrations']
|
||||||
|
get_opclass_query = '''
|
||||||
|
SELECT opcname, c.relname FROM pg_opclass AS oc
|
||||||
|
JOIN pg_index as i on oc.oid = ANY(i.indclass)
|
||||||
|
JOIN pg_class as c on c.oid = i.indexrelid
|
||||||
|
WHERE c.relname = %s
|
||||||
|
'''
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
# Delete table after testing
|
# Delete table after testing
|
||||||
|
@ -188,6 +194,29 @@ class OperationTests(OperationTestCase):
|
||||||
if connection.features.supports_raster:
|
if connection.features.supports_raster:
|
||||||
self.assertSpatialIndexExists('gis_neighborhood', 'rast', raster=True)
|
self.assertSpatialIndexExists('gis_neighborhood', 'rast', raster=True)
|
||||||
|
|
||||||
|
@skipUnlessDBFeature('supports_3d_storage')
|
||||||
|
def test_add_3d_field_opclass(self):
|
||||||
|
if not connection.ops.postgis:
|
||||||
|
self.skipTest('PostGIS-specific test.')
|
||||||
|
|
||||||
|
self.alter_gis_model(
|
||||||
|
migrations.AddField,
|
||||||
|
'Neighborhood',
|
||||||
|
'point3d',
|
||||||
|
field_class=fields.PointField,
|
||||||
|
field_class_kwargs={'dim': 3},
|
||||||
|
)
|
||||||
|
self.assertColumnExists('gis_neighborhood', 'point3d')
|
||||||
|
self.assertSpatialIndexExists('gis_neighborhood', 'point3d')
|
||||||
|
|
||||||
|
with connection.cursor() as cursor:
|
||||||
|
index_name = 'gis_neighborhood_point3d_id'
|
||||||
|
cursor.execute(self.get_opclass_query, [index_name])
|
||||||
|
self.assertEqual(
|
||||||
|
cursor.fetchall(),
|
||||||
|
[('gist_geometry_ops_nd', index_name)],
|
||||||
|
)
|
||||||
|
|
||||||
@skipUnlessDBFeature('can_alter_geometry_field', 'supports_3d_storage')
|
@skipUnlessDBFeature('can_alter_geometry_field', 'supports_3d_storage')
|
||||||
def test_alter_geom_field_dim(self):
|
def test_alter_geom_field_dim(self):
|
||||||
Neighborhood = self.current_state.apps.get_model('gis', 'Neighborhood')
|
Neighborhood = self.current_state.apps.get_model('gis', 'Neighborhood')
|
||||||
|
|
Loading…
Reference in New Issue