Skip to content

Commit e4a7d47

Browse files
committed
fix(subgraphs): prevent cols.sort() from mutating array, misaligning values in batched inserts
1 parent 7876f79 commit e4a7d47

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/subgraphs/src/runtime/context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ export class SubgraphContext {
217217
data[c] === "NOW()" ? "NOW()" : escapeLiteral(data[c]),
218218
);
219219

220-
// Batch key: table + sorted columns + upsert key signature
221-
const batchKey = `${op.table}:${cols.sort().join(",")}:${upsertKeys?.sort().join(",") ?? ""}`;
220+
// Batch key: table + sorted columns + upsert key signature (spread to avoid mutating cols)
221+
const batchKey = `${op.table}:${[...cols].sort().join(",")}:${upsertKeys ? [...upsertKeys].sort().join(",") : ""}`;
222222

223223
return { data, cols, vals, upsertKeys, batchKey };
224224
}

0 commit comments

Comments
 (0)