From 35daeab90752d94c8bf137429f2364a18751a3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 11 Mar 2008 18:42:58 +0100 Subject: [PATCH] Fix upgrade char size for the new None size --- trytond/osv/orm.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/trytond/osv/orm.py b/trytond/osv/orm.py index 5e60227bb4..3d0dab0fa7 100644 --- a/trytond/osv/orm.py +++ b/trytond/osv/orm.py @@ -559,7 +559,7 @@ class ORM(object): # columns with the name 'type' cannot be changed # for an unknown reason?! if k != 'type': - if f_pg_size > field.size: + if field.size and f_pg_size > field.size: logger.notify_channel('init', LOG_WARNING, "column '%s' in table '%s' " \ @@ -572,11 +572,11 @@ class ORM(object): "TO temp_change_size" % \ (self._table,k)) cursor.execute("ALTER TABLE \"%s\" " \ - "ADD COLUMN \"%s\" VARCHAR(%d)" % \ - (self._table,k,field.size)) + "ADD COLUMN \"%s\" %s" % \ + (self._table, k, field.sql_type()[1])) cursor.execute("UPDATE \"%s\" " \ - "SET \"%s\" = temp_change_size::VARCHAR(%d)" % \ - (self._table, k, field.size)) + "SET \"%s\" = temp_change_size::%s" % \ + (self._table, k, field.sql_type()[1])) cursor.execute("ALTER TABLE \"%s\" " \ "DROP COLUMN temp_change_size" % \ (self._table,))