tortoise / tortoise/tortoise-orm

model_config Parameter in pydantic_model_creator Not Effective in Sub Models

Open
#1,686 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.6k
Forks
516
Avg merge
2d 21h
Merged PRs (30d)
9

Description

When using pydantic_model_creator to create schemas, I want to set the json_encoders in the schema via the model_config parameter. Additionally, I want the same json_encoders to be used in sub models. However, the json_encoders are not effective in the sub models.

I noticed that in _pydantic_recursion_protector, the model_config is not passed to the sub models. How can I ensure that the json_encoders in model_config are applied to sub models?
image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting _pydantic_recursion_protector, which the report identifies as the point where model_config is not passed to sub models. Reproduce the issue with nested schemas and json_encoders, then verify that the configured encoders are applied consistently to both the top-level schema and its sub models.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.