-
Notifications
You must be signed in to change notification settings - Fork 898
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
[WIP] Polymorphic through #19778
[WIP] Polymorphic through #19778
Conversation
f1174bb
to
745352d
Compare
it is not valid to references() a polymorphic column Our understanding was not quite right before. we did want to preload/include the column, just not use references
references force all includes from preload() to eager_load() eager_load is the one that generates all the columns aliased without references(), includes() use preload() if we includes() a polymorphic, then it converts over to eager_load() and blows up. Now we're avoiding references(), getting better sql, and avoiding eager_load()
b5e93cc
to
d7cf4fd
Compare
Checked commits kbrock/manageiq@eeb8c62~...d7cf4fd with ruby 2.5.5, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 lib/rbac/filterer.rb
spec/models/miq_report_spec.rb
|
|
Actually think it was actually fixed by #19804 (still wish we could use join instead of references though) |
commenting to explain why this was closed: everything worked with this except for includes and counts You would think that calling a count would not deal with the includes. It is a preload. And since we are not bringing back the model to then use the preload, it would be pointless to bring them back. So it seems right to ignore the includes statement. But for counts, the includes are automatically converted to references, which is not what we want and sometimes creates syntax errors. To make this work we would need to add special logic around our counts to ensure that the includes (that do not have references) are removed. I thought we would also need to add logic to make sure that we don't have a references to a table that is in a joins. But it turned out to remove all the code that used references and includes. Of course I don't totally rule out that there is a problem, hence I am adding this note. still wish we could use left joins instead of references. |
Fix queries that have virtual attributes and polymorphic queries
This gets away from
references().includes()
and usespreload
for those models we want to reference from ruby andleft_joins
for those models we want to have in our where and select clauses