From a4bc6b1eede377f74bd00621d8e967d25c0b59c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=9Eahin=20Akkaya?= Date: Sun, 4 Aug 2024 19:10:20 +0300 Subject: [PATCH] Fix --- ...lly-load-sqlalchemy-model-relationships-in-fastapi.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/_posts/2024-08-04-conditionally-load-sqlalchemy-model-relationships-in-fastapi.md b/_posts/2024-08-04-conditionally-load-sqlalchemy-model-relationships-in-fastapi.md index 0ebf8e0..b78fadc 100644 --- a/_posts/2024-08-04-conditionally-load-sqlalchemy-model-relationships-in-fastapi.md +++ b/_posts/2024-08-04-conditionally-load-sqlalchemy-model-relationships-in-fastapi.md @@ -261,21 +261,14 @@ This is all we need to do for our sqlalchemy models. Now, let's implement the fu from typing import Any - -from models import RelationshipLoader from pydantic import create_model - -def generate_load_strategies(sqlalchemy_model: type[RelationshipLoader]) -> dict[str, Any]: - return sqlalchemy_model.get_relationships() - - def generate_pydantic_model(model_name, strategies: dict[str, Any]) -> type[BaseModel]: pydantic_fields = dict.fromkeys(strategies, (bool | None, None)) return create_model(model_name, **pydantic_fields) ``` -And lastly, let's use these functions in `app.py` to generate pydantic schemas and use it in our router: +And lastly, let's use this function in `app.py` to generate pydantic schemas and use it in our router: ```python # app.py