Files
tryton/modules/party/country.py
T
Cédric Krier ebed93c61a Define index using COALESCE for nullable Char fields
Closes #14909
(grafted from 525198c97acdd19820d581411b3af0f5bb6e4237)

--HG--
branch : 8.0
2026-07-14 21:14:05 +02:00

25 lines
729 B
Python

# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from sql.conditionals import Coalesce
from trytond.model import Index
from trytond.pool import PoolMeta
class PostalCode(metaclass=PoolMeta):
__name__ = 'country.postal_code'
@classmethod
def __setup__(cls):
super().__setup__()
t = cls.__table__()
cls._sql_indexes.update({
Index(
t,
(Index.Unaccent(Coalesce(t.city, '')),
Index.Similarity()),
(t.country, Index.Range()),
(t.subdivision, Index.Range())),
})