[MERGE] expression: support for =like/=ilike.
lp bug: https://launchpad.net/bugs/788106 fixed bzr revid: vmt@openerp.com-20110920124252-l5snbvb7ywfogw1o
This commit is contained in:
@@ -187,6 +187,19 @@
|
||||
domain = [('x','in',['y','z']),('a.v','=','e'),'|','|',('a','=','b'),'!',('c','>','d'),('e','!=','f'),('g','=','h')]
|
||||
norm_domain = ['&','&','&'] + domain
|
||||
assert norm_domain == expression.normalize(domain), "Non-normalized domains should be properly normalized"
|
||||
|
||||
|
||||
|
||||
-
|
||||
Check that =like/=ilike expressions are working with an untranslated field.
|
||||
-
|
||||
!python {model: res.partner }: |
|
||||
all_ids = self.search(cr, uid, [('name', '=like', 'Ax')])
|
||||
assert len(all_ids) == 1, "It should have 1 record !"
|
||||
all_ids = self.search(cr, uid, [('name', '=ilike', 'Ax')])
|
||||
assert len(all_ids) == 2, "It should have 2 records !"
|
||||
-
|
||||
Check that =like/=ilike expressions are working with a translated field.
|
||||
-
|
||||
!python {model: res.country }: |
|
||||
all_ids = self.search(cr, uid, [('name', '=like', 'Ind')])
|
||||
assert len(all_ids) == 3, "It should have 3 records !"
|
||||
all_ids = self.search(cr, uid, [('name', '=ilike', 'Ind')])
|
||||
assert len(all_ids) == 3, "It should have 3 records !"
|
||||
|
||||
@@ -425,11 +425,10 @@ class expression(object):
|
||||
self.__exp[i] = tuple(self.__exp[i])
|
||||
|
||||
if field.translate:
|
||||
operator = {'=like':'like','=ilike':'ilike'}.get(operator,operator)
|
||||
if operator in ('like', 'ilike', 'not like', 'not ilike'):
|
||||
right = '%%%s%%' % right
|
||||
|
||||
operator = operator == '=like' and 'like' or operator
|
||||
|
||||
|
||||
query1 = '( SELECT res_id' \
|
||||
' FROM ir_translation' \
|
||||
' WHERE name = %s' \
|
||||
@@ -522,8 +521,9 @@ class expression(object):
|
||||
query = '%s.id %s %%s' % (table._table, operator)
|
||||
params = right
|
||||
else:
|
||||
operator = {'=like':'like','=ilike':'ilike'}.get(operator,operator)
|
||||
like = operator in ('like', 'ilike', 'not like', 'not ilike')
|
||||
|
||||
|
||||
op = {'=like':'like','=ilike':'ilike'}.get(operator,operator)
|
||||
if left in table._columns:
|
||||
format = like and '%s' or table._columns[left]._symbol_set[0]
|
||||
|
||||
Reference in New Issue
Block a user