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

Add relationships support for pointers in errors #986

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

Merged
sliverc merged 4 commits into django-json-api:master from mehdy:master
Oct 7, 2021

Conversation

Copy link
Contributor

@mehdy mehdy commented Oct 3, 2021
edited
Loading

Fixes #413

Description of the Change

When formatting DRF errors, use relationships in the pointer when the field is actually a relationship.

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

Copy link
Contributor Author

mehdy commented Oct 3, 2021

@sliverc This is my draft attempt at solving the problem. I was wondering if you could give me some hints on whether I'm headed in the right direction or not?

Copy link

codecov bot commented Oct 3, 2021
edited
Loading

Codecov Report

Merging #986 (24de3fa) into master (0816192) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@ Coverage Diff @@
## master #986 +/- ##
==========================================
+ Coverage 96.83% 96.84% +0.01% 
==========================================
 Files 65 65 
 Lines 3914 3929 +15 
==========================================
+ Hits 3790 3805 +15 
 Misses 124 124 
Impacted Files Coverage Δ
example/tests/snapshots/snap_test_errors.py 100.00% <100.00%> (ø)
example/tests/test_errors.py 100.00% <100.00%> (ø)
rest_framework_json_api/renderers.py 90.15% <100.00%> (ø)
example/utils.py 92.67% <0.00%> (+0.30%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0816192...24de3fa. Read the comment docs.

Copy link
Member

sliverc commented Oct 3, 2021

Yes you are on the right track. included_serializers is optional though so not the right way to determine whether a field is a relationship. See here how an attribute is distinguished from relationship in the renderer.

Copy link
Contributor Author

mehdy commented Oct 3, 2021

@sliverc Great! Thanks!

@mehdy mehdy changed the title (削除) WIP: Add relationships support for pointers in errors (削除ここまで) (追記) Add relationships support for pointers in errors (追記ここまで) Oct 3, 2021
Copy link
Contributor Author

mehdy commented Oct 3, 2021

@sliverc
I think this is ready for review.
Just let me know if I should add it to CHANGELOG.md and/or the docs.

Copy link
Contributor Author

mehdy commented Oct 5, 2021

@sliverc I couldn't understand why codecov is failing. Should I do something?

Copy link
Member

@sliverc sliverc left a comment

Choose a reason for hiding this comment

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

Thanks for working on this. Please see my inline comments.

mehdy reacted with thumbs up emoji
Copy link
Contributor Author

mehdy commented Oct 6, 2021

@sliverc Resolved all the issues you mentioned.

Copy link
Member

@sliverc sliverc left a comment

Choose a reason for hiding this comment

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

This PR is shaping up nicely. See some small comments inline.

mehdy reacted with hooray emoji
Copy link
Contributor Author

mehdy commented Oct 6, 2021

@sliverc Done as well. Thanks for the tips.

Copy link
Member

@sliverc sliverc left a comment

Choose a reason for hiding this comment

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

Thanks for the changes. Somewhat one of my comment got swallowed (maybe had to many tabs open... 😄 ) See last comment, also rebase to current master and then this PR is good to merge.

Copy link
Member

sliverc commented Oct 6, 2021

and totally forgot please also add a changelog entry.

mehdy reacted with thumbs up emoji

mehdy added 3 commits October 6, 2021 22:55
Signed-off-by: Mehdy Khoshnoody <mehdy.khoshnoody@gmail.com>
Signed-off-by: Mehdy Khoshnoody <mehdy.khoshnoody@gmail.com>
Signed-off-by: Mehdy Khoshnoody <mehdy.khoshnoody@gmail.com>
Copy link
Contributor Author

mehdy commented Oct 6, 2021

@sliverc I think we're good to go :D

Signed-off-by: Mehdy Khoshnoody <mehdy.khoshnoody@gmail.com>
Copy link
Member

@sliverc sliverc left a comment

Choose a reason for hiding this comment

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

Thanks for the changes and your time putting into making this work. Very appreciated.

It seems that you (your IDE?) autoformatted the changelog markdown file (I guess with prettier?). There were quite a few changes... I reverted those to make this PR ready. But certainly something to think about whether as DJA we want to autoformat md files but I guess part of another discussion.

Thanks again.

@sliverc sliverc merged commit ee679ee into django-json-api:master Oct 7, 2021
Copy link
Contributor Author

mehdy commented Oct 7, 2021

@sliverc You're very welcome!
Sorry about the autoformat. Thanks for taking care of it though. :D

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

@sliverc sliverc sliverc approved these changes

+1 more reviewer

@auvipy auvipy auvipy approved these changes

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Error pointer always refers to the attributes

AltStyle によって変換されたページ (->オリジナル) /