Skip to content
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

Conversation

gtanzillo
Copy link
Member

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

@@ -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?
Copy link
Member

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?)

Copy link
Member Author

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
@gtanzillo gtanzillo force-pushed the rails-4-error-generating-vm-utilization-screen branch from 9304fd5 to be5eec6 Compare July 11, 2015 11:26
…cludes with a polymorphic association and references pending until issue is addressed in ActiveRecord.

https://bugzilla.redhat.com/show_bug.cgi?id=1238179
@Fryguy Fryguy added the wip label Jul 13, 2015
@miq-bot
Copy link
Member

miq-bot commented Jul 14, 2015

Checked commits gtanzillo@8615ffe .. gtanzillo@432d7c2 with rubocop 0.32.0
4 files checked, 0 offenses detected
Everything looks good. 🍰

@gtanzillo gtanzillo removed the wip label Jul 14, 2015
@gtanzillo gtanzillo changed the title [WIP] BZ 1238179 - VM Utilization screen generating charts throws internal server error after Rails 4 BZ 1238179 - VM Utilization screen generating charts throws internal server error after Rails 4 Jul 14, 2015
@gtanzillo
Copy link
Member Author

@matthewd Please review when you have some time. Thx.

@mzazrivec
Copy link
Contributor

I'm able to verify that with the above changes in place, the chart screens now work
as expected (i.e. the chart renders correctly, without errors).

matthewd added a commit that referenced this pull request Jul 21, 2015
…tilization-screen

BZ 1238179 - VM Utilization screen generating charts throws internal server error after Rails 4
@matthewd matthewd merged commit e1a91ae into ManageIQ:master Jul 21, 2015
@matthewd matthewd added this to the Sprint 27 Ending August 3, 2015 milestone Jul 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants