diff options
Diffstat (limited to 'lib/sqlalchemy/orm/loading.py')
-rw-r--r-- | lib/sqlalchemy/orm/loading.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/loading.py b/lib/sqlalchemy/orm/loading.py index c3d4773cd..49c71e5b2 100644 --- a/lib/sqlalchemy/orm/loading.py +++ b/lib/sqlalchemy/orm/loading.py @@ -161,7 +161,7 @@ def merge_result(query, iterator, load=True): session.autoflush = autoflush -def get_from_identity(session, key, passive): +def get_from_identity(session, mapper, key, passive): """Look up the given key in the given session's identity map, check the object for expired state if found. @@ -171,6 +171,9 @@ def get_from_identity(session, key, passive): state = attributes.instance_state(instance) + if mapper.inherits and not state.mapper.isa(mapper): + return attributes.PASSIVE_CLASS_MISMATCH + # expired - ensure it still exists if state.expired: if not passive & attributes.SQL_OK: |