New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load.load_only based on subclass doesn't get recognized #4373
Comments
Michael Bayer (@zzzeek) wrote: I think because "a" is part of MyEntity, you'd want to Load(MyEntity).load_only('a'). It probably should work the way you're doing it also, but using |
Changes by Michael Bayer (@zzzeek):
|
Changes by Michael Bayer (@zzzeek):
|
Changes by Michael Bayer (@zzzeek):
|
Changes by Michael Bayer (@zzzeek):
|
Dmytro Starosud (@dima-starosud) wrote:
Looks like it's not really true:
produces full query
BTW, It works with
produces
|
Michael Bayer (@zzzeek) wrote: i meant, |
OK this works for the "unbound" version because of #3287 committed in b63aae2 where an explicit "add the option for superclasses" step was added, when you have |
OK that was easy diff --git a/lib/sqlalchemy/orm/strategy_options.py b/lib/sqlalchemy/orm/strategy_options.py
index af9bd71b6a..0ef34b0b9b 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()
|
Mike Bayer has proposed a fix for this issue: Apply path generation for superclasses to Load._set_path_strategy() https://gerrit.sqlalchemy.org/991 |
Migrated issue, originally created by Dmytro Starosud (@dima-starosud)
This is using SQLAlchemy==1.2.14.
Please consider following code snippet:
It produces following output:
Please assist. Did I misread documentation? Note unbound
load_only('a')
works well.The text was updated successfully, but these errors were encountered: