From b21d1497faaba940df8164edd1c6b95f8634cfdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 27 Aug 2025 10:17:31 +0200 Subject: [PATCH] Use the FILTER syntax with SQL aggregate functions Closes #14199 --- trytond/CHANGELOG | 1 + trytond/trytond/backend/postgresql/database.py | 2 +- trytond/trytond/backend/sqlite/database.py | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/trytond/CHANGELOG b/trytond/CHANGELOG index e2d2a1f6cc..61d96e8376 100644 --- a/trytond/CHANGELOG +++ b/trytond/CHANGELOG @@ -1,3 +1,4 @@ +* Use the FILTER syntax with SQL aggregate functions * Use the EXISTS operator when using the 'where' operator in Many2One * Redact sensitive values from the log (issue14220) * Add multiple attribute to the buttons in the tree view diff --git a/trytond/trytond/backend/postgresql/database.py b/trytond/trytond/backend/postgresql/database.py index 4e6cfd2e0c..2692207d6a 100644 --- a/trytond/trytond/backend/postgresql/database.py +++ b/trytond/trytond/backend/postgresql/database.py @@ -205,7 +205,7 @@ class Database(DatabaseInterface): _has_proc = defaultdict(lambda: defaultdict(dict)) _extensions = defaultdict(dict) _search_full_text_languages = defaultdict(dict) - flavor = Flavor(ilike=True) + flavor = Flavor(ilike=True, filter_=True) TYPES_MAPPING = { 'SMALLINT': SQLType('INT2', 'INT2'), diff --git a/trytond/trytond/backend/sqlite/database.py b/trytond/trytond/backend/sqlite/database.py index 6a0928eb3a..c9a5c4a791 100644 --- a/trytond/trytond/backend/sqlite/database.py +++ b/trytond/trytond/backend/sqlite/database.py @@ -444,7 +444,8 @@ class Database(DatabaseInterface): _list_cache_timestamp = {} flavor = Flavor( paramstyle='qmark', function_mapping=MAPPING, null_ordering=False, - max_limit=-1) + max_limit=-1, + filter_=sqlite.sqlite_version_info >= (3, 30, 0)) IN_MAX = 200 TYPES_MAPPING = {