Add test is column_name is in _columns when testing field type for issue1194

add_raw_column is used in _update_history_table and column_name can any more
exist or not yet instanciate in the Model
This commit is contained in:
Cédric Krier committed 2009-09-28 11:58:52 +02:00
1 parent b427d21224
commit d3b3cd41f2
1 file changed
+3 -1
+3 -1
View File
@@ -179,7 +179,9 @@ class TableHandler(TableHandlerInterface):
column_type = column_type[1]
default = ''
from trytond.model import fields
if isinstance(self._model._columns[column_name], (fields.Integer, fields.Float)):
if column_name in self._model._columns and \
isinstance(self._model._columns[column_name],
(fields.Integer, fields.Float)):
default = ' DEFAULT 0'
self.cursor.execute(('ALTER TABLE "%s" ADD COLUMN "%s" %s' + default) %
(self.table_name, column_name, column_type))