diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-11-09 11:31:23 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-11-09 13:57:18 -0500 |
| commit | 52b3d6649525929ee1ec14487a2f007194ed741d (patch) | |
| tree | 66d24d06b9362051064a41ac38fe18d5a8ce0607 /lib/sqlalchemy | |
| parent | cf404d840c15fe167518dd884b295dc99ee26178 (diff) | |
| download | sqlalchemy-52b3d6649525929ee1ec14487a2f007194ed741d.tar.gz | |
upgrade deferred loader to regular loader if refresh_state
Fixed issue where deferred polymorphic loading of attributes from a
joined-table inheritance subclass would fail to populate the attribute
correctly if the :func:`_orm.load_only` option were used to originally
exclude that attribute, in the case where the load_only were descending
from a relationship loader option. The fix allows that other valid options
such as ``defer(..., raiseload=True)`` etc. still function as expected.
Fixes: #7304
Change-Id: I58b7ce7c450bcc52d2f0c9bfbcb4d747463ee9b2
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/strategies.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index 2a283caad..71c4a6976 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -382,7 +382,26 @@ class DeferredColumnLoader(LoaderStrategy): # dictionary. Normally, the DeferredColumnLoader.setup_query() # sets up that data in the "memoized_populators" dictionary # and "create_row_processor()" here is never invoked. - if not self.is_class_level: + + if ( + context.refresh_state + and context.query._compile_options._only_load_props + and self.key in context.query._compile_options._only_load_props + ): + self.parent_property._get_strategy( + (("deferred", False), ("instrument", True)) + ).create_row_processor( + context, + query_entity, + path, + loadopt, + mapper, + result, + adapter, + populators, + ) + + elif not self.is_class_level: if self.raiseload: set_deferred_for_local_state = ( self.parent_property._raise_column_loader |
