From f08bf5a6fec07d8c6295926d5fc9735ba72c8cc9 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 17 Mar 2006 02:51:08 +0000 Subject: [PATCH] fixed nasty transaction counting bug with new session thing + unit test --- lib/sqlalchemy/engine.py | 6 ++++++ test/proxy_engine.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/sqlalchemy/engine.py b/lib/sqlalchemy/engine.py index aa0449628d..482aa4270e 100644 --- a/lib/sqlalchemy/engine.py +++ b/lib/sqlalchemy/engine.py @@ -198,6 +198,7 @@ class SQLSession(object): """commits the transaction started by begin(). If begin() was called multiple times, a counter will be decreased for each call to commit(), with the actual commit operation occuring when the counter reaches zero. this is to provide "nested" behavior of transactions so that different functions in a particular call stack can call begin()/commit() independently of each other without knowledge of an existing transaction.""" if self.__tcount == 1: self.engine.do_commit(self.connection) + self.__tcount = 0 elif self.__tcount > 1: self.__tcount -= 1 def is_begun(self): @@ -711,6 +712,11 @@ class SQLEngine(schema.SchemaEngine): return parameters def proxy(self, statement=None, parameters=None): + """returns a callable which will execute the given statement string and parameter object. + the parameter object is expected to be the result of a call to compiled.get_params(). + This callable is a generic version of a connection/cursor-specific callable that + is produced within the execute_compiled method, and is used for objects that require + this style of proxy when outside of an execute_compiled method, primarily the DefaultRunner.""" parameters = self._convert_compiled_params(parameters) return self.execute(statement, parameters) diff --git a/test/proxy_engine.py b/test/proxy_engine.py index 14cd1902bc..170e526d96 100644 --- a/test/proxy_engine.py +++ b/test/proxy_engine.py @@ -11,7 +11,7 @@ import os # -module_engine = ProxyEngine() +module_engine = ProxyEngine(echo=testbase.echo) users = Table('users', module_engine, Column('user_id', Integer, primary_key=True), Column('user_name', String(16)), -- 2.47.2