tortoise / tortoise/tortoise-orm
pydantic_model_creator not validates JSONField
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
when creating a pedantic model with pydantic_model_creator, the JSON fields are not enforced and validated on pedantic.
I found in the source code https://github.com/tortoise/tortoise-orm/blob/4a81c051d2d8082839a8f15b0f332220e753ea27/tortoise/contrib/pydantic/creator.py#L402 that it specifies type of Any instead of pydantic.Json[Any]
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 in tortoise/contrib/pydantic/creator.py around line 402, where JSONField is assigned its generated type. Reproduce pydantic_model_creator with a JSONField and add coverage showing invalid JSON data is rejected; done means the generated model validates that field instead of accepting any value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- database
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100