Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ensured that no fields are returned when sparse fields is set to an empty value#1240

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

sliverc
Copy link
Member

Fixes#1238

Description of the Change

When a sparse field is set to an empty value no fields (attributes/relationships) should be rendered whereas currently it rendered all fields.

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added
  • documentation updated
  • CHANGELOG.md updated (only for user relevant changes)
  • author name inAUTHORS

@slivercsliverc requested a review fromn2ygkJune 27, 2024 19:35
Copy link
Contributor

@n2ygkn2ygk left a comment

Choose a reason for hiding this comment

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

I think the current behavior is supported by the spec:

If a client does not specify the set of fields for a given resource type, the server MAY send all fields, a subset of fields, or no fields for that resource type.

https://jsonapi.org/format/
8.4 Sparse Fieldsets

It could break a lot of implementations. Perhaps add a setting.

@sliverc
Copy link
MemberAuthor

I agree that the sentence you mentioned is a bit ambiguous, however it would not make any sense to first specify thatThe value of any fields[TYPE] parameter MUST and then afterward say that theserver MAY. So the sentence you mention is, as far as I see it, if there is no query parameter set at all for a given resource type, but not if it is explicitly set to an empty value.

In any case, I have double-checked what was the behavior before change#1221. It turned out when defining an empty value it would also return no fields. So this means it is a regression and this PR will revert to the behavior we had before version 7.0.0. I have clarified this in the changelog as well now.

@n2ygkn2ygk merged commitd1163ce intodjango-json-api:mainJun 28, 2024
11 checks passed
@slivercsliverc deleted the sparse_fields_empty_value branchJune 28, 2024 14:04
@sliverc
Copy link
MemberAuthor

Thanks@n2ygk for merging. Let me prepare a release to get those regressions out of the way.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@n2ygkn2ygkn2ygk approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Sparse field set should not return all fields when value is empty
2 participants
@sliverc@n2ygk

[8]ページ先頭

©2009-2025 Movatter.jp