tortoise / tortoise/tortoise-orm
pydantic v2,computed cannot use attribute from exclude
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
modify from example:
https://github.com/tortoise/tortoise-orm/blob/develop/examples/fastapi/models.py
show full_name and hide name:
class PydanticMeta:
computed = ["full_name"]
exclude = ["password_hash","name"]
raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'User' object has no attribute 'name'
Describe the bug
tortoise-orm: v0.20.0
pydantic : v2.3.0
Expected behavior
like pydantic v1, computed first then exclude
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with examples/fastapi/models.py and reproduce the Pydantic v2 case where User computes full_name while name is excluded. Trace the serialization order that produces the AttributeError, then verify that the computed field works while name remains hidden and compare the behavior with the stated Pydantic v1 expectation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100