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

Docs: example in "DTO: Excluding fields" is not clear #3804

Open
sobolevn opened this issue Oct 15, 2024 · 0 comments
Open

Docs: example in "DTO: Excluding fields" is not clear #3804

sobolevn opened this issue Oct 15, 2024 · 0 comments
Labels
Documentation 📚 This is related to documentation DTOs This is related to our DTO feature

Comments

@sobolevn
Copy link
Member

sobolevn commented Oct 15, 2024

Summary

Example:

config = DTOConfig(
    exclude={
        "id",
        "address.id",
        "address.street",
        "pets.0.id",
        "pets.0.user_id",
    }
)

Later is specifies:

and "pets.0.id" and "pets.0.user_id" represent fields of the Pets objects nested within the list of User.pets.

and

Given a generic type, with an arbitrary number of type parameters (e.g., GenericType[Type0, Type1, ..., TypeN]), we use the index of the type parameter to indicate which type the exclusion should refer to. For example, a.0.b, excludes the b field from the first type parameter of a, a.1.b excludes the b field from the second type parameter of a, and so on.

But I still don't understand what pets.0.id means :)

Here are my questions:

  1. Is pets.0 an index of an object? For example in [Pet(id=1, name="Dog"), Pet(id=2, name="Cat")] will both of them not have an id? Or only Dog?
  2. This sentence confuses me even more:

Given a generic type, with an arbitrary number of type parameters (e.g., GenericType[Type0, Type1, ..., TypeN]), we use the index of the type parameter to indicate which type the exclusion should refer to

Because neither User or Pet is generic. They don't have any type params.

I don't have any proposals on how to fix this, because I don't understand how it works :)


Note

While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.
Fund with Polar
@sobolevn sobolevn added the Documentation 📚 This is related to documentation label Oct 15, 2024
@github-project-automation github-project-automation bot moved this to Triage in Overview Oct 15, 2024
@sobolevn sobolevn added the DTOs This is related to our DTO feature label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation 📚 This is related to documentation DTOs This is related to our DTO feature
Projects
Status: Triage
Development

No branches or pull requests

1 participant