diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-09-01 16:25:20 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-09-01 16:25:20 +0000 |
commit | 005603e2fb198c3f3328fa555e82a334f0f89d52 (patch) | |
tree | bfec82270157f25d8335a44c21179a179614a257 /lib/sqlalchemy/attributes.py | |
parent | 2c1006534e2bb9e3e468e6ce47181f7a1f8a8de8 (diff) | |
download | sqlalchemy-005603e2fb198c3f3328fa555e82a334f0f89d52.tar.gz |
insure that "parent" pointers are set up on objects that were lazily loaded
Diffstat (limited to 'lib/sqlalchemy/attributes.py')
-rw-r--r-- | lib/sqlalchemy/attributes.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/sqlalchemy/attributes.py b/lib/sqlalchemy/attributes.py index c709afe3d..3aada1951 100644 --- a/lib/sqlalchemy/attributes.py +++ b/lib/sqlalchemy/attributes.py @@ -134,7 +134,10 @@ class InstrumentedAttribute(object): if callable_ is not None: if passive: return InstrumentedAttribute.PASSIVE_NORESULT - l = InstrumentedList(self, obj, self._adapt_list(callable_()), init=False) + values = callable_() + l = InstrumentedList(self, obj, self._adapt_list(values), init=False) + if self.trackparent and values is not None: + [self.sethasparent(v, True) for v in values if v is not None] # if a callable was executed, then its part of the "committed state" # if any, so commit the newly loaded data orig = state.get('original', None) @@ -152,7 +155,10 @@ class InstrumentedAttribute(object): if callable_ is not None: if passive: return InstrumentedAttribute.PASSIVE_NORESULT - obj.__dict__[self.key] = callable_() + value = callable_() + obj.__dict__[self.key] = value + if self.trackparent and value is not None: + self.sethasparent(value, True) # if a callable was executed, then its part of the "committed state" # if any, so commit the newly loaded data orig = state.get('original', None) |