From d0fde0d6ad7f8a339bcda5986d12c8102adb5551 Mon Sep 17 00:00:00 2001 From: e-kondr01 Date: Thu, 8 Aug 2024 11:50:46 +0300 Subject: [PATCH] fix: manage init error when using Identity columns --- fastapi_sqlalchemy_toolkit/model_manager.py | 6 +++++- pyproject.toml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fastapi_sqlalchemy_toolkit/model_manager.py b/fastapi_sqlalchemy_toolkit/model_manager.py index dd59edd..cdcc1f6 100644 --- a/fastapi_sqlalchemy_toolkit/model_manager.py +++ b/fastapi_sqlalchemy_toolkit/model_manager.py @@ -107,7 +107,11 @@ def __init__( if hasattr(attr, "default") and attr.default is not None: if isinstance(attr.default, ScalarElementColumnDefault): self.defaults[attr_name] = attr.default.arg - elif hasattr(attr, "server_default") and attr.server_default is not None: + elif ( + hasattr(attr, "server_default") + and attr.server_default is not None + and hasattr(attr.server_default, "arg") + ): if isinstance(attr.type, BOOLEAN): self.defaults[attr_name] = attr.server_default.arg != "False" elif isinstance(attr.type, Integer): diff --git a/pyproject.toml b/pyproject.toml index b3affcf..e471411 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "fastapi_sqlalchemy_toolkit" -version = "0.7.5.1" +version = "0.7.6" authors = [ { name="Egor Kondrashov", email="e.kondr01@gmail.com" }, ]