Add new patch, issue12480 [trytond] Support GIN index with btree_gin PostgreSQL extension.
This commit is contained in:
parent
e59eb8695f
commit
cfbc276b9e
|
@ -0,0 +1,53 @@
|
|||
diff --git a/tryton/trytond/trytond/backend/postgresql/table.py b/tryton/trytond/trytond/backend/postgresql/table.py
|
||||
index e874ee61c0..44ff97ce9b 100644
|
||||
--- a/tryton/trytond/trytond/backend/postgresql/table.py
|
||||
+++ b/tryton/trytond/trytond/backend/postgresql/table.py
|
||||
@@ -647,23 +647,42 @@ class TrigramTranslator(IndexMixin, IndexTranslatorInterface):
|
||||
|
||||
@classmethod
|
||||
def score(cls, index):
|
||||
- has_trigram = Transaction().database.has_extension('pg_trgm')
|
||||
- if not has_trigram:
|
||||
+ database = Transaction().database
|
||||
+ has_btree_gin = database.has_extension('btree_gin')
|
||||
+ has_trigram = database.has_extension('pg_trgm')
|
||||
+ if not has_btree_gin and not has_trigram:
|
||||
return 0
|
||||
|
||||
score = 0
|
||||
for _, usage in index.expressions:
|
||||
if usage.__class__.__name__ == 'Similarity':
|
||||
- score += 100
|
||||
+ if has_trigram:
|
||||
+ score += 100
|
||||
+ else:
|
||||
+ score += 50
|
||||
+ elif has_btree_gin:
|
||||
+ if usage.__class__.__name__ == 'Range':
|
||||
+ score += 90
|
||||
+ elif usage.__class__.__name__ == 'Equality':
|
||||
+ score += 40
|
||||
else:
|
||||
return 0
|
||||
return score
|
||||
|
||||
@classmethod
|
||||
def _get_indexed_expressions(cls, index):
|
||||
- return [
|
||||
- (e, u) for e, u in index.expressions
|
||||
- if u.__class__.__name__ == 'Similarity']
|
||||
+ database = Transaction().database
|
||||
+ has_btree_gin = database.has_extension('btree_gin')
|
||||
+ has_trigram = database.has_extension('pg_trgm')
|
||||
+
|
||||
+ def filter(usage):
|
||||
+ if usage.__class__.__name__ == 'Similarity':
|
||||
+ return has_trigram
|
||||
+ elif usage.__class__.__name__ in {'Range', 'Equality'}:
|
||||
+ return has_btree_gin
|
||||
+ else:
|
||||
+ return False
|
||||
+ return [(e, u) for e, u in index.expressions if filter(u)]
|
||||
|
||||
@classmethod
|
||||
def _get_expression_variables(cls, expression, usage):
|
2
series
2
series
|
@ -47,3 +47,5 @@ issue12414.diff # [stock_lot_sled] Check expiration lot in case Shelf Life Time
|
|||
merge_request581.diff # [account] Post cancelled, grouped, rescheduled and delegated moves
|
||||
|
||||
issue12216.diff # [stock] Handle evaluation error of cost price in cost price revision
|
||||
|
||||
issue12480.diff # [trytond] Support GIN index with btree_gin PostgreSQL extension
|
||||
|
|
Loading…
Reference in New Issue