~openerp-dev/openobject-server/saas-3-bug_1291322-ptr

« back to all changes in this revision

Viewing changes to openerp/osv/expression.py

  • Committer: Kersten Jeremy
  • Date: 2014-04-09 15:35:27 UTC
  • mfrom: (4743.1.535 7.0)
  • Revision ID: jke@openerp.com-20140409153527-mic1a8afcvdhsd27
[MERGE] Forward port of branch 7.0 up to rev 5278 rev-id jke@openerp.com-20140409151659-xwttchbtbj02v1w7

Show diffs side-by-side

added added

removed removed

Lines of Context:
1182
1182
        else:
1183
1183
            need_wildcard = operator in ('like', 'ilike', 'not like', 'not ilike')
1184
1184
            sql_operator = {'=like': 'like', '=ilike': 'ilike'}.get(operator, operator)
 
1185
            cast = '::text' if  sql_operator.endswith('like') else ''
1185
1186
 
1186
1187
            if left in model._columns:
1187
1188
                format = need_wildcard and '%s' or model._columns[left]._symbol_set[0]
1188
1189
                unaccent = self._unaccent if sql_operator.endswith('like') else lambda x: x
1189
1190
                column = '%s.%s' % (table_alias, _quote(left))
1190
 
                query = '(%s %s %s)' % (unaccent(column), sql_operator, unaccent(format))
 
1191
                query = '(%s%s %s %s)' % (unaccent(column), cast, sql_operator, unaccent(format))
1191
1192
            elif left in MAGIC_COLUMNS:
1192
 
                    query = "(%s.\"%s\" %s %%s)" % (table_alias, left, sql_operator)
 
1193
                    query = "(%s.\"%s\"%s %s %%s)" % (table_alias, left, cast, sql_operator)
1193
1194
                    params = right
1194
1195
            else:  # Must not happen
1195
1196
                raise ValueError("Invalid field %r in domain term %r" % (left, leaf))