1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Added DatabaseFeatures.can_alter_geometry_field.

This commit is contained in:
Tim Graham 2020-10-19 06:41:52 -04:00 committed by GitHub
parent c7c7615d00
commit 0eee5c1b9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View File

@ -46,6 +46,9 @@ class BaseSpatialFeatures:
# Does the database support a unique index on geometry fields?
supports_geometry_field_unique_index = True
# Can SchemaEditor alter geometry fields?
can_alter_geometry_field = True
@property
def supports_bbcontains_lookup(self):
return 'bbcontains' in self.connection.ops.gis_operators

View File

@ -6,6 +6,7 @@ from django.utils.functional import cached_property
class DatabaseFeatures(BaseSpatialFeatures, SQLiteDatabaseFeatures):
can_alter_geometry_field = False # Not implemented
supports_3d_storage = True
@cached_property

View File

@ -1,4 +1,4 @@
from unittest import skipIf, skipUnless
from unittest import skipUnless
from django.contrib.gis.db.models import fields
from django.contrib.gis.geos import MultiPolygon, Polygon
@ -10,7 +10,7 @@ from django.test import (
TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature,
)
from ..utils import mysql, oracle, spatialite
from ..utils import mysql, oracle
try:
GeometryColumns = connection.ops.geometry_columns()
@ -190,8 +190,7 @@ class OperationTests(OperationTestCase):
if connection.features.supports_raster:
self.assertSpatialIndexExists('gis_neighborhood', 'rast', raster=True)
@skipUnlessDBFeature("supports_3d_storage")
@skipIf(spatialite, "Django currently doesn't support altering Spatialite geometry fields")
@skipUnlessDBFeature('can_alter_geometry_field', 'supports_3d_storage')
def test_alter_geom_field_dim(self):
Neighborhood = self.current_state.apps.get_model('gis', 'Neighborhood')
p1 = Polygon(((0, 0), (0, 1), (1, 1), (1, 0), (0, 0)))