-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
Hi there! could you please add a test for this, so we clearly know the problem that is solved? thanks! |
+1 |
FYI my spec passes, but there are others which were broken as of the previous release |
👍 |
I am not familiar with the 0.8 codebase so @joaomdmoura I'm assigning you (: |
👍 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 |
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.
Why the change of node from attributes
to _serializable_hash
?
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.
@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
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.
Ok, thanks. I'm not as familiar with the 0.8 code flow.
Do you think you can get CI passing?
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.
@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.
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.
@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?
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.
yeah, they do about 50% of the time. Something to do with the way fake objects are generated for testing.
does this still apply? needs rebase if it does |
…cached response, since including associations produces the side-effect *actually* including the associations. Previously, subsequent renders of a cached serializer would never include associations.
rebased, should merge now |
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.