From 952615710687ab73a2afdf849f7d1f6c7832dfb2 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Sun, 13 Sep 2009 17:30:21 +0300 Subject: [PATCH] ORM: Protect against dropping columns. When a column is converted to a function, by default the db column is dropped. Sometimes this is a bad idea, until the data is migrated. Let an attribute change this behaviour. bzr revid: p_christ@hol.gr-20090913143021-6tj3c16n4lli9rls --- bin/osv/orm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 029042adca2..5ee29ca2bdd 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -1801,7 +1801,7 @@ class orm(orm_template): f_pg_type = f_pg_def['typname'] f_pg_size = f_pg_def['size'] f_pg_notnull = f_pg_def['attnotnull'] - if isinstance(f, fields.function) and not f.store: + if isinstance(f, fields.function) and not f.store and (not hasattr(f,'nodrop') or not f.nodrop): logger.notifyChannel('orm', netsvc.LOG_INFO, 'column %s (%s) in table %s removed: converted to a function !\n' % (k, f.string, self._table)) cr.execute('ALTER TABLE %s DROP COLUMN %s'% (self._table, k)) cr.commit()