diff options
| author | Mads Jensen <mje@inducks.org> | 2017-03-17 19:01:25 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-03-18 08:48:17 -0400 |
| commit | 0b93a992e50ebe455e46d261cb6a741bba1ad76e (patch) | |
| tree | e5259e71e89113968c32102133d28c42e50f6c68 /tests/postgres_tests | |
| parent | c548dba428d8eed290846235d1aef4c92c0d7b60 (diff) | |
[1.11.x] Fixed #27935 -- Fixed crash with BrinIndex name > 30 characters.
Backport of 82bb4e684f9d0e5939cb0596c249954df0888e2d from master
Diffstat (limited to 'tests/postgres_tests')
| -rw-r--r-- | tests/postgres_tests/test_indexes.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/postgres_tests/test_indexes.py b/tests/postgres_tests/test_indexes.py index db61561200..e26d96f003 100644 --- a/tests/postgres_tests/test_indexes.py +++ b/tests/postgres_tests/test_indexes.py @@ -3,7 +3,7 @@ from django.db import connection from django.test import skipUnlessDBFeature from . import PostgreSQLTestCase -from .models import CharFieldModel, IntegerArrayModel +from .models import CharFieldModel, DateTimeArrayModel, IntegerArrayModel @skipUnlessDBFeature('has_brin_index_support') @@ -23,6 +23,17 @@ class BrinIndexTests(PostgreSQLTestCase): index_with_page_range = BrinIndex(fields=['title'], pages_per_range=16) self.assertNotEqual(index, index_with_page_range) + def test_name_auto_generation(self): + """ + A name longer than 30 characters (since len(BrinIndex.suffix) is 4 + rather than usual limit of 3) is okay for PostgreSQL. For this test, + the name of the field ('datetimes') must be at least 7 characters to + generate a name longer than 30 characters. + """ + index = BrinIndex(fields=['datetimes']) + index.set_name_with_model(DateTimeArrayModel) + self.assertEqual(index.name, 'postgres_te_datetim_abf104_brin') + def test_deconstruction(self): index = BrinIndex(fields=['title'], name='test_title_brin') path, args, kwargs = index.deconstruct() |
