-
Notifications
You must be signed in to change notification settings - Fork 897
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
Exclude Service::AGGREGATE_ALL_VM_ATTRS from MiqExp.to_sql #16915
Exclude Service::AGGREGATE_ALL_VM_ATTRS from MiqExp.to_sql #16915
Conversation
Instead of passing just the column name into .excluded_col_for_expression, pass the entire field object into the method so that the model can also be referenced if needed (will be used in a future commit). This method is only used where it has been edited here in our entire codebase, so this should be a relatively safe change. I also don't see this as something that would called in an automate script.
These calls, while they are Arel and could be converted, would most likely be used in "filter" type scenarios, and would not be good candidates for that since they would perform horribly when used on more than one record at a time (which filtering would do that). Instead of preventing these records from showing up as a filter option, just make sure they can't be used with SQL when they are. That said, they will cause N+1 hell, so they really shouldn't be filtered on... but... ¯\(°_o)/¯
cc/ @imtayadeway @kbrock |
Checked commits NickLaMuro/manageiq@e7955bf~...0d32b87 with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0 |
@gtanzillo Seeing as this was originally targeted for a 5.9 BZ, should we be backporting this to Gaprindashvili? Also, I have confirmed that this causes issues as far back as Darga as well (though, I think we don't support that version any more), should we backport to other branches as well? |
…service-agg-col-with-miq-exp Exclude Service::AGGREGATE_ALL_VM_ATTRS from MiqExp.to_sql (cherry picked from commit 5709538) https://bugzilla.redhat.com/show_bug.cgi?id=1540698
Gaprindashvili backport details:
|
…service-agg-col-with-miq-exp Exclude Service::AGGREGATE_ALL_VM_ATTRS from MiqExp.to_sql (cherry picked from commit 5709538) https://bugzilla.redhat.com/show_bug.cgi?id=1540699
Fine backport details:
|
…x-avoid-service-agg-col-with-miq-exp Exclude Service::AGGREGATE_ALL_VM_ATTRS from MiqExp.to_sql (cherry picked from commit 5709538) https://bugzilla.redhat.com/show_bug.cgi?id=1540699
These calls, while they are Arel and could be converted, would most likely be used in "filter" type scenarios, and would not be good candidates for that since they would perform horribly when used on more than one record at a time (which filtering would do that).
Instead of preventing these records from showing up as a filter option, just make sure they can't be used with SQL when they are. That said, they will cause N+1 hell, so they really shouldn't be filtered on... but...
¯\(°_o)/¯
Alternative solution explanation
This is one possible solution for this BZ. The other would be wrapping the
arel_attribute
values in theMiqExpression#to_arel
method with aArel::Nodes::Grouping
call, which would alloweq
calls to be done on these, and the other arel-basedMiqExpression
operators. This solution was proposed first because of the concerns raised in #11502 which add theService::AGGREGATE_ALL_VM_ATTRS
virtual_attributes
:As mentioned above, this means if a user does decide to filter based on these columns, it will most likely be slow, but it will be a bunch of short queries to the DB instead of a single massive and crippling one. Ideally these filters just shouldn't be used for filtering Services.
Links
Steps for Testing/QA
I will add some tests in another commit/rebased commit, but for now, you can test with that the following doesn't raise an error in a
bin/rails c
: