details: https://code.tryton.org/tryton/commit/f62e20c70717
branch: default
user: Cédric Krier <[email protected]>
date: Thu Jun 18 15:49:10 2026 +0200
description:
Do not convert select query value into list when searching on char with
in operator
Closes #14898
diffstat:
trytond/trytond/model/fields/char.py | 11 ++++++-----
trytond/trytond/tests/test_field_char.py | 18 +++++++++++++++++-
2 files changed, 23 insertions(+), 6 deletions(-)
diffs (77 lines):
diff -r a80406308529 -r f62e20c70717 trytond/trytond/model/fields/char.py
--- a/trytond/trytond/model/fields/char.py Thu Jun 18 14:55:21 2026 +0200
+++ b/trytond/trytond/model/fields/char.py Thu Jun 18 15:49:10 2026 +0200
@@ -3,7 +3,7 @@
import string
import warnings
-from sql import Column, Expression, Query
+from sql import Column, CombiningQuery, Expression, Query, Select
from sql.conditionals import Coalesce, NullIf
from sql.functions import Trim
from sql.operators import Not
@@ -121,10 +121,11 @@
return column
def _domain_value(self, operator, value):
- if operator in {'in', 'not in'}:
- value = [v if v is not None else '' for v in value]
- elif value is None:
- value = ''
+ if not isinstance(value, (Select, CombiningQuery)):
+ if operator in {'in', 'not in'}:
+ value = [v if v is not None else '' for v in value]
+ elif value is None:
+ value = ''
value = super()._domain_value(operator, value)
if self.search_unaccented and operator.endswith('ilike'):
database = Transaction().database
diff -r a80406308529 -r f62e20c70717 trytond/trytond/tests/test_field_char.py
--- a/trytond/trytond/tests/test_field_char.py Thu Jun 18 14:55:21 2026 +0200
+++ b/trytond/trytond/tests/test_field_char.py Thu Jun 18 15:49:10 2026 +0200
@@ -3,7 +3,7 @@
# this repository contains the full copyright notices and license terms.
import unittest
-from sql import Literal
+from sql import Literal, Select
from trytond import backend
from trytond.model.exceptions import (
@@ -55,9 +55,17 @@
chars_bar = Char.search([
('char', '=', "Bar"),
])
+ chars_select_foo = Char.search([
+ ('char', '=', Select([Literal('Foo')])),
+ ])
+ chars_select_bar = Char.search([
+ ('char', '=', Select([Literal('Bar')])),
+ ])
self.assertListEqual(chars_foo, [char])
self.assertListEqual(chars_bar, [])
+ self.assertListEqual(chars_select_foo, [char])
+ self.assertListEqual(chars_select_bar, [])
@with_transaction()
def test_search_equals_none(self):
@@ -178,10 +186,18 @@
chars_empty = Char.search([
('char', 'in', []),
])
+ chars_select_foo = Char.search([
+ ('char', 'in', Select([Literal('Foo')])),
+ ])
+ chars_select_bar = Char.search([
+ ('char', 'in', Select([Literal('Bar')])),
+ ])
self.assertListEqual(chars_foo, [char])
self.assertListEqual(chars_bar, [])
self.assertListEqual(chars_empty, [])
+ self.assertListEqual(chars_select_foo, [char])
+ self.assertListEqual(chars_select_bar, [])
@with_transaction()
def test_search_in_none(self):