strawberry-graphql / strawberry-django

Strawberry GraphQL Django extension
https://strawberry.rocks/docs/django
MIT License
421 stars 122 forks source link

fix: Only set False to clear FileFields when updating an instance #601

Closed bellini666 closed 4 months ago

bellini666 commented 4 months ago

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.

sourcery-ai[bot] commented 4 months ago

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](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.
codecov-commenter commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.