diff options
| author | Nick Pope <nick@nickpope.me.uk> | 2021-05-29 00:53:18 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2024-01-02 12:55:12 +0100 |
| commit | 45f778eded9dff59cfdd4dce8720daf87a08cfac (patch) | |
| tree | bfb10dbcf88a4a9ccabcd1b25d61caa20df23f64 /tests/postgres_tests/test_indexes.py | |
| parent | f412add786dfc18424eee6281ec8cc97220b04fc (diff) | |
Fixed #35075 -- Added deduplicate_items parameter to BTreeIndex.
Diffstat (limited to 'tests/postgres_tests/test_indexes.py')
| -rw-r--r-- | tests/postgres_tests/test_indexes.py | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/tests/postgres_tests/test_indexes.py b/tests/postgres_tests/test_indexes.py index d063ac64a2..8a7ee39a76 100644 --- a/tests/postgres_tests/test_indexes.py +++ b/tests/postgres_tests/test_indexes.py @@ -143,12 +143,29 @@ class BTreeIndexTests(IndexTestMixin, PostgreSQLSimpleTestCase): self.assertEqual(BTreeIndex.suffix, "btree") def test_deconstruction(self): - index = BTreeIndex(fields=["title"], name="test_title_btree", fillfactor=80) + index = BTreeIndex(fields=["title"], name="test_title_btree") + path, args, kwargs = index.deconstruct() + self.assertEqual(path, "django.contrib.postgres.indexes.BTreeIndex") + self.assertEqual(args, ()) + self.assertEqual(kwargs, {"fields": ["title"], "name": "test_title_btree"}) + + index = BTreeIndex( + fields=["title"], + name="test_title_btree", + fillfactor=80, + deduplicate_items=False, + ) path, args, kwargs = index.deconstruct() self.assertEqual(path, "django.contrib.postgres.indexes.BTreeIndex") self.assertEqual(args, ()) self.assertEqual( - kwargs, {"fields": ["title"], "name": "test_title_btree", "fillfactor": 80} + kwargs, + { + "fields": ["title"], + "name": "test_title_btree", + "fillfactor": 80, + "deduplicate_items": False, + }, ) @@ -455,13 +472,18 @@ class SchemaTests(PostgreSQLTestCase): ) def test_btree_parameters(self): - index_name = "integer_array_btree_fillfactor" - index = BTreeIndex(fields=["field"], name=index_name, fillfactor=80) + index_name = "integer_array_btree_parameters" + index = BTreeIndex( + fields=["field"], name=index_name, fillfactor=80, deduplicate_items=False + ) with connection.schema_editor() as editor: editor.add_index(CharFieldModel, index) constraints = self.get_constraints(CharFieldModel._meta.db_table) self.assertEqual(constraints[index_name]["type"], BTreeIndex.suffix) - self.assertEqual(constraints[index_name]["options"], ["fillfactor=80"]) + self.assertEqual( + constraints[index_name]["options"], + ["fillfactor=80", "deduplicate_items=off"], + ) with connection.schema_editor() as editor: editor.remove_index(CharFieldModel, index) self.assertNotIn( |
