Browse Source

Merge pull request #1539 from CompassionCH/10.0-fix-fuzzy-encoding

[10.0][FIX] fuzzy search when accents are used in the search values
pull/1204/merge
Pedro M. Baeza 6 years ago
committed by GitHub
parent
commit
72154f3b19
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      base_search_fuzzy/models/ir_model.py

10
base_search_fuzzy/models/ir_model.py

@ -17,7 +17,7 @@ def patch_leaf_trgm(method):
model = eleaf.model model = eleaf.model
leaf = eleaf.leaf leaf = eleaf.leaf
left, operator, right = leaf left, operator, right = leaf
table_alias = '"%s"' % (eleaf.generate_alias())
table_alias = u'"%s"' % (eleaf.generate_alias())
if operator == '%': if operator == '%':
@ -25,14 +25,14 @@ def patch_leaf_trgm(method):
params = [] params = []
if left in model._fields: if left in model._fields:
column = '%s.%s' % (table_alias, expression._quote(left))
query = '(%s %s %s)' % (
column = u'%s.%s' % (table_alias, expression._quote(left))
query = u'(%s %s %s)' % (
column, column,
sql_operator, sql_operator,
model._fields[left].column_format, model._fields[left].column_format,
) )
elif left in models.MAGIC_COLUMNS: elif left in models.MAGIC_COLUMNS:
query = "(%s.\"%s\" %s %%s)" % (
query = u"(%s.\"%s\" %s %%s)" % (
table_alias, left, sql_operator) table_alias, left, sql_operator)
params = right params = right
else: # Must not happen else: # Must not happen
@ -41,7 +41,7 @@ def patch_leaf_trgm(method):
)) ))
if left in model._fields: if left in model._fields:
params = str(right)
params = unicode(right)
if isinstance(params, basestring): if isinstance(params, basestring):
params = [params] params = [params]

Loading…
Cancel
Save