From cc7a6842ed8fbe94ab6bba6b5405fd0a4b1895b9 Mon Sep 17 00:00:00 2001 From: wangdl Date: Fri, 19 Jun 2026 22:08:17 +0800 Subject: [PATCH] fix: standardize dbExec/dbQuery param passing as arrays Co-Authored-By: Claude Opus 4.7 --- test/helpers/integration-harness.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/helpers/integration-harness.ts b/test/helpers/integration-harness.ts index ab8ab2e..6c7fb0d 100644 --- a/test/helpers/integration-harness.ts +++ b/test/helpers/integration-harness.ts @@ -157,12 +157,12 @@ export function getPrisma(dbUrl: string): PrismaClient { return prisma; } -export async function dbExec(dbUrl: string, sql: string, ...params: any[]): Promise { +export async function dbExec(dbUrl: string, sql: string, params: any[] = []): Promise { const p = getPrisma(dbUrl); await p.$executeRawUnsafe(sql, ...params); } -export async function dbQuery(dbUrl: string, sql: string, ...params: any[]): Promise { +export async function dbQuery(dbUrl: string, sql: string, params: any[] = []): Promise { const p = getPrisma(dbUrl); return (await p.$queryRawUnsafe(sql, ...params)) as T[]; } @@ -173,19 +173,19 @@ export async function dbClose(): Promise { export async function setupFixtures(dbUrl: string, userId: string, kbId: string, kiId: string, sessionId: string): Promise { await dbExec(dbUrl, `INSERT IGNORE INTO User (id, email, nickname, role, status) VALUES (?, ?, ?, ?, ?)`, - userId, `test-${Date.now()}@zhixi.app`, 'Integration Test', 'USER', 'active'); + [userId, `test-${Date.now()}@zhixi.app`, 'Integration Test', 'USER', 'active']); await dbExec(dbUrl, `INSERT IGNORE INTO KnowledgeBase (id, userId, title) VALUES (?, ?, ?)`, - kbId, userId, 'Test KB'); + [kbId, userId, 'Test KB']); await dbExec(dbUrl, `INSERT IGNORE INTO KnowledgeItem (id, userId, knowledgeBaseId, itemType, title, content, status) VALUES (?, ?, ?, ?, ?, ?, ?)`, - kiId, userId, kbId, 'concept', 'Test Item', 'Test content.', 'active'); + [kiId, userId, kbId, 'concept', 'Test Item', 'Test content.', 'active']); await dbExec(dbUrl, `INSERT IGNORE INTO LearningSession (id, userId, knowledgeBaseId, knowledgeItemId, mode, status, startedAt) VALUES (?, ?, ?, ?, ?, ?, NOW())`, - sessionId, userId, kbId, kiId, 'active_recall', 'active'); + [sessionId, userId, kbId, kiId, 'active_recall', 'active']); } export async function cleanupFixtures(dbUrl: string, userId: string): Promise { const tables = ['ReviewCard', 'FocusItem', 'AiAnalysisResult', 'AiAnalysisJob', 'LearningSession', 'KnowledgeItem', 'KnowledgeBase']; for (const t of tables) { - await dbExec(dbUrl, `DELETE FROM \`${t}\` WHERE userId = ?`, userId).catch(() => {}); + await dbExec(dbUrl, `DELETE FROM \`${t}\` WHERE userId = ?`, [userId]).catch(() => {}); } - await dbExec(dbUrl, `DELETE FROM User WHERE id = ?`, userId).catch(() => {}); + await dbExec(dbUrl, `DELETE FROM User WHERE id = ?`, [userId]).catch(() => {}); }