Open avico78 opened 3 years ago
is there anyone who find solution for nested objects?
I tried something, but its a bit manual
ModelFlatPydantic = sqlalchemy_to_pydantic(ModelSQL)
ChildPydantic = sqlalchemy_to_pydantic(ChildSQL)
class ModelPydantic(ModelFlatPydantic):
child: ChildPydantic
Does that help?
The required input from the user is a nested json,
Expected:
sqlalachamy ORM will break this json and insert it to customers and subsciber tables . where the relation one to many .
Issues:
How i can define the Base class so it will not expect the id column but exactly as
i face issue defining the class when i remove fields as "id" (which not exists in the expected json), seems those fileds are required but it also changing the expected data to:
Second ,what am i doing wrong ? I expect to get 2 pydamtic class and one class which i need to define myself PydanticCustomerWithSubscriberes ,which describe the one--> many relation between customer--> subscriber block/tables. then , isdie fastapi assign the input(json) to this calss , then generate ORM model which i use to push to the DB.
see: added pydantic-sqlalchemy as part of fastapi,
Models:
added the Pydantic models and route:
Getting error: