diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-03-26 21:44:22 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-03-26 21:44:22 +0000 |
commit | cb3be7803bd2d8071ead35d5f053c90f706a678b (patch) | |
tree | c2412d863c4f07b149d41a863b02f1f26dcc0925 /lib/sqlalchemy/mapping/mapper.py | |
parent | c0775bdadc0ad37b7823379c5ab03df98b63da44 (diff) | |
download | sqlalchemy-cb3be7803bd2d8071ead35d5f053c90f706a678b.tar.gz |
rework to expire() to make it smarter. when you expire(), history is immediately removed as well as explicit from dirty/deleted lists. this also changes uow.rollback_object() to remove from those lists, which is strange that it didnt do that before. anyway the mapper, when selecting and creating instances, asks the uow if this already identity-mapped instance is expired, and if so refreshes it on the fly, saving the need for the re-_get() operation, if some other query happens to touch upon the expired object. unit test added to confirm this.
Diffstat (limited to 'lib/sqlalchemy/mapping/mapper.py')
-rw-r--r-- | lib/sqlalchemy/mapping/mapper.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/sqlalchemy/mapping/mapper.py b/lib/sqlalchemy/mapping/mapper.py index 1efdb649a..8ff28cf56 100644 --- a/lib/sqlalchemy/mapping/mapper.py +++ b/lib/sqlalchemy/mapping/mapper.py @@ -816,16 +816,16 @@ class Mapper(object): # including modifying any of its related items lists, as its already # been exposed to being modified by the application. identitykey = self._identity_key(row) - if objectstore.get_session().has_key(identitykey): - instance = objectstore.get_session()._get(identitykey) + sess = objectstore.get_session() + if sess.has_key(identitykey): + instance = sess._get(identitykey) isnew = False - if populate_existing: + if populate_existing or sess.is_expired(instance, unexpire=True): if not imap.has_key(identitykey): imap[identitykey] = instance for prop in self.props.values(): prop.execute(instance, row, identitykey, imap, True) - if self.extension.append_result(self, row, imap, result, instance, isnew, populate_existing=populate_existing): if result is not None: result.append_nohistory(instance) |