Define index using COALESCE for nullable Char fields

Closes #14909
(grafted from 525198c97acdd19820d581411b3af0f5bb6e4237)

--HG--
branch : 8.0
This commit is contained in:
Cédric Krier
2026-07-14 21:14:05 +02:00
parent 856461f693
commit ebed93c61a
22 changed files with 65 additions and 36 deletions
+2 -1
View File
@@ -5,6 +5,7 @@ import operator
from decimal import Decimal
from sql import Column
from sql.conditionals import Coalesce
from trytond.cache import Cache
from trytond.i18n import gettext
@@ -197,7 +198,7 @@ class Location(DeactivableMixin, tree(), ModelSQL, ModelView):
super().__setup__()
t = cls.__table__()
cls._sql_indexes.update({
Index(t, (t.code, Index.Similarity())),
Index(t, (Coalesce(t.code, ''), Index.Similarity())),
Index(
t,
(t.left, Index.Range(cardinality='high')),
+1 -1
View File
@@ -66,7 +66,7 @@ class ShipmentMixin:
super().__setup__()
t = cls.__table__()
cls._sql_indexes.update({
Index(t, (t.reference, Index.Similarity())),
Index(t, (Coalesce(t.reference, ''), Index.Similarity())),
})
cls._order = [
('effective_date', 'ASC NULLS LAST'),