-
Notifications
You must be signed in to change notification settings - Fork 5
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
Cached loadRelations result incorrectly reused for different objects. #33
Comments
Think this is the issue:
Plus using '?' as the id for the hasOne relations find. |
I quick fix for the hasOne relation is to replace the 'id' with the relationship ID. var relationId = options.jsonApi.jsonApiPath;
return childResourceDef.find(relationId, options).then(//... |
Need to add some tests for this change |
You are quite right. I apologize for not including tests. I can probably work on some next week. My thoughts would be to setup two primary objects with 1 hasOne and 1 hasMany relationships. We would then want to load object 1's hasOne relationship followed by object 2's and confirm that they are different results. Same with the hasMany relationship. Not sure if we need to cover belongsTo. And it would also be good to confirm that the cacheing is actually functioning correctly. However I'm not sure how to do that off hand. |
Yes i agree with above. I would comment out the changes that fix this issue. Create the test and check that it fails. Then un-comment the changes and ensure the test passes. Checking caching is working correctly |
Basically if you use LoadRelations in a loop for the same relationship the first call is used for every future call.
Trying to trace through now to figure out why loadRelations treats the request for
/v3/reports/123/comments
as the same as/v3/reports/456/comments
.The text was updated successfully, but these errors were encountered: