refactor: 统一 sqlmodel_ext 用法至官方推荐模式
Some checks failed
Test / test (push) Failing after 3m47s

- 替换 Field(max_length=X) 为 StrX/TextX 类型别名(21 个 sqlmodels 文件)
- 替换 get + 404 检查为 get_exist_one()(17 个路由文件,约 50 处)
- 替换 save + session.refresh 为 save(load=...)
- 替换 session.add + commit 为 save()(dav/provider.py)
- 更新所有依赖至最新版本

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-09 11:13:16 +08:00
parent 9185f26b83
commit 6c96c43bea
57 changed files with 1091 additions and 761 deletions

View File

@@ -192,7 +192,7 @@ async def _login_oauth(
# 已绑定 → 更新 OAuth 信息并返回关联用户
identity.display_name = nickname
identity.avatar_url = avatar_url
await identity.save(session)
identity = await identity.save(session)
user: User = await User.get(session, User.id == identity.user_id, load=User.group)
if not user:
@@ -254,7 +254,7 @@ async def _auto_register_oauth_user(
is_verified=True,
user_id=new_user_id,
)
await identity.save(session)
identity = await identity.save(session)
# 创建用户根目录
default_policy = await Policy.get(session, Policy.name == "本地存储")
@@ -335,7 +335,7 @@ async def _login_passkey(
# 更新签名计数
authn.sign_count = verification.new_sign_count
await authn.save(session)
authn = await authn.save(session)
# 加载用户
user: User = await User.get(session, User.id == authn.user_id, load=User.group)
@@ -392,7 +392,7 @@ async def _login_magic_link(
# 标记邮箱已验证
if not identity.is_verified:
identity.is_verified = True
await identity.save(session)
identity = await identity.save(session)
return user