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

[WIP] Fix Tortoise not populating nested models #68

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

marcoaaguiar
Copy link

FastAPI-CrudRouter + Tortoise

Tortoise models can have 3 "types" of pydantic models:

  • Regular pydantic models (BaseModel)
  • Uninitiated Tortoise's pydantic models (PydanticModel)
  • Initiated Tortoise's pydantic models (PydanticModel + Tortoise.init_models)

Tortoise initiated vs uninitiated models

Uninitiated models are models that are typically written in a module's body and are not preceded by a Tortoise.init_models(...).
Initiated models are aware of its related models (Foreign fields) and will include these fields in the created Pydantic models

Test cases:

The proposed test cases are the cross-product of the possible "types" of Pydantic model vs. having nested models or not.

Cases:

  • No nested - Regular pydantic models (BaseModel)
  • No nested - Uninitiated Tortoise's pydantic models (PydanticModel)
  • No nested - Initiated Tortoise's pydantic models (PydanticModel + Tortoise.init_models)
  • Nested - Regular pydantic models (BaseModel)
  • Nested - Uninitiated Tortoise's pydantic models (PydanticModel)
  • Nested - Initiated Tortoise's pydantic models (PydanticModel + Tortoise.init_models)

@vercel
Copy link

vercel bot commented May 21, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/flortz/fastapi-crudrouter/8dsNZt6zMLJuhPGEZpcM2SzPPX9t
✅ Preview: https://fastapi-crudro-git-fork-marcoaaguiar-feature-fix-tortois-a708ae.vercel.app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant