details:   https://code.tryton.org/tryton/commit/03695553f8b7
branch:    7.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 5470358faf60 -r 03695553f8b7 trytond/trytond/tests/test_field_char.py
--- a/trytond/trytond/tests/test_field_char.py  Tue Mar 17 17:45:22 2026 +0100
+++ b/trytond/trytond/tests/test_field_char.py  Wed Mar 18 17:23:14 2026 +0100
@@ -760,6 +760,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 5470358faf60 -r 03695553f8b7 trytond/trytond/tools/misc.py
--- a/trytond/trytond/tools/misc.py     Tue Mar 17 17:45:22 2026 +0100
+++ b/trytond/trytond/tools/misc.py     Wed Mar 18 17:23:14 2026 +0100
@@ -256,6 +256,8 @@
 
 
 def is_full_text(value, escape='\\'):
+    if not value:
+        return False
     escaped = strip_wildcard(value, escape=escape)
     escaped = escaped.replace(escape + '%', '').replace(escape + '_', '')
     if '%' in escaped or '_' in escaped:

Reply via email to