From 4ce828dbb170390f01f2d931ff7a165aefe87c32 Mon Sep 17 00:00:00 2001 From: Boris Pavlovic Date: Mon, 4 Feb 2013 16:12:13 +0000 Subject: Fix missing wrap_db_error for Session.execute() method We should add wrap_db_error for Session.execute() method, because Query.update() method will call Session.execute() and it is not inside Session.flush(), so exceptions from Query.update() wouldn't be wrapped. Add test for Session.flush() wrapper Add test for Session.execute() wrapper Fixes bug 1107890 Change-Id: I96894e502f9f279999b61a1e66469e34a07a022d --- openstack/common/db/sqlalchemy/session.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'openstack') diff --git a/openstack/common/db/sqlalchemy/session.py b/openstack/common/db/sqlalchemy/session.py index 700273a..06b198e 100644 --- a/openstack/common/db/sqlalchemy/session.py +++ b/openstack/common/db/sqlalchemy/session.py @@ -593,6 +593,10 @@ class Session(sqlalchemy.orm.session.Session): def flush(self, *args, **kwargs): return super(Session, self).flush(*args, **kwargs) + @wrap_db_error + def execute(self, *args, **kwargs): + return super(Session, self).execute(*args, **kwargs) + def get_maker(engine, autocommit=True, expire_on_commit=False): """Return a SQLAlchemy sessionmaker using the given engine.""" -- cgit