- Removed erroneous 'self' reference when raising
UnmappedColumnError during flush() operation.
+ - Added a new SessionExtension hook called after_attach().
+ This is called at the point of attachment for objects
+ via save(), update(), delete(), and merge()
+ (backported from 0.5).
+
- sql
- Fixed bug when calling select([literal('foo')])
or select([bindparam('foo')]).
engine level transaction is begun on a connection.
"""
+ def after_attach(self, session, instance):
+ """Execute after an instance is attached to a session."""
+
class SessionTransaction(object):
"""Represents a Session-level Transaction.
self.identity_map[key] = instance
instance._sa_session_id = self.hash_key
+ if self.extension is not None:
+ self.extension.after_attach(self, instance)
+
def _unattach(self, instance):
if instance._sa_session_id == self.hash_key:
del instance._sa_session_id
log.append('after_flush_postexec')
def after_begin(self, session, transaction, connection):
log.append('after_begin')
+ def after_attach(self, session, instance):
+ log.append('after_attach')
+
sess = create_session(extension = MyExt())
u = User()
sess.save(u)
sess.flush()
- assert log == ['before_flush', 'after_begin', 'after_flush', 'before_commit', 'after_commit', 'after_flush_postexec']
+ assert log == ['after_attach', 'before_flush', 'after_begin', 'after_flush', 'before_commit', 'after_commit', 'after_flush_postexec']
log = []
sess = create_session(transactional=True, extension=MyExt())
u = User()
sess.save(u)
sess.flush()
- assert log == ['before_flush', 'after_begin', 'after_flush', 'after_flush_postexec']
+ assert log == ['after_attach', 'before_flush', 'after_begin', 'after_flush', 'after_flush_postexec']
log = []
u.user_name = 'ed'