Pass rel_opts when filtering records for record count#1234
Closed
hatch-carl wants to merge 1 commit intoJSONAPI-Resources:release-0-9from
Closed
Pass rel_opts when filtering records for record count#1234hatch-carl wants to merge 1 commit intoJSONAPI-Resources:release-0-9from
rel_opts when filtering records for record count#1234hatch-carl wants to merge 1 commit intoJSONAPI-Resources:release-0-9from
Conversation
Naturally I uncovered this because it caused a more complex bug in my app. The problem here is that if you have a filter which depends on something that is set in, for example, the context, you will not have that context when the filter is re-invoked for record count, which happens when the record count configuration is active. This only happens when fetching related resources. In this case I add a test where we try to fetch an author's banned books, of which there should be only one. However, because the prior code discards the rel_opts and instead provides an empty hash (!) the filter does not execute because it will only operate when an admin user is in the context.
lgebhardt
pushed a commit
that referenced
this pull request
Mar 22, 2019
Naturally I uncovered this because it caused a more complex bug in my app. The problem here is that if you have a filter which depends on something that is set in, for example, the context, you will not have that context when the filter is re-invoked for record count, which happens when the record count configuration is active. This only happens when fetching related resources. In this case I add a test where we try to fetch an author's banned books, of which there should be only one. However, because the prior code discards the rel_opts and instead provides an empty hash (!) the filter does not execute because it will only operate when an admin user is in the context. Closes gh-1234
Contributor
|
@hatch-carl Thanks! |
st0012
pushed a commit
to st0012/jsonapi-resources
that referenced
this pull request
Aug 20, 2019
Naturally I uncovered this because it caused a more complex bug in my app. The problem here is that if you have a filter which depends on something that is set in, for example, the context, you will not have that context when the filter is re-invoked for record count, which happens when the record count configuration is active. This only happens when fetching related resources. In this case I add a test where we try to fetch an author's banned books, of which there should be only one. However, because the prior code discards the rel_opts and instead provides an empty hash (!) the filter does not execute because it will only operate when an admin user is in the context. Closes JSONAPI-Resourcesgh-1234
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Naturally I uncovered this because it caused a more complex bug in my app.
The problem here is that if you have a filter which depends on something
that is set in, for example, the context, you will not have that context
when the filter is re-invoked for record count, which happens when the
record count configuration is active. This only happens when fetching
related resources.
In this case I add a test where we try to fetch an author's banned books,
of which there should be only one. However, because the prior code
discards the rel_opts and instead provides an empty hash (!) the filter
does not execute because it will only operate when an admin user is in
the context. The failing test then reports the record count as 3, where it should be 1. The change to the processor class solves this issue.