Migrate from SQLAlchemy 1.x legacy Query API to 2.x style select/delete statements

This commit is contained in:
2026-04-06 01:06:01 +08:00
parent 356950e2c7
commit 970c2e9946
39 changed files with 372 additions and 275 deletions
+2 -1
View File
@@ -49,7 +49,8 @@ The following is an example configuration for *Mia! Accounting*.
return current_user()
def get_by_username(self, username: str) -> User | None:
return User.query.filter(User.username == username).first()
return db.session.scalar(
sa.select(User).where(User.username == username))
def get_pk(self, user: User) -> int:
return user.id