summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMads Jensen <mje@inducks.org>2017-08-26 16:32:03 +0200
committerTim Graham <timograham@gmail.com>2017-08-26 10:32:03 -0400
commite016c4c65b4aa0521a74e1cba6f75a596ee9ee1c (patch)
tree795626874187ba4e1ebf5ba7ee74303d4dcc3f18
parentfb42d0247136249ea81962474e9a6a2faf1755f1 (diff)
Refs #27869 -- Omitted field kwargs from GinIndex.deconstruct() if they're None.
-rw-r--r--django/contrib/postgres/indexes.py6
-rw-r--r--tests/postgres_tests/test_indexes.py7
2 files changed, 11 insertions, 2 deletions
diff --git a/django/contrib/postgres/indexes.py b/django/contrib/postgres/indexes.py
index 1f7a01faf1..cbfd43c1de 100644
--- a/django/contrib/postgres/indexes.py
+++ b/django/contrib/postgres/indexes.py
@@ -42,8 +42,10 @@ class GinIndex(Index):
def deconstruct(self):
path, args, kwargs = super().deconstruct()
- kwargs['fastupdate'] = self.fastupdate
- kwargs['gin_pending_list_limit'] = self.gin_pending_list_limit
+ if self.fastupdate is not None:
+ kwargs['fastupdate'] = self.fastupdate
+ if self.gin_pending_list_limit is not None:
+ kwargs['gin_pending_list_limit'] = self.gin_pending_list_limit
return path, args, kwargs
def create_sql(self, model, schema_editor, using=''):
diff --git a/tests/postgres_tests/test_indexes.py b/tests/postgres_tests/test_indexes.py
index ae4895a03e..ac19f53ab8 100644
--- a/tests/postgres_tests/test_indexes.py
+++ b/tests/postgres_tests/test_indexes.py
@@ -84,6 +84,13 @@ class GinIndexTests(PostgreSQLTestCase):
}
)
+ def test_deconstruct_no_args(self):
+ index = GinIndex(fields=['title'], name='test_title_gin')
+ path, args, kwargs = index.deconstruct()
+ self.assertEqual(path, 'django.contrib.postgres.indexes.GinIndex')
+ self.assertEqual(args, ())
+ self.assertEqual(kwargs, {'fields': ['title'], 'name': 'test_title_gin'})
+
class SchemaTests(PostgreSQLTestCase):