From fb05e085fe48a1c48fcb4bcf89ba58c0d7584b8c Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 30 Nov 2018 14:36:20 -0500 Subject: Apply path generation for superclasses to Load._set_path_strategy() Extended the fix first made as part of :ticket:`3287`, where a loader option made against a subclass using a wildcard would extend itself to include application of the wildcard to attributes on the super classes as well, to a "bound" loader option as well, e.g. in an expression like ``Load(SomeSubClass).load_only('foo')``. Columns that are part of the parent class of ``SomeSubClass`` will also be excluded in the same way as if the unbound option ``load_only('foo')`` were used. Fixes: #4373 Change-Id: I2eee0e587c34323a77df077b9cb699da370c403d --- lib/sqlalchemy/orm/strategy_options.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/sqlalchemy/orm/strategy_options.py b/lib/sqlalchemy/orm/strategy_options.py index af9bd71b6..0ef34b0b9 100644 --- a/lib/sqlalchemy/orm/strategy_options.py +++ b/lib/sqlalchemy/orm/strategy_options.py @@ -357,9 +357,15 @@ class Load(Generative, MapperOption): else: effective_path = self.path - self._set_for_path( - self.context, effective_path, replace=True, - merge_opts=self.is_opts_only) + if effective_path.is_token: + for path in effective_path.generate_for_superclasses(): + self._set_for_path( + self.context, path, replace=True, + merge_opts=self.is_opts_only) + else: + self._set_for_path( + self.context, effective_path, replace=True, + merge_opts=self.is_opts_only) def __getstate__(self): d = self.__dict__.copy() -- cgit v1.2.1