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

fix: OneToManyInput saves and runs validation on foreign key #487 #490

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

keithhackbarth
Copy link
Contributor

Description

Fix for issue described in #487

Notes:

  • Used django_assert_max_num_queries to write test
  • Reduced the number of queries for a "patch" update from 25 to 12
  • test_relation.py was blank so deleted it.
  • As a new contributor, I found it confusing which tests go where so added docstring to test_relationship to clarify my understanding

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

PR Type: Bug fix

PR Summary: This pull request addresses a specific issue with the handling of foreign key relationships in mutations, specifically aiming to optimize the process and reduce the number of database queries required for 'patch' updates. It introduces logic to handle cases where a foreign object is not found by creating it and skips updates when the foreign object does not need updating. Additionally, it optimizes the handling of many-to-many relationships during updates. The PR also includes a test to verify the reduction of database queries for a 'patch' update scenario.

Decision: Comment

📝 Type: 'Bug fix' - not supported yet.
  • Sourcery currently only approves 'Typo fix' PRs.
✅ Issue addressed: this change correctly addresses the issue or implements the desired feature.
No details provided.
✅ Small diff: the diff is small enough to approve with confidence.
No details provided.

General suggestions:

  • While the changes effectively address the issue described, it's important to ensure that the use of _default_manager.create() does not unintentionally bypass any custom managers that might be defined on related models. Consider either supporting custom managers explicitly or documenting the behavior to make the implementation choice clear to future contributors and users.

Thanks for using Sourcery. We offer it for free for open source projects and would be very grateful if you could help us grow. If you like it, would you consider sharing Sourcery on your favourite social media? ✨

Share Sourcery

Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.92%. Comparing base (bd75a3b) to head (274c45c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #490      +/-   ##
==========================================
+ Coverage   87.91%   87.92%   +0.01%     
==========================================
  Files          37       37              
  Lines        3170     3173       +3     
==========================================
+ Hits         2787     2790       +3     
  Misses        383      383              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@bellini666 bellini666 left a comment

Choose a reason for hiding this comment

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

LGTM :)

Thank you for this. I think you just need to fix the pre-commit issues from https://results.pre-commit.ci/run/github/308695886/1709063395.7XoMjDiQR8aEsM7A8X8lnQ

@keithhackbarth
Copy link
Contributor Author

@bellini666 - Good call. Updated.

@bellini666 bellini666 merged commit 3eda4e6 into strawberry-graphql:main Feb 27, 2024
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants