From b8f65547b21d9ecff8aead9db4f0881c75aca69e Mon Sep 17 00:00:00 2001 From: mxr612 Date: Thu, 19 Jun 2025 00:47:32 +0800 Subject: [PATCH] fix: change database commit to flush in new_user function - Updated the new_user function in database.py to use db.flush() instead of db.commit() for adding new users. This change ensures that the user object is added to the session without committing the transaction, allowing for better control over database operations. --- database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database.py b/database.py index 061f8a3..a9f8821 100644 --- a/database.py +++ b/database.py @@ -54,7 +54,7 @@ def new_user() -> int: user = User() user.last_seen = user.created_at = datetime.now(UTC) db.add(user) - db.commit() + db.flush() return user.id finally: db.close()