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

Replace class objects in query values with strings to fix a rails 5.0 deprecation #18827

Conversation

jrafanie
Copy link
Member

Fixes the following on rails 5.0:

DEPRECATION WARNING: Passing a class as a value in an Active
Record query is deprecated and will be removed. Pass a string instead.
(called from put_or_update at
/var/www/miq/vmdb/app/models/miq_queue.rb:343)

In rails 5.1, you get this if you try using a class object:

> MiqQueue.where(:class_name => MiqServer)
TypeError (can't cast Class)

Note, these were picked up in the QE test suite.

@jrafanie jrafanie requested a review from bdunne May 30, 2019 21:20
@jrafanie
Copy link
Member Author

@bdunne 🍰 🍪

:active => {
:class_name => MiqProvision.name, :ids => [], :storage_by_id => Hash.new { |k, v| k[v] = 0 },
:class_name => "MiqProvision", :ids => [], :storage_by_id => Hash.new { |k, v| k[v] = 0 },
Copy link
Member Author

@jrafanie jrafanie May 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bonus change that doesn't raise the deprecation but prevents autoload here and the above two places.

jrafanie added a commit to jrafanie/manageiq that referenced this pull request May 30, 2019
Fixes:
DEPRECATION WARNING: Passing a class as a value in an Active Record query is deprecated and will be removed. Pass a string instead. (called from block in <class:ExtManagementSystem> at /Users/joerafaniello/Code/manageiq/app/models/ext_management_system.rb:107)

Similar to ManageIQ#18827
Fixes the following on rails 5.0:
DEPRECATION WARNING: Passing a class as a value in an Active
Record query is deprecated and will be removed. Pass a string instead.
(called from put_or_update at
/var/www/miq/vmdb/app/models/miq_queue.rb:343)

In rails 5.1, you get this if you try using a class object:
> MiqQueue.where(:class_name => MiqServer)
TypeError (can't cast Class)
@jrafanie jrafanie force-pushed the fix_passing_a_class_as_a_value_in_an_active_record_query_deprecation branch from 06b63a6 to 6ed429d Compare May 30, 2019 21:53
@miq-bot
Copy link
Member

miq-bot commented May 30, 2019

Checked commit jrafanie@6ed429d with ruby 2.3.3, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
6 files checked, 0 offenses detected
Everything looks fine. ⭐

@bdunne bdunne merged commit fcdfe30 into ManageIQ:master May 31, 2019
@bdunne bdunne self-assigned this May 31, 2019
@bdunne bdunne added this to the Sprint 113 Ending Jun 10, 2019 milestone May 31, 2019
mzazrivec added a commit to mzazrivec/manageiq-ui-classic that referenced this pull request May 31, 2019
jrafanie added a commit to jrafanie/manageiq that referenced this pull request May 31, 2019
Fixes:
DEPRECATION WARNING: Passing a class as a value in an Active Record query is deprecated and will be removed. Pass a string instead. (called from block in <class:ExtManagementSystem> at /Users/joerafaniello/Code/manageiq/app/models/ext_management_system.rb:107)

Similar to ManageIQ#18827
jrafanie added a commit to jrafanie/manageiq that referenced this pull request May 31, 2019
Rails 5.1 dropped support for query values of type Class, and we should
have fixed most of them with ManageIQ#18827 and ManageIQ#18829, but since detecting
callers to put_or_update that do this could be difficult, we can still
support this by "fixing" it so rails 5.1 doesn't raise an exception,
and give us time to fix the caller.
thearifismail pushed a commit to thearifismail/manageiq that referenced this pull request Jun 3, 2019
Fixes:
DEPRECATION WARNING: Passing a class as a value in an Active Record query is deprecated and will be removed. Pass a string instead. (called from block in <class:ExtManagementSystem> at /Users/joerafaniello/Code/manageiq/app/models/ext_management_system.rb:107)

Similar to ManageIQ#18827
thearifismail pushed a commit to thearifismail/manageiq that referenced this pull request Jun 3, 2019
Rails 5.1 dropped support for query values of type Class, and we should
have fixed most of them with ManageIQ#18827 and ManageIQ#18829, but since detecting
callers to put_or_update that do this could be difficult, we can still
support this by "fixing" it so rails 5.1 doesn't raise an exception,
and give us time to fix the caller.
@jrafanie jrafanie deleted the fix_passing_a_class_as_a_value_in_an_active_record_query_deprecation branch October 4, 2019 19:46
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.

3 participants