From 9967b197f150ad9c80ff5753efa0a03fbcf1cebd Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bonicoli Date: Fri, 24 Aug 2012 17:29:29 +0200 Subject: [PATCH] sql query: don't add another 'id' column when it's already here issue2758 review484003 --- trytond/model/modelsql.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/trytond/model/modelsql.py b/trytond/model/modelsql.py index 0cbd4b0b25..c2ca853471 100644 --- a/trytond/model/modelsql.py +++ b/trytond/model/modelsql.py @@ -497,13 +497,14 @@ class ModelSQL(ModelStorage): '(COALESCE("%s".write_date, "%s".create_date))) ' 'AS VARCHAR) AS _timestamp' % (self._table, self._table)] + if 'id' not in fields_pre: + fields_pre2 += ['"%s".id AS id' % self._table] for i in range(0, len(ids), in_max): sub_ids = ids[i:i + in_max] red_sql, red_ids = reduce_ids('id', sub_ids) if domain1: - cursor.execute('SELECT ' + - ','.join(fields_pre2 + ['"%s".id AS id' % self._table]) + cursor.execute('SELECT ' + ','.join(fields_pre2) + ' FROM ' + table_query + '\"' + self._table + '\" ' 'WHERE ' + red_sql + history_clause + ' AND (' + domain1 + ') ' @@ -511,8 +512,7 @@ class ModelSQL(ModelStorage): + history_limit, table_args + red_ids + history_args + domain2) else: - cursor.execute('SELECT ' + - ','.join(fields_pre2 + ['"%s".id AS id' % self._table]) + cursor.execute('SELECT ' + ','.join(fields_pre2) + ' FROM ' + table_query + '\"' + self._table + '\" ' 'WHERE ' + red_sql + history_clause + history_order