-
Notifications
You must be signed in to change notification settings - Fork 898
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
Fixed error with dialog expression when virtual column involved #17215
Fixed error with dialog expression when virtual column involved #17215
Conversation
@miq-bot assign @gtanzillo |
This is the same as #16514 |
@miq-bot add-label gaprindashvili/yes |
57a027e
to
3d65dc0
Compare
@kbrock Please review |
it "removes :token key from passed expression" do | ||
exp = {"=" => {"field" => "Vm-active", "value" => "true"}, :token => 1} | ||
test_obj.exp_replace_qs_tokens(exp, {}) | ||
expect(exp).to eq("=" => {"field" => "Vm-active", "value" => "true"}) |
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 looks good. But it may be good to test with a more complex expression. Something like -
{"and"=>[{"="=>{"field"=>"Vm-active", "value"=>"true"}, :token => 1}, {"="=>{"field"=>"Vm-archived", "value"=>"true"}, :token => 1}], :token => 1}
Just a suggestion
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.
@gtanzillo ok, make sense, will do with this expression:
{"and"=>[{"="=>{"field"=>"Vm-active", "value"=>"true"}, :token => 1}, {"="=>{"field"=>"Vm-archived", "value"=>"true"}, :token => 1}]}
. (there is no tokens added on the level of and
or or
)
…ing token will make expression evaluation failed. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1558926
1daa294
to
a199611
Compare
Checked commits yrudman/manageiq@40ba300~...a199611 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
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.
deleting the :token
looks good.
Not exactly sure where/why it was added.
I'm good with this.
But would it make more sense for the ui that added the :token
key to remove it?
…xpression-after-substitution Fixed error with dialog expression when virtual column involved (cherry picked from commit 54589f6) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1565139
Gaprindashvili backport details:
|
ISSUE:
When virtual column involved in expression for automate method than error raised during attempt to order service. Error
operator 'token' is not supported...
raised whenMiqExpression
trying to convert expression to sql.The same expression works fine in other places, like report.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1558926
Automation vs Report:
Automation do special pre-processing of expression (before converting to sql) and substitute value in expression with supplied tokens (if any). This pre-processing includes adding temporary entry like
:token=>1
and supposed to be removed after automation specific pre-processing finished.There is place on UI side were those temporary tokens removed before saving record: https://github.com/ManageIQ/manageiq-ui-
classic/blob/f16e3f542c0463773ca19291ddd8884e8863aa9c/app/controllers/application_controller/filter.rb#L343 , but there is no clean-up on automation side during method invocation
FIX:
Remove temporary tokens from expression during token substitution.
It would allow to skip attempt to transfer expression
to_sql
here:manageiq/lib/miq_expression.rb
Line 289 in 9e95f2b
EXPRESSION:
BEFORE:
AFTER:
@miq-bot add-label bug
\cc @gtanzillo @gmcculloug