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

Ensured that sparse fields only applies when rendering not when parsing #1221

Merged
merged 4 commits into from
May 1, 2024

Conversation

sliverc
Copy link
Member

@sliverc sliverc commented Apr 19, 2024

Fixes #1216
Fixes #332

Description of the Change

The rendering of objects is flawed as the DJA renderer does most of the serialization again which should actually only be done by the serializer. Even though I reduced the readable fields in the serializer when sparse fields is used, it did not work.

I already adjusted extract_attributes that it uses the fields provided by the serializer. To adjust extract_relationships is more complex. Therefore, to get this critical issue fixed I also added code to exclude fields in the renderer when sparse fields is used.

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 in AUTHORS

@sliverc sliverc marked this pull request as ready for review April 30, 2024 19:42
@sliverc sliverc requested a review from n2ygk April 30, 2024 19:42
@sliverc
Copy link
Member Author

sliverc commented Apr 30, 2024

Codecov does not pass as it highlights two lines which I did change in this pull request but only changing the import not the functionality. There was no test for these lines before. I would say we ignore it, but I am open to revert the change to clean up the utils import in the renderer.

@n2ygk n2ygk merged commit 6c609f8 into django-json-api:main May 1, 2024
10 of 11 checks passed
@sliverc sliverc deleted the create_sparse_fields branch May 2, 2024 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants