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

Backport of fb42d0247136249ea81962474e9a6a2faf1755f1 from master
This commit is contained in:
Mads Jensen 2017-08-25 23:54:36 +02:00 committed by Tim Graham
parent 503b9ab7ad
commit c685b8f838
3 changed files with 6 additions and 2 deletions

View File

@ -31,6 +31,7 @@ class BrinIndex(Index):
def deconstruct(self): def deconstruct(self):
path, args, kwargs = super(BrinIndex, self).deconstruct() path, args, kwargs = super(BrinIndex, self).deconstruct()
if self.pages_per_range is not None:
kwargs['pages_per_range'] = self.pages_per_range kwargs['pages_per_range'] = self.pages_per_range
return path, args, kwargs return path, args, kwargs

View File

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

View File

@ -39,7 +39,7 @@ class BrinIndexTests(PostgreSQLTestCase):
path, args, kwargs = index.deconstruct() path, args, kwargs = index.deconstruct()
self.assertEqual(path, 'django.contrib.postgres.indexes.BrinIndex') self.assertEqual(path, 'django.contrib.postgres.indexes.BrinIndex')
self.assertEqual(args, ()) 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): def test_deconstruction_with_pages_per_range(self):
index = BrinIndex(fields=['title'], name='test_title_brin', pages_per_range=16) index = BrinIndex(fields=['title'], name='test_title_brin', pages_per_range=16)