diff options
| author | Christophe Simonis <chs@openerp.com> | 2014-02-17 19:20:45 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@openerp.com> | 2014-02-17 19:20:45 +0100 |
| commit | d60cf404ca5f7b3cf776fa04a14f362bcebf89a9 (patch) | |
| tree | 0c6302af7aa9c34b203a36108d2ac16e7c9aaccd /openerp/sql_db.py | |
| parent | a5b51c2be7f94b7d818fc4b52f95c5573fcf6507 (diff) | |
[FIX] orm._auto_init: fallback to copy method when altering in-place varchar columns failed.
When a varchar column has a dependence on a view, we cannot change the size in-place,
we need to manually re-create the column with the correct type.
bzr revid: chs@openerp.com-20140217182045-qor70r3gb0fch2ki
Diffstat (limited to 'openerp/sql_db.py')
| -rw-r--r-- | openerp/sql_db.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/openerp/sql_db.py b/openerp/sql_db.py index de9d21dcd82..fb214fa068b 100644 --- a/openerp/sql_db.py +++ b/openerp/sql_db.py @@ -3,7 +3,7 @@ # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). -# Copyright (C) 2010-2013 OpenERP s.a. (<http://openerp.com>). +# Copyright (C) 2010-2014 OpenERP s.a. (<http://openerp.com>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -27,8 +27,10 @@ the database, *not* a database abstraction toolkit. Database abstraction is what the ORM does, in fact. """ +from contextlib import contextmanager from functools import wraps import logging +import time import psycopg2.extensions from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT, ISOLATION_LEVEL_READ_COMMITTED, ISOLATION_LEVEL_REPEATABLE_READ from psycopg2.pool import PoolError @@ -344,6 +346,19 @@ class Cursor(object): """ return self._cnx.rollback() + @contextmanager + @check + def savepoint(self): + """context manager entering in a new savepoint""" + name = hex(int(time.time() * 1000))[1:] + self.execute("SAVEPOINT %s" % (name,)) + try: + yield + self.execute('RELEASE SAVEPOINT %s' % (name,)) + except Exception: + self.execute('ROLLBACK TO SAVEPOINT %s' % (name,)) + raise + @check def __getattr__(self, name): return getattr(self._obj, name) |
