Consider empty string and None as incompatible with full text searches

Closes #14691
This commit is contained in:
Nicolas Évrard
2026-03-18 17:23:14 +01:00
parent ed30a4efde
commit 28c03e5e81
2 changed files with 36 additions and 0 deletions
+34
View File
@@ -820,6 +820,40 @@ class FieldCharSimilarityTestCase(ExtensionTestCase):
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])
@with_transaction()
def test_search_null(self):
"Test a full text search with NULL"
pool = Pool()
Char = pool.get('test.char')
record1, record2 = Char.create([{
'char': "word",
}, {
'char': None,
}])
with Transaction().set_context(search_similarity=0.3):
self.assertEqual(
Char.search([('char', 'ilike', None)]),
[record2])
def _test_order(self, Model):
record1, record2 = Model.create([{
'char': "word",
+2
View File
@@ -223,6 +223,8 @@ def unescape_wildcard(string, wildcards='%_', escape='\\'):
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: