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
BZ 1238179 - VM Utilization screen generating charts throws internal server error after Rails 4 #3394
BZ 1238179 - VM Utilization screen generating charts throws internal server error after Rails 4 #3394
Conversation
@@ -445,7 +445,7 @@ def self.search(options = {}) | |||
def self.method_with_scope(ar_scope, options) | |||
if ar_scope == VmdbDatabaseConnection | |||
ar_scope.all | |||
elsif ar_scope < ActsAsArModel | |||
elsif ar_scope < ActsAsArModel || ar_scope.respond_to?(:instances_are_derived?) && ar_scope.instances_are_derived? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add parentheses to make the complex condition clearer:
elsif ar_scope < ActsAsArModel || (ar_scope.respond_to?(:instances_are_derived?) && ar_scope.instances_are_derived?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion. I just made the change.
…> true) the same as classes that derive from ActsAsArModel and call custom find method in brace search. Also added a test that exposes an ActiveRecord bug where a query like "Tagging.includes(:taggable => {}).where('bogus_table.column = 1').references(:bogus_table => {}).to_a" raises an error. The AR error is preventing this bug from being fixed. https://bugzilla.redhat.com/show_bug.cgi?id=1238179
…ng a query where a polymorphic reflection is specified in "includes" and ""references" are used in the query. It will check all of the included associations to see if any are polymorphic and if so avoid calling "references" on the scope. This change will still eager load any polymorphic associations that are included in the query. https://bugzilla.redhat.com/show_bug.cgi?id=1238179
9304fd5
to
be5eec6
Compare
…cludes with a polymorphic association and references pending until issue is addressed in ActiveRecord. https://bugzilla.redhat.com/show_bug.cgi?id=1238179
Checked commits gtanzillo@8615ffe .. gtanzillo@432d7c2 with rubocop 0.32.0 |
@matthewd Please review when you have some time. Thx. |
I'm able to verify that with the above changes in place, the chart screens now work |
…tilization-screen BZ 1238179 - VM Utilization screen generating charts throws internal server error after Rails 4
Treat classes that have "derived" instances (instances_are_derived? => true) the same as classes that derive from ActsAsArModel and call custom find method in brace search. Also added a test that exposes an ActiveRecord bug where a query like "Tagging.includes(:taggable => {}).where('bogus_table.column = 1').references(:bogus_table => {}).to_a" raises an error. The AR error is preventing this bug from being fixed. See (https://github.com/rails/rails/compare/master...gtanzillo:includes_references_with_polymorphic?w=1)
https://bugzilla.redhat.com/show_bug.cgi?id=1238179