feat(DTO): Add custom attribute accessor callable#4160
Merged
provinzkraut merged 2 commits intomainfrom May 1, 2025
Merged
Conversation
provinzkraut
commented
May 1, 2025
tests/unit/test_dto/test_factory/test_backends/test_backends.py
Outdated
Show resolved
Hide resolved
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4160 +/- ##
==========================================
- Coverage 98.37% 98.36% -0.01%
==========================================
Files 348 348
Lines 15864 15871 +7
Branches 1752 1754 +2
==========================================
+ Hits 15606 15612 +6
Misses 123 123
- Partials 135 136 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7eeeebb to
bc5ec09
Compare
cofin
approved these changes
May 1, 2025
Member
cofin
left a comment
There was a problem hiding this comment.
This is really simple but adds quite a bit of flexibility!
|
Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/4160 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a new
attribute_accessorproperty toAbstractDTO, which can be used by both the codegen and functional backend to access attributes on an object.This can be useful to implement DTOs for types that do not adhere to the plain protocol of
obj.data_fieldor need to add additional checks, e.g. usingobj.related_field.all()on a Django model to access related objects, while ensuring no I/O occurs.