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

Group AND expressions properly to account for nesting #18709

Merged
merged 1 commit into from
May 2, 2019

Conversation

d-m-u
Copy link
Contributor

@d-m-u d-m-u commented Apr 30, 2019

The sql generated for a nested expression à la c OR(a AND b) is incorrect because we're not wrapping the inside expression when it's an AND. This just adds the wrapping to all ANDs. It results in extra parens in a couple cases but while not having the parens is occasionally detrimental, having too many is never going to hurt us so we should err on the side of too many, methinks.

Fixes part of https://bugzilla.redhat.com/show_bug.cgi?id=1660460
It'll require UI changes as well because https://bugzilla.redhat.com/show_bug.cgi?id=1660460#c8 is still an issue

@d-m-u
Copy link
Contributor Author

d-m-u commented Apr 30, 2019

@miq-bot add_label bug
@miq-bot add_label hammer/yes
@miq-bot add_reviewer @jrafanie
@miq-bot add_reviewer @kbrock

@d-m-u
Copy link
Contributor Author

d-m-u commented Apr 30, 2019

@miq-bot assign @jrafanie

@d-m-u d-m-u force-pushed the fixing_arel_node_grouping_for_and branch from d995e4d to 8875a22 Compare April 30, 2019 18:43
@miq-bot
Copy link
Member

miq-bot commented Apr 30, 2019

Checked commit d-m-u@8875a22 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🍪

@d-m-u
Copy link
Contributor Author

d-m-u commented May 1, 2019

@miq-bot add_label changelog/yes

Copy link
Member

@jrafanie jrafanie left a comment

Choose a reason for hiding this comment

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

LGTM, I worked with @d-m-u on this... @gtanzillo do you have any concern with doing this? It fixes an issue where we were not properly grouping the AND atoms in "A OR B AND C" by always grouping AND expressions. I think this is extra caution but shouldn't break anything if we do needless extra grouping, right?

Copy link
Member

@kbrock kbrock left a comment

Choose a reason for hiding this comment

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

:shipit: parens are our friends

@kbrock kbrock assigned kbrock and unassigned jrafanie May 2, 2019
@kbrock kbrock added this to the Sprint 111 Ending May 13, 2019 milestone May 2, 2019
@kbrock
Copy link
Member

kbrock commented May 2, 2019

Stole - @jrafanie worked on this with @d-m-u and was too close to merge

@kbrock kbrock merged commit 5c506fd into ManageIQ:master May 2, 2019
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.

Nice work 👍

simaishi pushed a commit that referenced this pull request Jun 14, 2019
Group AND expressions properly to account for nesting

(cherry picked from commit 5c506fd)

https://bugzilla.redhat.com/show_bug.cgi?id=1720753
@simaishi
Copy link
Contributor

Hammer backport details:

$ git log -1
commit 581d68f438469225b9d95426ce15d304db7f3d50
Author: Keenan Brock <keenan@thebrocks.net>
Date:   Thu May 2 09:54:38 2019 -0600

    Merge pull request #18709 from d-m-u/fixing_arel_node_grouping_for_and
    
    Group AND expressions properly to account for nesting
    
    (cherry picked from commit 5c506fda3951e5efb724385aca145f5877ae6525)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1720753

@d-m-u d-m-u deleted the fixing_arel_node_grouping_for_and branch September 26, 2019 10:35
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.

6 participants