From a56a1814b9227d2ce4ba4b2aec3c3da8bfa76497 Mon Sep 17 00:00:00 2001 From: Cactiw Date: Wed, 10 Jan 2024 02:34:16 +0300 Subject: [PATCH] fix: Close #24. Fix PostgreSQL IntegrityError in add_policies --- fastapi_user_auth/utils/sqlachemy_adapter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastapi_user_auth/utils/sqlachemy_adapter.py b/fastapi_user_auth/utils/sqlachemy_adapter.py index 5675a1b..eb9475d 100644 --- a/fastapi_user_auth/utils/sqlachemy_adapter.py +++ b/fastapi_user_auth/utils/sqlachemy_adapter.py @@ -147,7 +147,7 @@ async def add_policies(self, sec: str, ptype: str, rules: Iterable[Tuple[str]]) """adds a policy rules to the storage.""" values = [] for rule in rules: - values.append(self.parse_rule(ptype, rule).dict()) + values.append(self.parse_rule(ptype, rule).dict(exclude={"id"})) if not values: return await self.db.async_execute(insert(self._db_class).values(values))