diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-03-07 15:11:29 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-03-08 09:39:38 -0500 |
commit | 788804fd51b612c435b9ca4036ab55cc4adcb892 (patch) | |
tree | 9062f2b4cc4ab11ca4938232efa2ba4efac8f566 /lib/sqlalchemy/orm/mapper.py | |
parent | a289e05226e20cc6de9deb479f63297320ef7c5c (diff) | |
download | sqlalchemy-788804fd51b612c435b9ca4036ab55cc4adcb892.tar.gz |
support selectin_polymorphic w/ no fixed polymorphic_on
Fixed issue where the :func:`_orm.polymorphic_selectin` loader option would
not work with joined inheritance mappers that don't have a fixed
"polymorphic_on" column. Additionally added test support for a wider
variety of usage patterns with this construct.
Fixed bug where :func:`_orm.composite` attributes would not work in
conjunction with the :func:`_orm.selectin_polymorphic` loader strategy for
joined table inheritance.
Fixes: #7799
Fixes: #7801
Change-Id: I7cfe32dfe844b188403b39545930c0aee71d0119
Diffstat (limited to 'lib/sqlalchemy/orm/mapper.py')
-rw-r--r-- | lib/sqlalchemy/orm/mapper.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 5a34188a9..011e7d2ef 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -43,6 +43,7 @@ from .interfaces import InspectionAttr from .interfaces import MapperProperty from .interfaces import ORMEntityColumnsClauseRole from .interfaces import ORMFromClauseRole +from .interfaces import StrategizedProperty from .path_registry import PathRegistry from .. import event from .. import exc as sa_exc @@ -3077,8 +3078,11 @@ class Mapper( assert self.inherits - polymorphic_prop = self._columntoproperty[self.polymorphic_on] - keep_props = set([polymorphic_prop] + self._identity_key_props) + if self.polymorphic_on is not None: + polymorphic_prop = self._columntoproperty[self.polymorphic_on] + keep_props = set([polymorphic_prop] + self._identity_key_props) + else: + keep_props = set(self._identity_key_props) disable_opt = strategy_options.Load(entity) enable_opt = strategy_options.Load(entity) @@ -3087,6 +3091,9 @@ class Mapper( 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) + if not isinstance(prop, StrategizedProperty): + continue + enable_opt = enable_opt._set_generic_strategy( # convert string name to an attribute before passing # to loader strategy |