-
Notifications
You must be signed in to change notification settings - Fork 900
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
Allow order fields to be subqueries with order #18909
Conversation
RE Rubocops: - I copy and pasted these bits from the rails code. |
fa0c7e0
to
146c09a
Compare
cc @jrafanie |
@kbrock Can you make the first commit the current code in rails (include which rails version you're pulling from... I have no idea if it's changed in 5.1 -> 5.2 -> 6), and then apply your patch in the second commit... It should make this easier to dissect. I'm pretty lost. |
db39bc9
to
bf2d349
Compare
@jrafanie ok, updated. is this easier to figure out? |
s = collector.value | ||
end | ||
end | ||
# Remove any ASC/DESC modifiers |
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 comment should be updated to reflect the conditional you're doing here. We should explain that there's an existing ORDER clause so we want to retain any ASC/DESC.
This lets us see just what was done in the money patch
Fields like last_compliance_status (on VmOrTemplate.yaml) contain a limit and order. This is because the column joins to a has_many and references the most recent record. ManageIQ/manageiq-ui-classic#5374
Checked commits kbrock/manageiq@18f71ad~...e237d0a with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 lib/extensions/ar_order.rb
|
Note, ignoring cops because it's rails code... we're trying to avoid making unrelated changes to the core rails code. |
@kbrock did you test the UI suite with this PR? |
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.
LGTM, I'll merge when we get confirmation that UI classic test suite works with this change.
@jrafanie ui classic passed |
Allow order fields to be subqueries with order (cherry picked from commit 5d6eb83) https://bugzilla.redhat.com/show_bug.cgi?id=1738266
Hammer backport details:
|
Other note - it also addresses https://bugzilla.redhat.com/show_bug.cgi?id=1745660 |
@miq-bot add_label rails5.2 |
Fixes: ManageIQ/manageiq-ui-classic#5374
Overview
Virtual fields that reference a
has_many
relationship, often need to have aLIMIT
andORDER
in the field definition.When rails works with these fields in an
ORDER BY
clause, they sometimes add that field to theSELECT
clause for Sql reasons. In that process, they munge the field and break things.Before
We see this issue on the Vm explorer page. If we sort by
compliance
(i.e.last_compliance_status
) it blows up:After
I put in a Rails PR that avoids string munging and leverages Arel. In the mean time, this PR is a monkey patch to our codebase with the same code that fixes the problem in the short term.