From f8eae466e58ed7f0ec491c7a656fb55a210a7141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 11 Oct 2010 13:20:09 +0200 Subject: [PATCH] Return _timestamp as string for issue1715 --- trytond/model/modelsql.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/trytond/model/modelsql.py b/trytond/model/modelsql.py index 912f8320ce..52aa291676 100644 --- a/trytond/model/modelsql.py +++ b/trytond/model/modelsql.py @@ -4,6 +4,7 @@ from __future__ import with_statement import contextlib import datetime import re +from decimal import Decimal from trytond.model import ModelStorage from trytond.model import fields from trytond.backend import FIELDS, TableHandler @@ -489,10 +490,9 @@ class ModelSQL(ModelStorage): if '_timestamp' in fields_pre: if not self.table_query(): fields_pre2 += ['CAST(EXTRACT(EPOCH FROM ' - '(COALESCE("%s".write_date, "%s".create_date))) AS %s' - ') AS _timestamp' % - (self._table, self._table, - FIELDS['numeric'].sql_type(self.create_date)[1])] + '(COALESCE("%s".write_date, "%s".create_date)))' + 'AS VARCHAR) AS _timestamp' % + (self._table, self._table)] for i in range(0, len(ids), in_max): sub_ids = ids[i:i + in_max] @@ -749,8 +749,8 @@ class ModelSQL(ModelStorage): for i in sub_ids: if Transaction().timestamp.get(self._name + ',' + str(i)): args.append(i) - args.append(Transaction().timestamp[ - self._name + ',' +str(i)]) + args.append(Decimal(Transaction().timestamp[ + self._name + ',' +str(i)])) if args: cursor.execute("SELECT id " \ 'FROM "' + self._table + '" ' \ @@ -1184,8 +1184,7 @@ class ModelSQL(ModelStorage): if not self.table_query(): select_fields += ['CAST(EXTRACT(EPOCH FROM ' '(COALESCE("' + self._table + '".write_date, ' - '"' + self._table + '".create_date))) AS ' + \ - FIELDS['numeric'].sql_type(self.create_date)[1] + \ + '"' + self._table + '".create_date))) AS VARCHAR' ') AS _timestamp'] query_str = cursor.limit_clause( 'SELECT ' + ','.join(select_fields) + ' FROM ' + \