summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/gis_tests/gis_migrations/test_operations.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/gis_tests/gis_migrations/test_operations.py b/tests/gis_tests/gis_migrations/test_operations.py
index 033f2ac5b9..3ecde2025e 100644
--- a/tests/gis_tests/gis_migrations/test_operations.py
+++ b/tests/gis_tests/gis_migrations/test_operations.py
@@ -133,6 +133,24 @@ class OperationTests(OperationTestCase):
if self.has_spatial_indexes:
self.assertSpatialIndexExists("gis_neighborhood", "path")
+ @skipUnless(connection.vendor == "mysql", "MySQL specific test")
+ def test_remove_geom_field_nullable_with_index(self):
+ # MySQL doesn't support spatial indexes on NULL columns.
+ with self.assertNumQueries(1) as ctx:
+ self.alter_gis_model(
+ migrations.AddField,
+ "Neighborhood",
+ "path",
+ fields.LineStringField,
+ field_class_kwargs={"null": True},
+ )
+ self.assertColumnExists("gis_neighborhood", "path")
+ self.assertNotIn("CREATE SPATIAL INDEX", ctx.captured_queries[0]["sql"])
+
+ with self.assertNumQueries(1), self.assertNoLogs("django.contrib.gis", "ERROR"):
+ self.alter_gis_model(migrations.RemoveField, "Neighborhood", "path")
+ self.assertColumnNotExists("gis_neighborhood", "path")
+
@skipUnless(HAS_GEOMETRY_COLUMNS, "Backend doesn't support GeometryColumns.")
def test_geom_col_name(self):
self.assertEqual(