fix: demo page deep-copies query results to prevent reference sharing between statements
CI / test (18.x) (push) Successful in 10m2s
CI / test (20.x) (push) Successful in 9m59s
CI / test (22.x) (push) Successful in 9m57s
CI / test (24.x) (push) Successful in 9m55s

This commit is contained in:
thzxx
2026-07-29 22:38:48 +08:00
parent 9d53bb7124
commit 3ae7d6e8fb
+3 -1
View File
@@ -221,7 +221,9 @@ async function runQuery() {
const allResults = [];
for (const stmt of statements) {
const result = await db.query(stmt);
allResults.push({ sql: stmt, result });
// 深拷贝查询结果,防止后续语句通过引用修改已保存的结果
const resultCopy = Array.isArray(result) ? result.map(r => ({ ...r })) : result;
allResults.push({ sql: stmt, result: resultCopy });
}
if (allResults.length === 1) {