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

Fixes #1211, include_tree is null when using the key: options #1214

Merged
merged 1 commit into from
Oct 2, 2015

Conversation

NullVoxPopuli
Copy link
Contributor

Fixes #1211, and Closes #1212

Thanks @hut8 for the failing test!

@@ -92,7 +92,7 @@ def associations(include_tree = DEFAULT_INCLUDE_TREE)

Enumerator.new do |y|
self.class._reflections.each do |reflection|
next unless include_tree.key?(reflection.name)
next unless include_tree.try(:key?, reflection.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

This fix is not right, because then you can never explicitly include an association with a custom key.

Copy link
Contributor

Choose a reason for hiding this comment

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

Clearly, the test should be on reflection.key instead of reflection.name in order to handle custom keys (reflection.key falls back to reflection.name anyways if one was not provided). I'm still trying to understand what caused include_tree to be nil though.

@NullVoxPopuli
Copy link
Contributor Author

ok, hopefully the build passes.

any other out standing concerns?

@@ -92,7 +92,8 @@ def associations(include_tree = DEFAULT_INCLUDE_TREE)

Enumerator.new do |y|
self.class._reflections.each do |reflection|
next unless include_tree.key?(reflection.name)
key = reflection.options.fetch(:key, reflection.name)
next unless include_tree.key?(key)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@NullVoxPopuli
Copy link
Contributor Author

yay it passed!

@NullVoxPopuli
Copy link
Contributor Author

rebased

@beauby
Copy link
Contributor

beauby commented Oct 2, 2015

LGTM, let's squash and merge.

@NullVoxPopuli
Copy link
Contributor Author

done

@NullVoxPopuli
Copy link
Contributor Author

the author says hut8, should that be changed? he did point out the issue and gave us a failing test :-)

@beauby
Copy link
Contributor

beauby commented Oct 2, 2015

He did point out the issue so that seems fair.

@hut8
Copy link
Contributor

hut8 commented Oct 2, 2015

I'm fine with @NullVoxPopuli being the author. I wrote the failing test but he fixed it which is really what counts.

@NullVoxPopuli
Copy link
Contributor Author

@hut8, I'm leaving you as the author, to show how thankful we are that you found the bug, and gave us the test. :-)

beauby added a commit that referenced this pull request Oct 2, 2015
Fix #1211, include_tree is null when using the key: options
@beauby beauby merged commit 34d6571 into rails-api:master Oct 2, 2015
This pull request was closed.
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