-
Notifications
You must be signed in to change notification settings - Fork 904
[WIP] Remove <value> nodes from MiqExpression#to_ruby #23104
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
base: master
Are you sure you want to change the base?
Conversation
@Fryguy When @jrafanie was working through performance for So I had started modifying Got a little bit of a wrench for the Question: Do you feel this is a good direction or too much of a tangent? |
This pull request has been automatically marked as stale because it has not been updated for at least 3 months. If these changes are still valid, please remove the |
8021a8c
to
e9d9f18
Compare
This pull request has been automatically marked as stale because it has not been updated for at least 3 months. If these changes are still valid, please remove the |
1 similar comment
This pull request has been automatically marked as stale because it has not been updated for at least 3 months. If these changes are still valid, please remove the |
lib/miq_expression.rb
Outdated
def lenient_evaluate(obj, timezone = nil, prune_sql: false) | ||
def evaluate(obj, timezone = nil, prune_sql: false, lenient: false) | ||
ruby_exp = to_ruby(timezone, :prune_sql => prune_sql) | ||
ruby_exp.nil? || Condition.subst_matches?(ruby_exp, obj) | ||
end | ||
|
||
def evaluate(obj, tz = nil) | ||
ruby_exp = to_ruby(tz) | ||
Condition.subst_matches?(ruby_exp, obj) | ||
ruby_exp.nil? ? lenient : Condition.subst_matches?(ruby_exp, obj) |
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.
def lenient
ruby_exp = to_ruby(timezone, :prune_sql => prune_sql)
ruby_exp.nil? ? true : Condition.subst_matches?(ruby_exp, obj)
end
def evaluate
ruby_exp = to_ruby(tz)
# ruby_exp is never null?
ruby_exp.nil? ? nil : Condition.subst_matches?(ruby_exp, obj)
end
def evaluate
ruby_exp = to_ruby(timezone, :prune_sql => prune_sql)
if ruby_exp.nil?
if lenient
return true
else
return false # noop ??? verify
end
end
Condition.subst_matches?(ruby_exp, obj)
end
def evaluate
ruby_exp = to_ruby(timezone, :prune_sql => prune_sql)
ruby_exp.nil? ? lenient : Condition.subst_matches?(ruby_exp, obj)
end
Since we know non-lenient ruby_exp must always be present (it throws an exception so we know the path is not valid) I wonder if we can drop the non-lenient form of evaluate
.
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 code moved to #23467
e9d9f18
to
a75fa45
Compare
This allows us to use `rec` in the expression and not have to post evaluate the to_ruby output Skipped over the associations and the find clauses Also skipped the hash contexts
a75fa45
to
b7f07cc
Compare
Some comments on commit kbrock@b7f07cc spec/lib/miq_expression_spec.rb
|
Checked commit kbrock@b7f07cc with ruby 3.1.5, rubocop 1.56.3, haml-lint 0.62.0, and yamllint app/models/condition.rb
lib/miq_expression.rb
|
Overview
For now, this is only changes simple expressions like
Host-name
and not those with an associationVm.host-name
.It also does not change
<find>
clauses.Looking for feedback on whether this is a good route. (I'm happy to merge code)
Before
After