summaryrefslogtreecommitdiff
path: root/odoo/tools/sql.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-04-28 18:59:14 +0200
committerChristophe Simonis <chs@odoo.com>2017-04-28 18:59:14 +0200
commit9a769a8b47c586032bdd4c214ac97c510d514c16 (patch)
treeaff7024161ffedb32de935433581f996a2790900 /odoo/tools/sql.py
parent0858e3d33008fd0abc1306ac0991e2ba86494faa (diff)
[FIX] tools.sql: correct queries used to rename field
Diffstat (limited to 'odoo/tools/sql.py')
-rw-r--r--odoo/tools/sql.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/odoo/tools/sql.py b/odoo/tools/sql.py
index bd947dd913c..c4e9a143a8e 100644
--- a/odoo/tools/sql.py
+++ b/odoo/tools/sql.py
@@ -77,12 +77,14 @@ def convert_column(cr, tablename, columnname, columntype):
log_exceptions=False)
except psycopg2.NotSupportedError:
# can't do inplace change -> use a casted temp column
- query = 'ALTER TABLE "{0}" RENAME COLUMN "{1}" TO __temp_type_cast; ' \
- 'ALTER TABLE "{0}" ADD COLUMN "{1}" {2}; ' \
- 'UPDATE "{0}" SET "{1}"= __temp_type_cast::{2}' \
- 'ALTER TABLE "{0}" DROP COLUMN __temp_type_cast CASCADE'
- cr.execute(query.format(tablename, columntype, columntype))
- _schema.debug("Table %r: column %r changed to type %s", tablename, columntype, columntype)
+ query = '''
+ ALTER TABLE "{0}" RENAME COLUMN "{1}" TO __temp_type_cast;
+ ALTER TABLE "{0}" ADD COLUMN "{1}" {2};
+ UPDATE "{0}" SET "{1}"= __temp_type_cast::{2};
+ ALTER TABLE "{0}" DROP COLUMN __temp_type_cast CASCADE;
+ '''
+ cr.execute(query.format(tablename, columnname, columntype))
+ _schema.debug("Table %r: column %r changed to type %s", tablename, columnname, columntype)
def set_not_null(cr, tablename, columnname):
""" Add a NOT NULL constraint on the given column. """