@secondlayer/subgraphs 3.14.2 → 3.14.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/index.js +10 -9
- package/dist/src/index.js.map +3 -3
- package/dist/src/runtime/block-processor.js +10 -9
- package/dist/src/runtime/block-processor.js.map +3 -3
- package/dist/src/runtime/catchup.js +10 -9
- package/dist/src/runtime/catchup.js.map +3 -3
- package/dist/src/runtime/context.js +10 -9
- package/dist/src/runtime/context.js.map +3 -3
- package/dist/src/runtime/processor.js +10 -9
- package/dist/src/runtime/processor.js.map +3 -3
- package/dist/src/runtime/reindex.js +10 -9
- package/dist/src/runtime/reindex.js.map +3 -3
- package/dist/src/runtime/reorg.js +10 -9
- package/dist/src/runtime/reorg.js.map +3 -3
- package/dist/src/service.js +10 -9
- package/dist/src/service.js.map +3 -3
- package/package.json +2 -2
package/dist/src/service.js
CHANGED
|
@@ -520,21 +520,22 @@ class SubgraphContext {
|
|
|
520
520
|
"_tx_id",
|
|
521
521
|
"_created_at"
|
|
522
522
|
];
|
|
523
|
-
|
|
524
|
-
|
|
523
|
+
if (this.journal) {
|
|
524
|
+
statements.push(this.journalCaptureSQL(batch.table, batch.keyCols, Array.from(batch.rows.values()).map((r) => batch.keyCols.map((k) => escapeLiteral(r.keys[k])))));
|
|
525
|
+
}
|
|
526
|
+
for (const r of batch.rows.values()) {
|
|
527
|
+
const keyPred = batch.keyCols.map((k) => `"${k}" = ${escapeLiteral(r.keys[k])}`).join(" AND ");
|
|
528
|
+
const updSet = batch.deltaCols.map((c) => `"${c}" = COALESCE("${c}", 0) + (${String(r.deltas[c] ?? 0n)})`).join(", ");
|
|
529
|
+
statements.push(`UPDATE ${qualifiedTable} SET ${updSet} WHERE ${keyPred}`);
|
|
530
|
+
const insertVals = [
|
|
525
531
|
...batch.keyCols.map((k) => escapeLiteral(r.keys[k])),
|
|
526
532
|
...batch.deltaCols.map((c) => String(r.deltas[c] ?? 0n)),
|
|
527
533
|
escapeLiteral(r.meta.blockHeight),
|
|
528
534
|
escapeLiteral(r.meta.txId),
|
|
529
535
|
"NOW()"
|
|
530
536
|
];
|
|
531
|
-
|
|
532
|
-
}).join(", ");
|
|
533
|
-
const setClauses = batch.deltaCols.map((c) => `"${c}" = COALESCE("${batch.table}"."${c}", 0) + EXCLUDED."${c}"`);
|
|
534
|
-
if (this.journal) {
|
|
535
|
-
statements.push(this.journalCaptureSQL(batch.table, batch.keyCols, Array.from(batch.rows.values()).map((r) => batch.keyCols.map((k) => escapeLiteral(r.keys[k])))));
|
|
537
|
+
statements.push(`INSERT INTO ${qualifiedTable} (${cols.map((c) => `"${c}"`).join(", ")}) ` + `SELECT ${insertVals.join(", ")} ` + `WHERE NOT EXISTS (SELECT 1 FROM ${qualifiedTable} WHERE ${keyPred})`);
|
|
536
538
|
}
|
|
537
|
-
statements.push(`INSERT INTO ${qualifiedTable} (${cols.map((c) => `"${c}"`).join(", ")}) VALUES ${valuesList} ` + `ON CONFLICT (${batch.keyCols.map((k) => `"${k}"`).join(", ")}) DO UPDATE SET ${setClauses.join(", ")}`);
|
|
538
539
|
incBatch = null;
|
|
539
540
|
incBatchKey = "";
|
|
540
541
|
};
|
|
@@ -3519,5 +3520,5 @@ var shutdown = async () => {
|
|
|
3519
3520
|
process.on("SIGINT", shutdown);
|
|
3520
3521
|
process.on("SIGTERM", shutdown);
|
|
3521
3522
|
|
|
3522
|
-
//# debugId=
|
|
3523
|
+
//# debugId=9435991A9E2313C564756E2164756E21
|
|
3523
3524
|
//# sourceMappingURL=service.js.map
|