diff options
| author | Hannes Ljungberg <hannes@5monkeys.se> | 2020-02-07 22:44:17 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-02-10 11:20:45 +0100 |
| commit | adcf1a73084d005a04ce6ebce9a5cecd42fed812 (patch) | |
| tree | 74d7d1231ab25279502db15e50cc9d0b069d82f5 | |
| parent | 382af9b14113aaa8821da404933c12053bb394fd (diff) | |
Fixed #31248 -- Added missing space before USING SQL on PostGIS.
| -rw-r--r-- | django/contrib/gis/db/backends/postgis/schema.py | 2 | ||||
| -rw-r--r-- | tests/gis_tests/geoapp/test_indexes.py | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/django/contrib/gis/db/backends/postgis/schema.py b/django/contrib/gis/db/backends/postgis/schema.py index 25264f701f..0ca5362231 100644 --- a/django/contrib/gis/db/backends/postgis/schema.py +++ b/django/contrib/gis/db/backends/postgis/schema.py @@ -37,7 +37,7 @@ class PostGISSchemaEditor(DatabaseSchemaEditor): self.sql_create_index, name=self.quote_name('%s_%s_id' % (model._meta.db_table, field.column)), table=self.quote_name(model._meta.db_table), - using='USING %s' % self.geom_index_type, + using=' USING %s' % self.geom_index_type, columns=field_column, extra='', condition='', diff --git a/tests/gis_tests/geoapp/test_indexes.py b/tests/gis_tests/geoapp/test_indexes.py new file mode 100644 index 0000000000..ce6b998794 --- /dev/null +++ b/tests/gis_tests/geoapp/test_indexes.py @@ -0,0 +1,19 @@ +from unittest import skipUnless + +from django.db import connection +from django.db.models import Index +from django.test import TestCase + +from ..utils import postgis +from .models import City + + +class SchemaIndexesTests(TestCase): + @skipUnless(postgis, 'This is a PostGIS-specific test.') + def test_using_sql(self): + index = Index(fields=['point']) + editor = connection.schema_editor() + self.assertIn( + '%s USING ' % editor.quote_name(City._meta.db_table), + str(index.create_sql(City, editor)), + ) |
