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
Error when selectin eager loading on polymorphic subtypes #4156
Comments
Theron Luhn wrote: It seems that the following query works fine, and is actually closer to what I want to achieve.
The polymorphic loading API is a bit confusing... was I using it wrong in my original code sample? |
Theron Luhn wrote: Okay, back again: When using the "working" query above, but trying to eager load other relationships as well, it breaks again. Here's a couple queries I tried, the first executes successfully but doesn't eager load Employee.benefits, the second one throws the same error as above.
|
Changes by Theron Luhn:
|
Michael Bayer (@zzzeek) wrote: first guess for first problem at https://gerrit.sqlalchemy.org/#/c/zzzeek/sqlalchemy/+/630. second example looks like a separate issue. |
Michael Bayer (@zzzeek) wrote: if we fix the first bug with the one liner (even though im not sure that's the place this should be fixed yet), the second example w/ the benefits can work if all the of_type stuff is removed, I added a Benefit to both and made sure I can get to all benefits / languages without extra SQL emitted:
it works this way also:
as far as throwing in the extra with_polymorphic(), this relationship is already polymorphically loading, I'm not sure why adding it in seems to interfere with everything, that is a bug but the overlapping of options in that case is so confusing and unintuitive that I'm not inclined to get into that case right now. |
Theron Luhn wrote: I think your updated query makes more sense and is easier to read, so I'm quite happy forgoing my awkward second example. I don't fully understand polymorphic loading yet, so I'm just throwing things against the wall. |
Michael Bayer (@zzzeek) wrote: Limit select in loading for correct types Fixed bug in new "selectin" relationship loader where the loader could try This generalizes the mapper limiting that was present Change-Id: I31416550e27bc8374b673860f57d9dcf96abe87d → a216625 |
Changes by Michael Bayer (@zzzeek):
|
Migrated issue, originally created by Theron Luhn
I'm attempting to use selectin eager loading on polymorphic subtypes using the strategy laid out here: http://docs.sqlalchemy.org/en/latest/orm/inheritance_loading.html#eager-loading-of-specific-or-polymorphic-subtypes
Here's some example code:
This results in:
This only happens when both a Manager and Programmer object are in the employees relation. If only a Manager or only a Programmer are attached to a company, it works fine.
This only happens when using selectinload, using subqueryload works fine.
I'm running the current master branch (1.2.0 doesn't work due to #4153)
The text was updated successfully, but these errors were encountered: