From 5d591c46391de76c3bf72daa5e8d3bfe2620bab5 Mon Sep 17 00:00:00 2001 From: OG T Date: Fri, 10 Apr 2026 00:22:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(drift=5Frepository):=20CAST(:param=20AS=20j?= =?UTF-8?q?sonb)=20=E5=8F=96=E4=BB=A3=20:param::jsonb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit asyncpg 不支援 named param 混用 :: cast 語法,導致 PostgresSyntaxError。 改用 CAST() 函數語法,與 SQLAlchemy text() named params 相容。 影響: drift_reports 現在可正常寫入 DB Co-Authored-By: Claude Sonnet 4.6 --- apps/api/src/repositories/drift_repository.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/api/src/repositories/drift_repository.py b/apps/api/src/repositories/drift_repository.py index 4976577b..12550fdc 100644 --- a/apps/api/src/repositories/drift_repository.py +++ b/apps/api/src/repositories/drift_repository.py @@ -92,7 +92,7 @@ class DriftReportRepository: VALUES (:report_id, :namespace, :triggered_by, :scanned_at, :high_count, :medium_count, :info_count, - :items::jsonb, :interpretation::jsonb, :status, :created_at, :resolved_at) + CAST(:items AS jsonb), CAST(:interpretation AS jsonb), :status, :created_at, :resolved_at) ON CONFLICT (report_id) DO UPDATE SET items = EXCLUDED.items, interpretation = EXCLUDED.interpretation, @@ -144,7 +144,7 @@ class DriftReportRepository: await db.execute( text(""" UPDATE drift_reports - SET interpretation = :interpretation::jsonb + SET interpretation = CAST(:interpretation AS jsonb) WHERE report_id = :report_id """), {