diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-02-17 17:54:43 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-02-17 18:01:20 -0500 |
| commit | 594a974ede97941a61c2e657a63cb11a7137c1ae (patch) | |
| tree | b18fb3ec6b934385238311e80baf4cda1f64ec8d /lib/sqlalchemy/orm | |
| parent | 2965da0a5d89119787bd45ac6f5459a7b755656d (diff) | |
| download | sqlalchemy-594a974ede97941a61c2e657a63cb11a7137c1ae.tar.gz | |
- Fixed bug which would cause an eagerly loaded many-to-one attribute
to not be loaded, if the joined eager load were from a row where the
same entity were present multiple times, some calling for the attribute
to be eagerly loaded and others not. The logic here is revised to
take in the attribute even though a different loader path has
handled the parent entity already. fixes #3431
Diffstat (limited to 'lib/sqlalchemy/orm')
| -rw-r--r-- | lib/sqlalchemy/orm/strategies.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index 7942b14d4..7d816e626 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -1573,13 +1573,19 @@ class JoinedLoader(AbstractRelationshipLoader): # call _instance on the row, even though the object has # been created, so that we further descend into properties existing = _instance(row) - if existing is not None \ - and key in dict_ \ - and existing is not dict_[key]: - util.warn( - "Multiple rows returned with " - "uselist=False for eagerly-loaded attribute '%s' " - % self) + if existing is not None: + # conflicting value already loaded, this shouldn't happen + if key in dict_: + if existing is not dict_[key]: + util.warn( + "Multiple rows returned with " + "uselist=False for eagerly-loaded attribute '%s' " + % self) + else: + # this case is when one row has multiple loads of the + # same entity (e.g. via aliasing), one has an attribute + # that the other doesn't. + dict_[key] = existing def load_scalar_from_joined_exec(state, dict_, row): _instance(row) |
