From 4319cf7f31ceca863fa8674bb6309a03ed1ad1d1 Mon Sep 17 00:00:00 2001 From: shaw Date: Tue, 30 Dec 2025 23:11:49 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E4=BB=93=E5=82=A8):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=20BatchUpdateLastUsed=20=E6=97=B6=E9=97=B4=E6=88=B3=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E4=B8=8D=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在原生 SQL 的 CASE WHEN 语句中,PostgreSQL 无法自动推断占位符参数类型, 导致 time.Time 被当作 text 类型处理,与 last_used_at 列的 timestamptz 类型不匹配。 添加显式类型转换 ::timestamptz 解决此问题。 --- backend/internal/repository/account_repo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/internal/repository/account_repo.go b/backend/internal/repository/account_repo.go index 19dff447..aa880269 100644 --- a/backend/internal/repository/account_repo.go +++ b/backend/internal/repository/account_repo.go @@ -334,7 +334,7 @@ func (r *accountRepository) BatchUpdateLastUsed(ctx context.Context, updates map idx := 1 for id, ts := range updates { - caseSQL += " WHEN $" + itoa(idx) + " THEN $" + itoa(idx+1) + caseSQL += " WHEN $" + itoa(idx) + " THEN $" + itoa(idx+1) + "::timestamptz" args = append(args, id, ts) ids = append(ids, id) idx += 2