Refs #25809 -- Omitted pages_per_range from BrinIndex.deconstruct() if it's None.

This commit is contained in:
Mads Jensen 2017-08-25 23:54:36 +02:00 committed by Tim Graham
parent 3c0b2b80ed
commit fb42d02471
3 changed files with 6 additions and 2 deletions

View File

@ -19,7 +19,8 @@ class BrinIndex(Index):
def deconstruct(self):
path, args, kwargs = super().deconstruct()
kwargs['pages_per_range'] = self.pages_per_range
if self.pages_per_range is not None:
kwargs['pages_per_range'] = self.pages_per_range
return path, args, kwargs
def create_sql(self, model, schema_editor, using=''):

View File

@ -26,3 +26,6 @@ Bugfixes
* Added POST request support to ``LogoutView``, for equivalence with the
function-based ``logout()`` view (:ticket:`28513`).
* Omitted ``pages_per_range`` from ``BrinIndex.deconstruct()`` if it's ``None``
(:ticket:`25809`).

View File

@ -33,7 +33,7 @@ class BrinIndexTests(PostgreSQLTestCase):
path, args, kwargs = index.deconstruct()
self.assertEqual(path, 'django.contrib.postgres.indexes.BrinIndex')
self.assertEqual(args, ())
self.assertEqual(kwargs, {'fields': ['title'], 'name': 'test_title_brin', 'pages_per_range': None})
self.assertEqual(kwargs, {'fields': ['title'], 'name': 'test_title_brin'})
def test_deconstruction_with_pages_per_range(self):
index = BrinIndex(fields=['title'], name='test_title_brin', pages_per_range=16)