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.
This commit is contained in:
Miu Li 2025-06-19 00:47:32 +08:00
parent 068000515a
commit b8f65547b2

View File

@ -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()