-
Notifications
You must be signed in to change notification settings - Fork 897
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
Correctly recurse over nested field associations #18890
Correctly recurse over nested field associations #18890
Conversation
@miq-bot add_label bug |
@miq-bot add_label hammer/yes |
1f8cd07
to
2ece9be
Compare
Checked commit d-m-u@2ece9be with ruby 2.3.3, 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.
👍
path.flatten! | ||
fieldname_being_triggered = path.last | ||
while associations[fieldname_being_triggered] | ||
return [fieldname_being_triggered, (path & associations[fieldname_being_triggered]).first] if (path & associations[fieldname_being_triggered]).present? |
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 don't know if this is useful, but maybe we extract path & associations[fieldname_being_triggered]
into a local variable? &
is already pretty performant as far as I know, so even if both of the arrays are large that shouldn't be a big deal, it would really just be to understand exactly what path & associations[fieldname_being_triggered]
represents.
It's not necessary though, I'm going to approve regardless.
@bdunne any chance i could also con you into merging this one, please? |
can i get someone to review this or whatever again please |
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.
@d-m-u Did something else change? I don't see anything that looks out of place. 👍
sorry, Erik, nothing changed, I just, no one other than you's looking at this and I'd like to get it in |
@bdunne please review |
@tinaafitz please review |
2ece9be
to
186004f
Compare
hey @bdunne I'm getting asked to speed this one up, could you please review? |
de87e95
to
d0d7941
Compare
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. This looks much simpler. Thanks for taking this on!
@eclarizio can you re-review? |
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.
All of your it
block names seem kind of weird, they don't really describe what the test is testing (it "false"
and then the test is ensuring the return value is nil? or that it doesn't blow up? You have two it "trivial case"
blocks, one of them is expecting a nil return and the other is expecting an error), but as far as the actual code goes, it looks good to me.
Is there a reason we got rid of the specs in dialog_import_validator_spec.rb
around the circular reference stuff though?
Sure, I mean, since I'm not raising in the import validator any longer, the dialog_field_association_validator test cases handle the error stuff and I'm not sure what the import validator is supposed to be testing now. |
d0d7941
to
65b0e26
Compare
True, the error handling isn't there anymore, but right now you could comment out the entire line that delegates to the circular reference checker and the tests would all still pass because nothing is ensuring we go in there, I think. I think either a spec should be added to ensure work is being delegated to it, or maybe you feed it a circular reference and allow it to run through and bubble up expecting the error. |
65b0e26
to
efa01bf
Compare
Could I get you all to look again at this, please? It's subject to escalation at the moment |
@lfu @bdunne @jrafanie @eclarizio |
Correctly recurse over nested field associations (cherry picked from commit b7f78ba) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1725894
Hammer backport details:
|
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1720617
This originally caught (and returned) only the first of multiple nested fields that are linked via the dialog associations:
[fieldname_being_triggered, associations[fieldname_being_triggered].first]
and that's wrong, see the test case which was distilled straight from the bug.