-
Notifications
You must be signed in to change notification settings - Fork 900
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
Load virtual custom columns from miq expression automatically #11369
Load virtual custom columns from miq expression automatically #11369
Conversation
@@ -1539,6 +1551,27 @@ def self._quick_search?(e) | |||
end | |||
end | |||
|
|||
def custom_attribute_columns_and_models(expression = nil) | |||
return [] |
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.
short circuit? Is this PR a WIP PR?
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.
@Fryguy I had here some unwanted stuff
ed003ce
to
b17c012
Compare
@kbrock is it ok regard to perfomance ? methods for virtual custom attributes are created only when MiqExpression object is created and when there are already defined the creation is skipped. It is also finding recursively virtual_custom_attributes in expression for each MiqExpression object. |
b17c012
to
7e8e11c
Compare
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.
Trying to wrap my mind around this.
Not sure if we need to work so hard to be lazy about these.
We are taking the hit on creation of the MiqExpression
when the MiqExpression
only has a custom attribute in it. So this looks good to me.
Let me know when this is no longer WIP
@@ -34,6 +34,8 @@ def self.load_custom_attributes_for(cols) | |||
end | |||
|
|||
def self.add_custom_attribute(custom_attribute) | |||
return if respond_to?(custom_attribute) |
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.
this is great
d8fa377
to
4ba36ca
Compare
4ba36ca
to
d2e7ca5
Compare
at this moment depends on #11415 |
d2e7ca5
to
6880499
Compare
@miq-bot remove_label wip |
@kbrock @alongoldboim @imtayadeway - rebased and I added catching of expection. |
I'm good with this. I'll merge if @imtayadeway or @gtanzillo give a +1 |
|
||
it "automatically loads virtual custom attributes from MiqExpression on class" do | ||
MiqExpression.new("EQUAL" => {"field" => "#{klass}-#{virtual_custom_attribute}", "value" => "foo"}).to_sql | ||
expect(vm).to respond_to(virtual_custom_attribute) |
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.
Is there a way to prove that it was the line above that made this so?
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.
@imtayadeway I am not sure how to prove it.
maybe ?
expect(vm).not_to respond_to(virtual_custom_attribute)
MiqExpression.new("EQUAL" => {"field" => "#{klass}-#{virtual_custom_attribute}", "value" => "foo"}).to_sql
expect(vm).to respond_to(virtual_custom_attribute)
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 like that better 👍
Could also be:
expect {
MiqExpression.new(...)
}.to change { vm.respond_to?(virtual_custom_attrivute) }.from(false).to(true)
But whichever you prefer :)
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.
@imtayadeway I prefer change
👍 thanks
6880499
to
985ca22
Compare
Checked commits lpichler/manageiq@062ad5e~...985ca22 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 lib/miq_expression.rb
|
@gtanzillo can it be merged, if it looks good to you ? thanks! @alongoldboim need it for #11002 |
LGTM 👍 |
👍 LGTM |
@lpichler I've tagged as euwe/no. Let me know if this is not correct. |
we are loading virtual custom columns from MiqExpression when MiqExpression object is created ManageIQ#11369
@gtanzillo this should be euwe/yes, @alongoldboim's related PR are also euwe/yes @miq-bot add_label euwe/yes |
we are loading virtual custom columns from MiqExpression when MiqExpression object is created ManageIQ#11369 (cherry picked from commit 26f94a1)
@miq-bot remove_label euwe/no |
…rom_miq_expression Load virtual custom columns from miq expression automatically (cherry picked from commit 10d93a4)
Euwe Backport details: $ git log -1
commit e7832969d7eef5c2e228ddc71a05955d1fab6396
Author: Gregg Tanzillo <gtanzill@redhat.com>
Date: Wed Oct 5 18:18:29 2016 -0400
Merge pull request #11369 from lpichler/load_virtual_custom_columns_from_miq_expression
Load virtual custom columns from miq expression automatically
(cherry picked from commit 10d93a4a5761a3b5402fba20fccb1d807c51e174) |
Load virtual custom columns == create dynamically method which is virtual and such methods
contain loading attributes from table CustomAttribute and we are getting ability that attributes in CustomAttribute#name have behavior as normal column.
If we have some in MiqExpression we need to load them first. This PR is moving loading when MiqExpression object is created.
@miq-bot assign @gtanzillo
can you please review?
@imtayadeway @alongoldboim
WIP: requires fix: #11380 and #11415 [unmerged]