-
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
Do not raise error in MiqExpression#to_sql if (:token) present as one of operators #19176
Do not raise error in MiqExpression#to_sql if (:token) present as one of operators #19176
Conversation
@kbrock can you review |
…or expression is not supportyed and extra entry (:token) was present in MiqExpression's Hash. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1741243
3286763
to
3ad5e19
Compare
looked over the other PR. Why are we adding an invalid tag (i.e.: |
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.
options in order of preference:
- Don't put invalid entries (i.e.
:token
) into the expression - The code responsible for adding the
:token
should remove it MiqExpresion
supports having:token
in the treeMiqExpression
remove:token
from the hash
Since @mkanoor seems to not want 1. And it looks like 2 is difficult, can we go with 3?
I'd really prefer to avoid option 4. (and I probably missed other options.)
lib/miq_expression.rb
Outdated
@@ -285,7 +285,7 @@ def self._to_ruby(exp, context_type, tz) | |||
|
|||
def to_sql(tz = nil) | |||
tz ||= "UTC" | |||
@pexp, attrs = preprocess_for_sql(@exp.deep_clone) | |||
@pexp, attrs = preprocess_for_sql(@exp.deep_clone.except!(:token)) |
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'd prefer we don't go this route
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.
@kbrock is you objection because it looks as a "dirty fix" ?
on the bright side it is very save (modification done on clone) and will not do any harm now and in the future
I am not clear what you mean by solution 3.
Everywhere in the code of MiqExpression
we assumed that only single entry in the top level of Hash is present, this code operator = exp.keys.first
is all over
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.
Checked commits yrudman/manageiq@3ad5e19~...759a67d with ruby 2.4.6, rubocop 0.69.0, 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.
like the change
…-initializiing-miq-expression Do not raise error in MiqExpression#to_sql if (:token) present as one of operators (cherry picked from commit 4c39040) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1761525
Hammer backport details:
|
…-initializiing-miq-expression Do not raise error in MiqExpression#to_sql if (:token) present as one of operators (cherry picked from commit 4c39040) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1784097
Ivanchuk backport details:
|
ISSUE: Sometimes
:token
key (used in automate) is not removed fromMiqExpression
'sHash
before saving or attempting to execute.This will trigger below Error if another entry in MiqExpression does not support SQL generation:
Note: if another entry in
MiqExpression
does support SQL generation than no Error; it may explain why this bug was not found before.FIX: remove
:token
from MiqExpression's Hash before attempting to generate SQLFixes https://bugzilla.redhat.com/show_bug.cgi?id=1741243
There is another PR #17215 on the same topic, but apparently it did not solve issue for all situations.
@miq-bot add-label changelog/no, bug, core, hammer/yes, ivanchuk/yes