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

Handle deprecated attributes (aliased) in VirtualArel.arel_attribute method #16489

Closed
wants to merge 1 commit into from

Conversation

gtanzillo
Copy link
Member

This fixes an MiqExpression bug where an error is raised attempting to get the arel_attribute of an aliased column. In the case of the bug, the column was aliased due to deprecation like this in the Host model -

deprecate_attribute :address, :hostname

The change adds an additional check for whether the column is an alias before attempting to look it up the field in the _virtual_arel hash which would result in nil. It instead falls into the else and calls super on it where it will get the name of the column it was aliased to.

https://bugzilla.redhat.com/show_bug.cgi?id=1507047

@gtanzillo
Copy link
Member Author

@kbrock Can you review this one?

@miq-bot
Copy link
Member

miq-bot commented Nov 16, 2017

Checked commit gtanzillo@9b5c580 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. ⭐

def self.connection
TestClassBase.connection
end
deprecate_attribute :old_col1, :col1
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you consider adding a new, deprecated column to the existing TestClass? Alternatively, you could add a separate context for the test you added below with its own before/after hooks to manage the lifecycle of this fixture, so that it's not setup/torn down for a lot of tests that don't use it

Copy link
Member

Choose a reason for hiding this comment

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

👍 I think you could just add this to an existing test class

@gtanzillo
Copy link
Member Author

@kbrock Can you please review? This one addresses a Gaprindashvili blocker BZ. Thanks!

@gtanzillo
Copy link
Member Author

Closing in favor of #16560

@gtanzillo gtanzillo closed this Nov 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants