From e063ac227e8cf4fcdfa2c3dcc61ac9fedf0afa61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Rehp=C3=B6hler?= Date: Sun, 5 Jan 2025 19:36:56 +0100 Subject: [PATCH] Bug-Fix: when using Postgresql the user and oauth_account objects get disconnected from the session. Reconnect them with a refresh() --- fastapi_users_db_sqlalchemy/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fastapi_users_db_sqlalchemy/__init__.py b/fastapi_users_db_sqlalchemy/__init__.py index 467a2bf..2e44344 100644 --- a/fastapi_users_db_sqlalchemy/__init__.py +++ b/fastapi_users_db_sqlalchemy/__init__.py @@ -169,6 +169,8 @@ async def add_oauth_account(self, user: UP, create_dict: dict[str, Any]) -> UP: self.session.add(user) await self.session.commit() + await self.session.refresh(oauth_account) + await self.session.refresh(user) return user @@ -182,6 +184,8 @@ async def update_oauth_account( setattr(oauth_account, key, value) self.session.add(oauth_account) await self.session.commit() + await self.session.refresh(oauth_account) + await self.session.refresh(user) return user