fix(creator): 详情接口用了 MySQL 5.7 不支持的 NULLS LAST
Deploy VitePress site to Pages / build (push) Canceled after 0s
Deploy VitePress site to Pages / Deploy (push) Canceled after 0s

1064 语法错误。nullslast() 是 PostgreSQL 语法,MySQL 5.7 不认;而 MySQL 把 NULL 视为比任何值都小,
所以 DESC 本身就把它排在最后,不需要额外声明。

这个 bug 只在真机上暴露:SQLite 从 3.30 起支持 NULLS LAST,本地测试环境测不出来。
This commit is contained in:
2026-10-07 16:32:53 +08:00
parent c2b310c7bf
commit 5484e5a3ae
+4 -1
View File
@@ -141,7 +141,10 @@ async def latest_notes(session: AsyncSession, account_id: int) -> List[Dict[str,
& (CreatorNoteStat.captured_at == newest.c.captured_at),
)
.where(CreatorNoteStat.account_id == account_id)
.order_by(CreatorNoteStat.publish_time.desc().nullslast())
# 不要用 nullslast():那是 PostgreSQL 语法,MySQL 5.7 会直接抛 1064 语法错误。
# MySQL 把 NULL 视为比任何值都小,所以 DESC 天然把未解析出发布时间的排在最后。
# 这个 bug 只在真机上才暴露 —— SQLite 从 3.30 起支持 NULLS LAST,测试环境测不出来。
.order_by(CreatorNoteStat.publish_time.desc())
)
).all()
return [_note_dict(row) for row in rows]