diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-03-21 17:26:24 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-03-22 11:47:59 -0400 |
commit | becab22dcbe9d68b0671a9246e022c9810f7e319 (patch) | |
tree | e9dee7d56ca0509ee08ffde195eb2f0791e9f158 /lib/sqlalchemy/orm/strategies.py | |
parent | a25e2e02e108551d2910171202fd91fdaeb8162c (diff) | |
download | sqlalchemy-becab22dcbe9d68b0671a9246e022c9810f7e319.tar.gz |
Test instance for matching class hierarchy on get_from_identity
Fixed issue where a lazyload that uses session-local "get" against a target
many-to-one relationship where an object with the correct primary key is
present, however it's an instance of a sibling class, does not correctly
return None as is the case when the lazy loader actually emits a load for
that row.
Fixes: #5210
Change-Id: I89f9946cfeba61d89a272435f76a5a082b1da30c
Diffstat (limited to 'lib/sqlalchemy/orm/strategies.py')
-rw-r--r-- | lib/sqlalchemy/orm/strategies.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index 7d05a37f5..094637082 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -774,7 +774,10 @@ class LazyLoader(AbstractRelationshipLoader, util.MemoizedSlots): ) if instance is not None: - return instance + if instance is attributes.PASSIVE_CLASS_MISMATCH: + return None + else: + return instance elif ( not passive & attributes.SQL_OK or not passive & attributes.RELATED_OBJECT_OK |