1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #35075 -- Added deduplicate_items parameter to BTreeIndex.

This commit is contained in:
Nick Pope
2021-05-29 00:53:18 +01:00
committed by Mariusz Felisiak
parent f412add786
commit 45f778eded
5 changed files with 48 additions and 8 deletions

View File

@@ -117,20 +117,27 @@ class BrinIndex(PostgresIndex):
class BTreeIndex(PostgresIndex):
suffix = "btree"
def __init__(self, *expressions, fillfactor=None, **kwargs):
def __init__(self, *expressions, fillfactor=None, deduplicate_items=None, **kwargs):
self.fillfactor = fillfactor
self.deduplicate_items = deduplicate_items
super().__init__(*expressions, **kwargs)
def deconstruct(self):
path, args, kwargs = super().deconstruct()
if self.fillfactor is not None:
kwargs["fillfactor"] = self.fillfactor
if self.deduplicate_items is not None:
kwargs["deduplicate_items"] = self.deduplicate_items
return path, args, kwargs
def get_with_params(self):
with_params = []
if self.fillfactor is not None:
with_params.append("fillfactor = %d" % self.fillfactor)
if self.deduplicate_items is not None:
with_params.append(
"deduplicate_items = %s" % ("on" if self.deduplicate_items else "off")
)
return with_params