details: https://code.tryton.org/tryton/commit/b817f61f4560
branch: 6.0
user: Nicolas Évrard <[email protected]>
date: Wed Mar 18 17:23:14 2026 +0100
description:
Consider empty string and None as incompatible with full text searches
Closes #14691
(grafted from a23b86559016b158103efe518844b5eceb593e6c)
diffstat:
trytond/trytond/tests/test_field_char.py | 17 +++++++++++++++++
trytond/trytond/tools/misc.py | 2 ++
2 files changed, 19 insertions(+), 0 deletions(-)
diffs (39 lines):
diff -r f3207f619ef4 -r b817f61f4560 trytond/trytond/tests/test_field_char.py
--- a/trytond/trytond/tests/test_field_char.py Thu Mar 26 16:23:55 2026 +0100
+++ b/trytond/trytond/tests/test_field_char.py Wed Mar 18 17:23:14 2026 +0100
@@ -610,6 +610,23 @@
pool = Pool()
self._test_search(pool.get('test.char_translate'))
+ @with_transaction()
+ def test_search_empty(self):
+ "Test a full text search with an empty string"
+ pool = Pool()
+ Char = pool.get('test.char')
+
+ record1, record2 = Char.create([{
+ 'char': "word",
+ }, {
+ 'char': "",
+ }])
+
+ with Transaction().set_context(search_similarity=0.3):
+ self.assertEqual(
+ Char.search([('char', 'ilike', '')]),
+ [record2])
+
def _test_order(self, Model):
record1, record2 = Model.create([{
'char': "word",
diff -r f3207f619ef4 -r b817f61f4560 trytond/trytond/tools/misc.py
--- a/trytond/trytond/tools/misc.py Thu Mar 26 16:23:55 2026 +0100
+++ b/trytond/trytond/tools/misc.py Wed Mar 18 17:23:14 2026 +0100
@@ -228,6 +228,8 @@
def is_full_text(value, escape='\\'):
+ if not value:
+ return False
escaped = value.strip('%')
escaped = escaped.replace(escape + '%', '').replace(escape + '_', '')
if '%' in escaped or '_' in escaped: