Define index using COALESCE for nullable Char fields
Closes #14909 (grafted from 525198c97acdd19820d581411b3af0f5bb6e4237) --HG-- branch : 8.0
This commit is contained in:
@@ -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')),
|
||||
|
||||
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user