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

fix for serializers never including associations on cache hits #1276

Merged
merged 3 commits into from
Apr 1, 2016

Conversation

kieran
Copy link

@kieran kieran commented Oct 16, 2015

move @node assignment and the include_associations! call outside the cached response, since including associations produces the side-effect actually including the associations.

Previously, subsequent renders of a cached serializer would never include associations.

@NullVoxPopuli
Copy link
Contributor

Hi there! could you please add a test for this, so we clearly know the problem that is solved? thanks!

@chainlink
Copy link

+1

@kieran
Copy link
Author

kieran commented Oct 16, 2015

FYI my spec passes, but there are others which were broken as of the previous release

@gf3
Copy link

gf3 commented Oct 19, 2015

👍

@beauby
Copy link
Contributor

beauby commented Oct 19, 2015

I am not familiar with the 0.8 codebase so @joaomdmoura I'm assigning you (:

@jorgemanrubia
Copy link

👍 to this, thank you so much @kieran

Current version 0.8 is completely broken when it comes to caching objects with associations. It would be great to have this merged

@@ -476,9 +479,7 @@ def scope

def _serializable_hash
return nil if @object.nil?
@node = attributes
Copy link
Member

Choose a reason for hiding this comment

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

Why the change of node from attributes to _serializable_hash?

Copy link
Author

Choose a reason for hiding this comment

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

@node needs to be assigned outside of _serializable_hash, since associations can differ based on the serializer used, and the _serializable_hash method itself is cached inside serializable_hash

Copy link
Member

Choose a reason for hiding this comment

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

Ok, thanks. I'm not as familiar with the 0.8 code flow.

Do you think you can get CI passing?

Copy link
Author

Choose a reason for hiding this comment

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

@bf4 the specs seem to fail randomly trying to call read_attribute_for_serialization - the failures are not tied to versions of rails or ruby, and can change per run. The issue appears to be in the generated faker data, but I'm not exactly sure what's going on there.

Anyway, we've used this in production without issue since I opened this PR, so it's safe to merge.

Copy link
Member

Choose a reason for hiding this comment

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

@kieran I'm okay to merge then, since I'm trusting you, here :) It looks like you have run the specs locally, but you say they fail intermittently for you?

Copy link
Author

Choose a reason for hiding this comment

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

yeah, they do about 50% of the time. Something to do with the way fake objects are generated for testing.

@NullVoxPopuli
Copy link
Contributor

does this still apply? needs rebase if it does

kieran added 3 commits March 16, 2016 14:39
…cached response, since including associations produces the side-effect *actually* including the associations.

Previously, subsequent renders of a cached serializer would never include associations.
@kieran
Copy link
Author

kieran commented Mar 16, 2016

rebased, should merge now

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.

8 participants