#37236 new Bug

Spatial indexes cannot be added, removed, or altered on RasterField

Reported by: Jacob Walls Owned by:
Component: GIS Version: 6.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

RasterField allows spatial indexes spatial_index=True just like GeometryField, but the support for adding/removing/altering spatial indexes in #35074 only checked GeometryField instead of BaseSpatialField.

For the purposes of testing only, see this diff:

  • tests/gis_tests/gis_migrations/test_operations.py

    diff --git a/tests/gis_tests/gis_migrations/test_operations.py b/tests/gis_tests/gis_migrations/test_operations.py
    index 98201ed3f7..98f327cc2b 100644
    a b class OperationTests(OperationTestCase):  
    281281        if not self.has_spatial_indexes:
    282282            self.skipTest("No support for Spatial indexes")
    283283
    284         self.assertSpatialIndexExists("gis_neighborhood", "geom")
     284        self.assertSpatialIndexExists("gis_neighborhood", "rast", raster=True)
    285285
    286286        self.alter_gis_model(
    287287            migrations.AlterField,
    288288            "Neighborhood",
    289             "geom",
     289            "rast",
    290290            fields.MultiPolygonField,
    291291            field_class_kwargs={"spatial_index": False},
    292292        )
    293         self.assertSpatialIndexNotExists("gis_neighborhood", "geom")
     293        self.assertSpatialIndexNotExists("gis_neighborhood", "rast", raster=True)
    294294
    295295    @skipUnlessDBFeature("can_alter_geometry_field")
    296296    @skipUnless(connection.vendor == "mysql", "MySQL specific test")
======================================================================
FAIL: test_alter_field_remove_spatial_index (gis_tests.gis_migrations.test_operations.OperationTests.test_alter_field_remove_spatial_index)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jwalls/django/tests/gis_tests/gis_migrations/test_operations.py", line 293, in test_alter_field_remove_spatial_index
    self.assertSpatialIndexNotExists("gis_neighborhood", "rast", raster=True)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwalls/django/tests/gis_tests/gis_migrations/test_operations.py", line 99, in assertSpatialIndexNotExists
    self.assertFalse(
    ~~~~~~~~~~~~~~~~^
        any(
        ^^^^
    ...<3 lines>...
        )
        ^
    )
    ^
AssertionError: True is not false

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top