From 6ef44805f5c45eb918ce911ee44e796bbfeb0636 Mon Sep 17 00:00:00 2001 From: wangxiaogang <1433729587@qq.com> Date: Mon, 8 Jun 2026 15:56:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9F=8B=E7=82=B9?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=20LIMIT/OFFSET=20=E5=8F=82=E6=95=B0=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - mysql2 execute 对 LIMIT/OFFSET 参数类型要求严格 - 改为直接嵌入 SQL 字符串(pSize 和 offset 已是安全的数字) --- server/src/routes/logs.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/routes/logs.ts b/server/src/routes/logs.ts index e41da99..8fcd393 100644 --- a/server/src/routes/logs.ts +++ b/server/src/routes/logs.ts @@ -157,14 +157,15 @@ router.get('/track/list', requireAdmin, async (req, res) => { ) const total = (countResult as any[])[0].total + // LIMIT/OFFSET 直接嵌入 SQL(mysql2 execute 对这些参数类型要求严格) const [rows] = await pool.execute( `SELECT t.*, u.nickname FROM track_events t LEFT JOIN users u ON t.user_id = u.id WHERE ${where} ORDER BY t.created_at DESC - LIMIT ? OFFSET ?`, - [...params, pSize, offset] + LIMIT ${pSize} OFFSET ${offset}`, + params ) res.json({