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: Only set False to clear FileFields when updating an instance #601

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

bellini666
Copy link
Member

@bellini666 bellini666 commented Jul 24, 2024

Fix #599

Summary by Sourcery

This pull request fixes a bug where FileField values were being incorrectly cleared during instance creation. It ensures that FileField values are only set to False to clear them when updating an existing instance. Additionally, a new test has been added to verify the correct handling of optional FileField values during creation.

  • Bug Fixes:
    • Ensure FileField values are only set to False to clear them when updating an existing instance, preventing unintended clearing during creation.
  • Tests:
    • Add a test to verify that optional FileField values are handled correctly when not set during creation.

@bellini666 bellini666 self-assigned this Jul 24, 2024
Copy link
Contributor

sourcery-ai bot commented Jul 24, 2024

Reviewer's Guide by Sourcery

This pull request addresses issue #599 by ensuring that FileFields are only cleared (set to False) when updating an existing instance and not during creation. A new test case was added to verify the correct behavior when an optional file field is not set during creation.

File-Level Changes

Files Changes
tests/mutations/test_mutations.py
strawberry_django/mutations/resolvers.py
Added a test case to cover the scenario of not setting an optional file field during creation and updated the resolver logic to only clear FileFields when updating an existing instance.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

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.

Hey @bellini666 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Testing: 3 issues found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

tests/mutations/test_mutations.py Show resolved Hide resolved
strawberry_django/mutations/resolvers.py Show resolved Hide resolved
tests/mutations/test_mutations.py Show resolved Hide resolved
tests/mutations/test_mutations.py Show resolved Hide resolved
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.73%. Comparing base (6dc6be9) to head (6499d95).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #601      +/-   ##
==========================================
- Coverage   88.84%   88.73%   -0.12%     
==========================================
  Files          41       41              
  Lines        3605     3605              
==========================================
- Hits         3203     3199       -4     
- Misses        402      406       +4     

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

@bellini666 bellini666 merged commit 97743cf into main Jul 24, 2024
22 checks passed
@bellini666 bellini666 deleted the fix_file_field_false branch July 24, 2024 21:16
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