diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-05-08 16:09:48 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-05-08 16:09:48 -0400 |
commit | 6ea6673376609ce6a5e26f9f20425cffee96bcd8 (patch) | |
tree | 937024d0317d18d6fdffbbca7ee32b2449162242 /lib/sqlalchemy/orm/state.py | |
parent | 7009a3bc32daadf078e2806622615c665105240e (diff) | |
download | sqlalchemy-6ea6673376609ce6a5e26f9f20425cffee96bcd8.tar.gz |
- session.merge() will not expire attributes on the returned
instance if that instance is "pending". [ticket:1789]
Diffstat (limited to 'lib/sqlalchemy/orm/state.py')
-rw-r--r-- | lib/sqlalchemy/orm/state.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/state.py b/lib/sqlalchemy/orm/state.py index 2b43d2cac..9ee31bff8 100644 --- a/lib/sqlalchemy/orm/state.py +++ b/lib/sqlalchemy/orm/state.py @@ -43,6 +43,10 @@ class InstanceState(object): @util.memoized_property def callables(self): return {} + + @property + def has_identity(self): + return bool(self.key) def detach(self): if self.session_id: @@ -219,6 +223,14 @@ class InstanceState(object): If all attributes are expired, the "expired" flag is set to True. """ + # we would like to assert that 'self.key is not None' here, + # but there are many cases where the mapper will expire + # a newly persisted instance within the flush, before the + # key is assigned, and even cases where the attribute refresh + # occurs fully, within the flush(), before this key is assigned. + # the key is assigned late within the flush() to assist in + # "key switch" bookkeeping scenarios. + if attribute_names is None: attribute_names = self.manager.keys() self.expired = True |