diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2022-10-24 16:18:07 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2022-10-24 16:18:07 +0000 |
| commit | 5e8fd3239394a7737ae859b0b3b1b7ce3d821564 (patch) | |
| tree | 90fb69d88846f7e172ca5c1ecad713fa7024cedb /lib/sqlalchemy/orm | |
| parent | 13766228c19954f8860de6a2401c44a32832ae3e (diff) | |
| parent | bd1777426255648215328252795dff24dfd08616 (diff) | |
| download | sqlalchemy-5e8fd3239394a7737ae859b0b3b1b7ce3d821564.tar.gz | |
Merge "skip ad-hoc properties within subclass_load_via_in" into main
Diffstat (limited to 'lib/sqlalchemy/orm')
| -rw-r--r-- | lib/sqlalchemy/orm/mapper.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 5d784498a..5d255c9ab 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -3432,6 +3432,13 @@ class Mapper( enable_opt = strategy_options.Load(entity) for prop in self.attrs: + + # skip prop keys that are not instrumented on the mapped class. + # this is primarily the "_sa_polymorphic_on" property that gets + # created for an ad-hoc polymorphic_on SQL expression, issue #8704 + if prop.key not in self.class_manager: + continue + if prop.parent is self or prop in keep_props: # "enable" options, to turn on the properties that we want to # load by default (subject to options from the query) @@ -3440,7 +3447,8 @@ class Mapper( enable_opt = enable_opt._set_generic_strategy( # convert string name to an attribute before passing - # to loader strategy + # to loader strategy. note this must be in terms + # of given entity, such as AliasedClass, etc. (getattr(entity.entity_namespace, prop.key),), dict(prop.strategy_key), _reconcile_to_other=True, @@ -3451,7 +3459,8 @@ class Mapper( # the options from the query to override them disable_opt = disable_opt._set_generic_strategy( # convert string name to an attribute before passing - # to loader strategy + # to loader strategy. note this must be in terms + # of given entity, such as AliasedClass, etc. (getattr(entity.entity_namespace, prop.key),), {"do_nothing": True}, _reconcile_to_other=False, |
