From b6823a7378f82bc67e65bd79e417d939de3d5326 Mon Sep 17 00:00:00 2001 From: Julien Thewys Date: Wed, 4 Aug 2010 17:37:07 +0200 Subject: [PATCH] [FIX] Where clause with one element was not properly serialized. Guideline: please don't modify the type of a variable within its scope, create a new variable instead. bzr revid: jth@openerp.com-20100804153707-9wolx4of6ymjl5pq --- bin/osv/orm.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 4d343fc9628..7b670b0be22 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -3804,13 +3804,10 @@ class orm(orm_template): if t not in tables: tables.append(t) - if len(qu1): - qu1 = ' where ' + ' and '.join(qu1) - else: - qu1 = '' + where = qu1 order_by = self._order - qu1_join = '' + qu1_join = [] if order: self._check_qorder(order) o = order.split(' ')[0] @@ -3825,16 +3822,15 @@ class orm(orm_template): limit_str = limit and ' limit %d' % limit or '' offset_str = offset and ' offset %d' % offset or '' - if len(qu1_join): - qu1 = qu1 + ' and ' - qu1 += ' and '.join(qu1_join) + where.extend(qu1_join) + where_str = " WHERE %s" % " AND ".join(where) if count: cr.execute('select count(%s.id) from ' % self._table + - ','.join(tables) +qu1 + limit_str + offset_str, qu2) + ','.join(tables) + where_str + limit_str + offset_str, qu2) res = cr.fetchall() return res[0][0] - cr.execute('select %s.id from ' % self._table + ','.join(tables) +qu1+' order by '+order_by+limit_str+offset_str, qu2) + cr.execute('select %s.id from ' % self._table + ','.join(tables) + where_str +' order by '+order_by+limit_str+offset_str, qu2) res = cr.fetchall() return [x[0] for x in res]