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

feat: Add support for auto mapping of ArrayFields #567

Merged
merged 1 commit into from
Jun 29, 2024
Merged

Conversation

bellini666
Copy link
Member

@bellini666 bellini666 commented Jun 29, 2024

Fix #200

Summary by Sourcery

This pull request introduces support for auto mapping of ArrayFields in Django models, including handling for both single-dimensional and multi-dimensional arrays. It also adds corresponding tests to ensure the correct type resolution and functionality.

  • New Features:
    • Added support for auto mapping of ArrayFields in models, including both single-dimensional and multi-dimensional arrays.
  • Tests:
    • Introduced new tests to verify the correct handling and type resolution of ArrayFields and nested ArrayFields in models.

@bellini666 bellini666 self-assigned this Jun 29, 2024
Copy link
Contributor

sourcery-ai bot commented Jun 29, 2024

Reviewer's Guide by Sourcery

This pull request adds support for auto mapping of ArrayFields in Django models. The implementation includes importing ArrayField from django.contrib.postgres.fields, adding a helper function _resolve_array_field_type to handle the type resolution of ArrayFields, and updating the resolve_model_field_type function to incorporate this new functionality. Additionally, new tests have been added to verify the correct handling of both single and nested ArrayFields.

File-Level Changes

Files Changes
tests/fields/test_types.py
strawberry_django/fields/types.py
Implemented support for auto mapping of ArrayFields and added corresponding tests to ensure correct type resolution for both single and nested ArrayFields.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • 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: 5 issues found
  • 🟢 Security: all looks good
  • 🟡 Testing: 2 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.

strawberry_django/fields/types.py Show resolved Hide resolved
strawberry_django/fields/types.py Show resolved Hide resolved
strawberry_django/fields/types.py Show resolved Hide resolved
strawberry_django/fields/types.py Show resolved Hide resolved
strawberry_django/fields/types.py Show resolved Hide resolved
tests/fields/test_types.py Show resolved Hide resolved
tests/fields/test_types.py Show resolved Hide resolved
strawberry_django/fields/types.py Show resolved Hide resolved
tests/fields/test_types.py Show resolved Hide resolved
tests/fields/test_types.py Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Jun 29, 2024

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.88%. Comparing base (db5ca05) to head (dfaa5e7).
Report is 1 commits behind head on main.

Files Patch % Lines
strawberry_django/fields/types.py 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #567      +/-   ##
==========================================
+ Coverage   88.85%   88.88%   +0.03%     
==========================================
  Files          41       41              
  Lines        3544     3545       +1     
==========================================
+ Hits         3149     3151       +2     
+ Misses        395      394       -1     

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

@bellini666 bellini666 merged commit 1023674 into main Jun 29, 2024
22 checks passed
@bellini666 bellini666 deleted the array_field branch June 29, 2024 13:51
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.

Add built-in support for List[] django model properties
2 participants