mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #32721 -- Fixed migrations crash when adding namespaced spatial indexes on PostGIS.
This commit is contained in:
committed by
Mariusz Felisiak
parent
99bc67a9e7
commit
29345aecf6
@@ -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.')
|
||||
|
||||
Reference in New Issue
Block a user