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

MiqExpression#contains improvement #20199

Merged
merged 5 commits into from
Jun 18, 2020

Conversation

kbrock
Copy link
Member

@kbrock kbrock commented May 21, 2020

Before

  • MiqExpression only supports contains value and tags for limited models.
  • MiqExpression has a lot of code around determining what contains is supported.

After

  • MiqExpression supports contains values and tags for any models reachable by non-virtual associations.
  • MiqExpression now uses MiqExpression::Target#*_supports_sql? instead of rewriting that logic.

added 36 lines of tests and 10 lines of comments - so feature for nothing and the code for free :)

@kbrock kbrock changed the title Miq expression expansion MiqExpression CONTAINS expansion May 21, 2020
@miq-bot
Copy link
Member

miq-bot commented May 22, 2020

Checked commits kbrock/manageiq@086b836~...f01c37e with ruby 2.5.7, rubocop 0.69.0, haml-lint 0.28.0, and yamllint
7 files checked, 0 offenses detected
Everything looks fine. 🏆

@kbrock kbrock changed the title MiqExpression CONTAINS expansion MiqExpression improved CONTAINS May 22, 2020
@kbrock kbrock changed the title MiqExpression improved CONTAINS MiqExpression#contains improvement May 22, 2020
@@ -1373,8 +1367,8 @@ def to_arel(exp, tz)
# Only support for tags of the main model
if exp[operator].key?("tag")
tag = Tag.parse(exp[operator]["tag"])
ids = tag.model.find_tagged_with(:any => parsed_value, :ns => tag.namespace).pluck(:id)
tag.model.arel_attribute(:id).in(ids)
ids = tag.target.find_tagged_with(:any => parsed_value, :ns => tag.namespace).pluck(:id)
Copy link
Member Author

Choose a reason for hiding this comment

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

I can change this to not pluck the id and become an inner query.
It would remove some arel, but would add a few lines to make that work smothly

Copy link
Member

@gtanzillo gtanzillo left a comment

Choose a reason for hiding this comment

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

LGTM, reviewed with @kbrock

@kbrock
Copy link
Member Author

kbrock commented Jun 18, 2020

kicking

@kbrock kbrock closed this Jun 18, 2020
@kbrock kbrock reopened this Jun 18, 2020
@gtanzillo gtanzillo merged commit 7f1051f into ManageIQ:master Jun 18, 2020
@kbrock kbrock deleted the miq_expression_expansion branch June 23, 2020 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants