- Fixed an error in expression typing which caused an endless
loop for expressions with two NULL types.
+
+ - Fixed bug in execution_options() feature whereby the existing
+ Transaction and other state information from the parent
+ connection would not be propagated to the sub-connection.
- ext
- the compiler extension now allows @compiles decorators
"""
return self.engine.Connection(self.engine, self.__connection, _branch=True)
+
+ def _clone(self):
+ """Create a shallow copy of this Connection.
+
+ """
+ c = self.__class__.__new__(self.__class__)
+ c.__dict__ = self.__dict__.copy()
+ return c
def execution_options(self, **opt):
""" Set non-SQL options for the connection which take effect during execution.
:meth:`sqlalchemy.sql.expression.Executable.execution_options`.
"""
- return self.engine.Connection(
- self.engine, self.__connection,
- _branch=self.__branch, _execution_options=opt)
+ c = self._clone()
+ c._execution_options = c._execution_options.union(opt)
+ return c
@property
def dialect(self):
finally:
connection.close()
-
+ def test_retains_through_options(self):
+ connection = testing.db.connect()
+ try:
+ transaction = connection.begin()
+ connection.execute(users.insert(), user_id=1, user_name='user1')
+ conn2 = connection.execution_options(dummy=True)
+ conn2.execute(users.insert(), user_id=2, user_name='user2')
+ transaction.rollback()
+ eq_(connection.scalar("select count(1) from query_users"), 0)
+ finally:
+ connection.close()
+
def test_nesting(self):
connection = testing.db.connect()
transaction = connection.begin()