diff options
author | snowman2 <alansnow21@gmail.com> | 2021-05-13 13:02:31 +0200 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-05-14 07:10:28 +0200 |
commit | 29345aecf6e8d53ccb3577a3762bb0c263f7558d (patch) | |
tree | c424880b887d92557b0d236f8ac574eb86d04641 /tests/gis_tests | |
parent | 99bc67a9e79256d8a2fcd5742e33a5e79c056539 (diff) | |
download | django-29345aecf6e8d53ccb3577a3762bb0c263f7558d.tar.gz |
Fixed #32721 -- Fixed migrations crash when adding namespaced spatial indexes on PostGIS.
Diffstat (limited to 'tests/gis_tests')
-rw-r--r-- | tests/gis_tests/geoapp/test_indexes.py | 26 | ||||
-rw-r--r-- | tests/gis_tests/gis_migrations/test_operations.py | 2 |
2 files changed, 27 insertions, 1 deletions
diff --git a/tests/gis_tests/geoapp/test_indexes.py b/tests/gis_tests/geoapp/test_indexes.py index 4aee5062d8..ce9376d810 100644 --- a/tests/gis_tests/geoapp/test_indexes.py +++ b/tests/gis_tests/geoapp/test_indexes.py @@ -1,6 +1,8 @@ +from django.contrib.gis.db import models from django.db import connection from django.db.models import Index from django.test import TransactionTestCase +from django.test.utils import isolate_apps from .models import City @@ -38,6 +40,30 @@ class SchemaIndexesTests(TransactionTestCase): str(index.create_sql(City, editor)), ) + @isolate_apps('gis_tests.geoapp') + def test_namespaced_db_table(self): + if not connection.ops.postgis: + self.skipTest('PostGIS-specific test.') + + class SchemaCity(models.Model): + point = models.PointField() + + class Meta: + app_label = 'geoapp' + db_table = 'django_schema"."geoapp_schema_city' + + index = Index(fields=['point']) + editor = connection.schema_editor() + create_index_sql = str(index.create_sql(SchemaCity, editor)) + self.assertIn( + '%s USING ' % editor.quote_name(SchemaCity._meta.db_table), + create_index_sql, + ) + self.assertIn( + 'CREATE INDEX "geoapp_schema_city_point_9ed70651_id" ', + create_index_sql, + ) + def test_index_name(self): if not self.has_spatial_indexes(City._meta.db_table): self.skipTest('Spatial indexes in Meta.indexes are not supported.') diff --git a/tests/gis_tests/gis_migrations/test_operations.py b/tests/gis_tests/gis_migrations/test_operations.py index 25d55619ed..6c7adcf359 100644 --- a/tests/gis_tests/gis_migrations/test_operations.py +++ b/tests/gis_tests/gis_migrations/test_operations.py @@ -210,7 +210,7 @@ class OperationTests(OperationTestCase): self.assertSpatialIndexExists('gis_neighborhood', 'point3d') with connection.cursor() as cursor: - index_name = 'gis_neighborhood_point3d_id' + index_name = 'gis_neighborhood_point3d_113bc868_id' cursor.execute(self.get_opclass_query, [index_name]) self.assertEqual( cursor.fetchall(), |