orez 0.9.7 → 0.10.0
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/README.md +27 -19
- package/dist/config.d.ts +0 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -1
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -43
- package/dist/index.js.map +1 -1
- package/package.json +7 -71
- package/dist/cf-deploy/bundle.d.ts +0 -21
- package/dist/cf-deploy/bundle.d.ts.map +0 -1
- package/dist/cf-deploy/bundle.js +0 -347
- package/dist/cf-deploy/bundle.js.map +0 -1
- package/dist/cf-deploy/config.d.ts +0 -52
- package/dist/cf-deploy/config.d.ts.map +0 -1
- package/dist/cf-deploy/config.js +0 -23
- package/dist/cf-deploy/config.js.map +0 -1
- package/dist/cf-deploy/index.d.ts +0 -11
- package/dist/cf-deploy/index.d.ts.map +0 -1
- package/dist/cf-deploy/index.js +0 -17
- package/dist/cf-deploy/index.js.map +0 -1
- package/dist/cf-deploy/leaves.d.ts +0 -19
- package/dist/cf-deploy/leaves.d.ts.map +0 -1
- package/dist/cf-deploy/leaves.js +0 -109
- package/dist/cf-deploy/leaves.js.map +0 -1
- package/dist/cf-deploy/migration.d.ts +0 -40
- package/dist/cf-deploy/migration.d.ts.map +0 -1
- package/dist/cf-deploy/migration.js +0 -891
- package/dist/cf-deploy/migration.js.map +0 -1
- package/dist/cf-deploy/nativeMigrations.d.ts +0 -24
- package/dist/cf-deploy/nativeMigrations.d.ts.map +0 -1
- package/dist/cf-deploy/nativeMigrations.js +0 -185
- package/dist/cf-deploy/nativeMigrations.js.map +0 -1
- package/dist/cf-deploy/prune.d.ts +0 -14
- package/dist/cf-deploy/prune.d.ts.map +0 -1
- package/dist/cf-deploy/prune.js +0 -235
- package/dist/cf-deploy/prune.js.map +0 -1
- package/dist/cf-deploy/shims.d.ts +0 -13
- package/dist/cf-deploy/shims.d.ts.map +0 -1
- package/dist/cf-deploy/shims.js +0 -737
- package/dist/cf-deploy/shims.js.map +0 -1
- package/dist/cf-deploy/smoke.d.ts +0 -15
- package/dist/cf-deploy/smoke.d.ts.map +0 -1
- package/dist/cf-deploy/smoke.js +0 -141
- package/dist/cf-deploy/smoke.js.map +0 -1
- package/dist/cf-deploy/sources.d.ts +0 -9
- package/dist/cf-deploy/sources.d.ts.map +0 -1
- package/dist/cf-deploy/sources.js +0 -276
- package/dist/cf-deploy/sources.js.map +0 -1
- package/dist/cf-deploy/wrangler.d.ts +0 -6
- package/dist/cf-deploy/wrangler.d.ts.map +0 -1
- package/dist/cf-deploy/wrangler.js +0 -168
- package/dist/cf-deploy/wrangler.js.map +0 -1
- package/dist/cf-do/application-sql.d.ts +0 -49
- package/dist/cf-do/application-sql.d.ts.map +0 -1
- package/dist/cf-do/application-sql.js +0 -124
- package/dist/cf-do/application-sql.js.map +0 -1
- package/dist/cf-do/cdc.d.ts +0 -155
- package/dist/cf-do/cdc.d.ts.map +0 -1
- package/dist/cf-do/cdc.js +0 -719
- package/dist/cf-do/cdc.js.map +0 -1
- package/dist/cf-do/cursor-pull.d.ts +0 -27
- package/dist/cf-do/cursor-pull.d.ts.map +0 -1
- package/dist/cf-do/cursor-pull.js +0 -78
- package/dist/cf-do/cursor-pull.js.map +0 -1
- package/dist/cf-do/row-undo.d.ts +0 -36
- package/dist/cf-do/row-undo.d.ts.map +0 -1
- package/dist/cf-do/row-undo.js +0 -221
- package/dist/cf-do/row-undo.js.map +0 -1
- package/dist/cf-do/tx-journal.d.ts +0 -119
- package/dist/cf-do/tx-journal.d.ts.map +0 -1
- package/dist/cf-do/tx-journal.js +0 -718
- package/dist/cf-do/tx-journal.js.map +0 -1
- package/dist/cf-do/watermark.d.ts +0 -29
- package/dist/cf-do/watermark.d.ts.map +0 -1
- package/dist/cf-do/watermark.js +0 -105
- package/dist/cf-do/watermark.js.map +0 -1
- package/dist/cf-do/worker.d.ts +0 -287
- package/dist/cf-do/worker.d.ts.map +0 -1
- package/dist/cf-do/worker.js +0 -1961
- package/dist/cf-do/worker.js.map +0 -1
- package/dist/do-sql-tracking.d.ts +0 -104
- package/dist/do-sql-tracking.d.ts.map +0 -1
- package/dist/do-sql-tracking.js +0 -255
- package/dist/do-sql-tracking.js.map +0 -1
- package/dist/pg-proxy-do-backend.d.ts +0 -211
- package/dist/pg-proxy-do-backend.d.ts.map +0 -1
- package/dist/pg-proxy-do-backend.js +0 -7884
- package/dist/pg-proxy-do-backend.js.map +0 -1
- package/dist/pg-sqlite-compiler/catalog/seed.d.ts +0 -67
- package/dist/pg-sqlite-compiler/catalog/seed.d.ts.map +0 -1
- package/dist/pg-sqlite-compiler/catalog/seed.js +0 -436
- package/dist/pg-sqlite-compiler/catalog/seed.js.map +0 -1
- package/dist/pg-sqlite-compiler/compiler.d.ts +0 -17
- package/dist/pg-sqlite-compiler/compiler.d.ts.map +0 -1
- package/dist/pg-sqlite-compiler/compiler.js +0 -86
- package/dist/pg-sqlite-compiler/compiler.js.map +0 -1
- package/dist/pg-sqlite-compiler/index.d.ts +0 -2
- package/dist/pg-sqlite-compiler/index.d.ts.map +0 -1
- package/dist/pg-sqlite-compiler/index.js +0 -13
- package/dist/pg-sqlite-compiler/index.js.map +0 -1
- package/dist/pg-sqlite-compiler/passes/array.d.ts +0 -3
- package/dist/pg-sqlite-compiler/passes/array.d.ts.map +0 -1
- package/dist/pg-sqlite-compiler/passes/array.js +0 -223
- package/dist/pg-sqlite-compiler/passes/array.js.map +0 -1
- package/dist/pg-sqlite-compiler/passes/ast-utils.d.ts +0 -48
- package/dist/pg-sqlite-compiler/passes/ast-utils.d.ts.map +0 -1
- package/dist/pg-sqlite-compiler/passes/ast-utils.js +0 -93
- package/dist/pg-sqlite-compiler/passes/ast-utils.js.map +0 -1
- package/dist/pg-sqlite-compiler/passes/catalog.d.ts +0 -34
- package/dist/pg-sqlite-compiler/passes/catalog.d.ts.map +0 -1
- package/dist/pg-sqlite-compiler/passes/catalog.js +0 -30
- package/dist/pg-sqlite-compiler/passes/catalog.js.map +0 -1
- package/dist/pg-sqlite-compiler/passes/datetime.d.ts +0 -23
- package/dist/pg-sqlite-compiler/passes/datetime.d.ts.map +0 -1
- package/dist/pg-sqlite-compiler/passes/datetime.js +0 -55
- package/dist/pg-sqlite-compiler/passes/datetime.js.map +0 -1
- package/dist/pg-sqlite-compiler/passes/dml-cte.d.ts +0 -22
- package/dist/pg-sqlite-compiler/passes/dml-cte.d.ts.map +0 -1
- package/dist/pg-sqlite-compiler/passes/dml-cte.js +0 -161
- package/dist/pg-sqlite-compiler/passes/dml-cte.js.map +0 -1
- package/dist/pg-sqlite-compiler/passes/index.d.ts +0 -24
- package/dist/pg-sqlite-compiler/passes/index.d.ts.map +0 -1
- package/dist/pg-sqlite-compiler/passes/index.js +0 -52
- package/dist/pg-sqlite-compiler/passes/index.js.map +0 -1
- package/dist/pg-sqlite-compiler/passes/json-functions.d.ts +0 -3
- package/dist/pg-sqlite-compiler/passes/json-functions.d.ts.map +0 -1
- package/dist/pg-sqlite-compiler/passes/json-functions.js +0 -57
- package/dist/pg-sqlite-compiler/passes/json-functions.js.map +0 -1
- package/dist/pg-sqlite-compiler/passes/row-json.d.ts +0 -3
- package/dist/pg-sqlite-compiler/passes/row-json.d.ts.map +0 -1
- package/dist/pg-sqlite-compiler/passes/row-json.js +0 -230
- package/dist/pg-sqlite-compiler/passes/row-json.js.map +0 -1
- package/dist/pg-sqlite-compiler/passes/schema.d.ts +0 -4
- package/dist/pg-sqlite-compiler/passes/schema.d.ts.map +0 -1
- package/dist/pg-sqlite-compiler/passes/schema.js +0 -128
- package/dist/pg-sqlite-compiler/passes/schema.js.map +0 -1
- package/dist/pg-sqlite-compiler/passes/string-functions.d.ts +0 -11
- package/dist/pg-sqlite-compiler/passes/string-functions.d.ts.map +0 -1
- package/dist/pg-sqlite-compiler/passes/string-functions.js +0 -37
- package/dist/pg-sqlite-compiler/passes/string-functions.js.map +0 -1
- package/dist/pg-sqlite-compiler/passes/types.d.ts +0 -41
- package/dist/pg-sqlite-compiler/passes/types.d.ts.map +0 -1
- package/dist/pg-sqlite-compiler/passes/types.js +0 -115
- package/dist/pg-sqlite-compiler/passes/types.js.map +0 -1
- package/dist/pg-sqlite-compiler/passes/unsupported.d.ts +0 -3
- package/dist/pg-sqlite-compiler/passes/unsupported.d.ts.map +0 -1
- package/dist/pg-sqlite-compiler/passes/unsupported.js +0 -57
- package/dist/pg-sqlite-compiler/passes/unsupported.js.map +0 -1
- package/dist/pg-sqlite-compiler/test/oracle.d.ts +0 -34
- package/dist/pg-sqlite-compiler/test/oracle.d.ts.map +0 -1
- package/dist/pg-sqlite-compiler/test/oracle.js +0 -204
- package/dist/pg-sqlite-compiler/test/oracle.js.map +0 -1
- package/dist/pg-sqlite-compiler/types.d.ts +0 -66
- package/dist/pg-sqlite-compiler/types.d.ts.map +0 -1
- package/dist/pg-sqlite-compiler/types.js +0 -2
- package/dist/pg-sqlite-compiler/types.js.map +0 -1
- package/dist/sync-browser-host/generated/sqlite3-browser.wasm +0 -0
- package/dist/sync-browser-host/generated/sync_wasm.js +0 -922
- package/dist/sync-browser-host/generated/sync_wasm_bg.wasm +0 -0
- package/dist/sync-browser-host/host.d.ts +0 -10
- package/dist/sync-browser-host/host.d.ts.map +0 -1
- package/dist/sync-browser-host/host.js +0 -496
- package/dist/sync-browser-host/host.js.map +0 -1
- package/dist/sync-browser-host/idb-snapshot.d.ts +0 -11
- package/dist/sync-browser-host/idb-snapshot.d.ts.map +0 -1
- package/dist/sync-browser-host/idb-snapshot.js +0 -122
- package/dist/sync-browser-host/idb-snapshot.js.map +0 -1
- package/dist/sync-browser-host/index.d.ts +0 -5
- package/dist/sync-browser-host/index.d.ts.map +0 -1
- package/dist/sync-browser-host/index.js +0 -5
- package/dist/sync-browser-host/index.js.map +0 -1
- package/dist/sync-browser-host/message-port.d.ts +0 -7
- package/dist/sync-browser-host/message-port.d.ts.map +0 -1
- package/dist/sync-browser-host/message-port.js +0 -188
- package/dist/sync-browser-host/message-port.js.map +0 -1
- package/dist/sync-browser-host/sqlite-adapter.d.ts +0 -67
- package/dist/sync-browser-host/sqlite-adapter.d.ts.map +0 -1
- package/dist/sync-browser-host/sqlite-adapter.js +0 -145
- package/dist/sync-browser-host/sqlite-adapter.js.map +0 -1
- package/dist/sync-browser-host/types.d.ts +0 -52
- package/dist/sync-browser-host/types.d.ts.map +0 -1
- package/dist/sync-browser-host/types.js +0 -2
- package/dist/sync-browser-host/types.js.map +0 -1
- package/dist/sync-cf-host.d.ts +0 -2
- package/dist/sync-cf-host.d.ts.map +0 -1
- package/dist/sync-cf-host.js +0 -2
- package/dist/sync-cf-host.js.map +0 -1
- package/dist/sync-executor.d.ts +0 -2
- package/dist/sync-executor.d.ts.map +0 -1
- package/dist/sync-executor.js +0 -2
- package/dist/sync-executor.js.map +0 -1
- package/dist/wake.d.ts +0 -22
- package/dist/wake.d.ts.map +0 -1
- package/dist/wake.js +0 -114
- package/dist/wake.js.map +0 -1
- package/dist/worker/cf-do-shim.d.ts +0 -55
- package/dist/worker/cf-do-shim.d.ts.map +0 -1
- package/dist/worker/cf-do-shim.js +0 -58
- package/dist/worker/cf-do-shim.js.map +0 -1
- package/dist/worker/cf-patches.d.ts +0 -43
- package/dist/worker/cf-patches.d.ts.map +0 -1
- package/dist/worker/cf-patches.js +0 -840
- package/dist/worker/cf-patches.js.map +0 -1
- package/dist/worker/local-sql-backend.d.ts +0 -35
- package/dist/worker/local-sql-backend.d.ts.map +0 -1
- package/dist/worker/local-sql-backend.js +0 -217
- package/dist/worker/local-sql-backend.js.map +0 -1
- package/dist/worker/zero-cache-embed-cf.d.ts +0 -92
- package/dist/worker/zero-cache-embed-cf.d.ts.map +0 -1
- package/dist/worker/zero-cache-embed-cf.js +0 -764
- package/dist/worker/zero-cache-embed-cf.js.map +0 -1
- package/dist/worker/zero-sql-write-circuit.d.ts +0 -46
- package/dist/worker/zero-sql-write-circuit.d.ts.map +0 -1
- package/dist/worker/zero-sql-write-circuit.js +0 -161
- package/dist/worker/zero-sql-write-circuit.js.map +0 -1
- package/dist/zero-http/encrypted-column-codec.d.ts +0 -46
- package/dist/zero-http/encrypted-column-codec.d.ts.map +0 -1
- package/dist/zero-http/encrypted-column-codec.js +0 -676
- package/dist/zero-http/encrypted-column-codec.js.map +0 -1
- package/dist/zero-http/encrypted-column-conformance.d.ts +0 -7
- package/dist/zero-http/encrypted-column-conformance.d.ts.map +0 -1
- package/dist/zero-http/encrypted-column-conformance.js +0 -161
- package/dist/zero-http/encrypted-column-conformance.js.map +0 -1
- package/dist/zero-http/fixture-schema.d.ts +0 -127
- package/dist/zero-http/fixture-schema.d.ts.map +0 -1
- package/dist/zero-http/fixture-schema.js +0 -56
- package/dist/zero-http/fixture-schema.js.map +0 -1
- package/dist/zero-http/mount.d.ts +0 -71
- package/dist/zero-http/mount.d.ts.map +0 -1
- package/dist/zero-http/mount.js +0 -594
- package/dist/zero-http/mount.js.map +0 -1
- package/dist/zero-http/payload-codec.d.ts +0 -91
- package/dist/zero-http/payload-codec.d.ts.map +0 -1
- package/dist/zero-http/payload-codec.js +0 -10
- package/dist/zero-http/payload-codec.js.map +0 -1
- package/dist/zero-http/server.d.ts +0 -16
- package/dist/zero-http/server.d.ts.map +0 -1
- package/dist/zero-http/server.js +0 -270
- package/dist/zero-http/server.js.map +0 -1
- package/dist/zero-http/test-harness.d.ts +0 -32
- package/dist/zero-http/test-harness.d.ts.map +0 -1
- package/dist/zero-http/test-harness.js +0 -77
- package/dist/zero-http/test-harness.js.map +0 -1
- package/dist/zero-http/transport.d.ts +0 -71
- package/dist/zero-http/transport.d.ts.map +0 -1
- package/dist/zero-http/transport.js +0 -1106
- package/dist/zero-http/transport.js.map +0 -1
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Data-modifying CTEs (`WITH x AS (DELETE/INSERT/UPDATE …) …`) are
|
|
3
|
-
* Postgres-only; SQLite rejects DML inside a WITH clause.
|
|
4
|
-
*
|
|
5
|
-
* The one shape we translate — because zero-cache's changeLog purge depends
|
|
6
|
-
* on it (zero 1.6 storer.js: a leading `keep` boundary CTE, a
|
|
7
|
-
* `purged AS (DELETE … RETURNING …)` CTE, and `SELECT COUNT(*) FROM purged`)
|
|
8
|
-
* — is the "counted delete": an outer SELECT that only counts the rows a
|
|
9
|
-
* single DELETE CTE removed. It restructures into a top-level
|
|
10
|
-
* `WITH <other ctes> DELETE … RETURNING 1 AS "__orez_count__<col>"`, which
|
|
11
|
-
* SQLite executes natively (plain CTEs ARE allowed on a DELETE).
|
|
12
|
-
*
|
|
13
|
-
* The result shape changes (N marker rows instead of one count row), so the
|
|
14
|
-
* emitted SQL is self-describing: the RETURNING alias carries the count
|
|
15
|
-
* column name behind COUNT_MARKER_PREFIX. Runtimes executing compiled SQL
|
|
16
|
-
* (orez's DoBackend) detect the marker and fold the rows back into
|
|
17
|
-
* `[{ <col>: rowCount }]` — see foldCountMarkerResult. Left untranslated,
|
|
18
|
-
* every changeLog purge tick 500s on the DO backend and the log grows
|
|
19
|
-
* forever (the 2026-07 CF rows-written burn).
|
|
20
|
-
*
|
|
21
|
-
* Every other data-modifying CTE gets a warning (strict mode rejects it).
|
|
22
|
-
*/
|
|
23
|
-
import { walkAst } from './ast-utils.js';
|
|
24
|
-
export const COUNT_MARKER_PREFIX = '__orez_count__';
|
|
25
|
-
const DML_TAGS = ['DeleteStmt', 'InsertStmt', 'UpdateStmt'];
|
|
26
|
-
function cteDmlTag(cte) {
|
|
27
|
-
const query = cte?.CommonTableExpr?.ctequery;
|
|
28
|
-
if (!query || typeof query !== 'object')
|
|
29
|
-
return null;
|
|
30
|
-
for (const tag of DML_TAGS) {
|
|
31
|
-
if (query[tag])
|
|
32
|
-
return tag;
|
|
33
|
-
}
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
function isCountStarTarget(target) {
|
|
37
|
-
const func = target?.ResTarget?.val?.FuncCall;
|
|
38
|
-
if (!func?.agg_star)
|
|
39
|
-
return false;
|
|
40
|
-
const parts = func.funcname;
|
|
41
|
-
if (!Array.isArray(parts) || parts.length === 0)
|
|
42
|
-
return false;
|
|
43
|
-
const last = parts[parts.length - 1];
|
|
44
|
-
const name = last?.String?.sval ?? last?.String?.str;
|
|
45
|
-
return typeof name === 'string' && name.toLowerCase() === 'count';
|
|
46
|
-
}
|
|
47
|
-
function referencesRelation(node, name) {
|
|
48
|
-
let found = false;
|
|
49
|
-
walkAst(node, {
|
|
50
|
-
RangeVar: (rangeVar) => {
|
|
51
|
-
if (!rangeVar?.schemaname && rangeVar?.relname === name)
|
|
52
|
-
found = true;
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
return found;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Restructure a counted-delete CTE statement in place. `stmt` is the inner
|
|
59
|
-
* tag-wrapped statement node (`{ SelectStmt: … }`). Returns the count column
|
|
60
|
-
* name when the statement matched and was rewritten, else null (untouched).
|
|
61
|
-
*/
|
|
62
|
-
export function transformCountedDeleteCte(stmt) {
|
|
63
|
-
const sel = stmt?.SelectStmt;
|
|
64
|
-
if (!sel?.withClause?.ctes || sel.withClause.recursive)
|
|
65
|
-
return null;
|
|
66
|
-
if (sel.op !== 'SETOP_NONE' ||
|
|
67
|
-
sel.whereClause ||
|
|
68
|
-
sel.groupClause ||
|
|
69
|
-
sel.havingClause ||
|
|
70
|
-
sel.sortClause ||
|
|
71
|
-
sel.limitCount ||
|
|
72
|
-
sel.limitOffset ||
|
|
73
|
-
sel.distinctClause ||
|
|
74
|
-
sel.valuesLists) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
const ctes = sel.withClause.ctes;
|
|
78
|
-
const dmlIndexes = ctes
|
|
79
|
-
.map((cte, index) => (cteDmlTag(cte) ? index : -1))
|
|
80
|
-
.filter((index) => index >= 0);
|
|
81
|
-
if (dmlIndexes.length !== 1)
|
|
82
|
-
return null;
|
|
83
|
-
const dmlIndex = dmlIndexes[0];
|
|
84
|
-
const dmlCte = ctes[dmlIndex].CommonTableExpr;
|
|
85
|
-
if (cteDmlTag(ctes[dmlIndex]) !== 'DeleteStmt')
|
|
86
|
-
return null;
|
|
87
|
-
const deleteStmt = dmlCte.ctequery.DeleteStmt;
|
|
88
|
-
// outer select must be exactly `SELECT COUNT(*) [AS col] FROM <dml cte>`
|
|
89
|
-
if (sel.targetList?.length !== 1 || !isCountStarTarget(sel.targetList[0]))
|
|
90
|
-
return null;
|
|
91
|
-
const from = sel.fromClause;
|
|
92
|
-
if (from?.length !== 1)
|
|
93
|
-
return null;
|
|
94
|
-
const fromRel = from[0]?.RangeVar;
|
|
95
|
-
if (!fromRel || fromRel.schemaname || fromRel.relname !== dmlCte.ctename)
|
|
96
|
-
return null;
|
|
97
|
-
// the delete CTE must not be read anywhere else (another CTE consuming its
|
|
98
|
-
// RETURNING rows cannot be preserved once the DELETE moves to the top level)
|
|
99
|
-
const others = ctes.filter((_, index) => index !== dmlIndex);
|
|
100
|
-
if (others.some((cte) => referencesRelation(cte.CommonTableExpr?.ctequery, dmlCte.ctename))) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
const countColumn = sel.targetList[0].ResTarget?.name ?? 'count';
|
|
104
|
-
deleteStmt.returningList = [
|
|
105
|
-
{
|
|
106
|
-
ResTarget: {
|
|
107
|
-
name: `${COUNT_MARKER_PREFIX}${countColumn}`,
|
|
108
|
-
val: { A_Const: { ival: { ival: 1 } } },
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
];
|
|
112
|
-
if (others.length) {
|
|
113
|
-
deleteStmt.withClause = { ...sel.withClause, ctes: others };
|
|
114
|
-
}
|
|
115
|
-
delete stmt.SelectStmt;
|
|
116
|
-
stmt.DeleteStmt = deleteStmt;
|
|
117
|
-
return { countColumn };
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Fold an executed counted-delete result back into the original statement's
|
|
121
|
-
* shape: N marker rows → `[{ <col>: N }]`. `columnsOrSql` is either the
|
|
122
|
-
* result column list or the executed SQL (for zero-row results, where some
|
|
123
|
-
* drivers report no columns). Returns null when the marker is absent.
|
|
124
|
-
*/
|
|
125
|
-
export function foldCountMarkerResult(rowCount, columnsOrSql) {
|
|
126
|
-
// the deparser quotes the alias only when required, so match both forms
|
|
127
|
-
const column = typeof columnsOrSql === 'string'
|
|
128
|
-
? (columnsOrSql.match(new RegExp(`"${COUNT_MARKER_PREFIX}([^"]+)"`))?.[1] ??
|
|
129
|
-
columnsOrSql.match(new RegExp(`\\b${COUNT_MARKER_PREFIX}(\\w+)\\b`))?.[1])
|
|
130
|
-
: columnsOrSql.length === 1 && columnsOrSql[0].startsWith(COUNT_MARKER_PREFIX)
|
|
131
|
-
? columnsOrSql[0].slice(COUNT_MARKER_PREFIX.length)
|
|
132
|
-
: undefined;
|
|
133
|
-
if (!column)
|
|
134
|
-
return null;
|
|
135
|
-
return { rows: [{ [column]: rowCount }], columns: [column] };
|
|
136
|
-
}
|
|
137
|
-
export const dmlCtePass = {
|
|
138
|
-
name: 'dml-cte',
|
|
139
|
-
run(stmt, ctx) {
|
|
140
|
-
transformCountedDeleteCte(stmt);
|
|
141
|
-
// anything still holding DML inside a CTE is untranslatable
|
|
142
|
-
walkAst(stmt, {
|
|
143
|
-
CommonTableExpr: (cte) => {
|
|
144
|
-
const query = cte?.ctequery;
|
|
145
|
-
if (!query || typeof query !== 'object')
|
|
146
|
-
return;
|
|
147
|
-
for (const tag of DML_TAGS) {
|
|
148
|
-
if (query[tag]) {
|
|
149
|
-
ctx.warnings.push({
|
|
150
|
-
kind: 'data-modifying-cte',
|
|
151
|
-
near: 'CommonTableExpr',
|
|
152
|
-
message: 'data-modifying CTEs are Postgres-only (SQLite rejects DML in WITH); only the counted-delete shape is translated',
|
|
153
|
-
});
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
});
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
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AE,CAAC,MAAM,CAAC,EAAE,CAAA;AAC9D,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAS;IAC9B,IAAI,EAAE,SAAS;IACf,GAAG,CAAC,IAAI,EAAE,GAAG;QACX,yBAAyB,CAAC,IAAI,CAAC,CAAA;QAC/B,4DAA4D;QAC5D,OAAO,CAAC,IAAI,EAAE;YACZ,eAAe,EAAE,CAAC,GAAQ,EAAE,EAAE;gBAC5B,MAAM,KAAK,GAAG,GAAG,EAAE,QAAQ,CAAA;gBAC3B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;oBAAE,OAAM;gBAC/C,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;oBAC3B,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;wBACf,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;4BAChB,IAAI,EAAE,oBAAoB;4BAC1B,IAAI,EAAE,iBAAiB;4BACvB,OAAO,EACL,iHAAiH;yBACpH,CAAC,CAAA;wBACF,OAAM;oBACR,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pass pipeline.
|
|
3
|
-
*
|
|
4
|
-
* Each pass is a focused visitor over the PG AST that mutates nodes in place
|
|
5
|
-
* to make the tree SQLite-emittable. Order matters: type normalization runs
|
|
6
|
-
* first (so other passes see SQLite-native type names), datetime runs after
|
|
7
|
-
* (function-form → SQLValueFunction), catalog rewrites last (after every
|
|
8
|
-
* other pass has stabilized).
|
|
9
|
-
*
|
|
10
|
-
* array runs ahead of types: it reads the operand's original `$1::text[]` cast
|
|
11
|
-
* to find the bind slot, and types would have already flattened that cast.
|
|
12
|
-
*/
|
|
13
|
-
import type { Pass, PassContext } from '../types.js';
|
|
14
|
-
export declare const DEFAULT_PASSES: Pass[];
|
|
15
|
-
/**
|
|
16
|
-
* Run all passes on a single top-level RawStmt entry.
|
|
17
|
-
*
|
|
18
|
-
* Input shape: `{ stmt: { TagName: data } }` (a libpg_query RawStmt).
|
|
19
|
-
* Passes use `walkAst()` (in passes/ast-utils.ts) which expects a tag-wrapped
|
|
20
|
-
* node — so we hand them `rawStmt.stmt`, the inner `{ TagName: data }`.
|
|
21
|
-
* Callbacks receive (data, parent, key) and mutate via `parent[key] = ...`.
|
|
22
|
-
*/
|
|
23
|
-
export declare function runPasses(rawStmt: any, ctx: PassContext): void;
|
|
24
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pg-sqlite-compiler/passes/index.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEpD,eAAO,MAAM,cAAc,EAAE,IAAI,EAehC,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI,CAc9D"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { arrayPass } from './array.js';
|
|
2
|
-
import { catalogPass } from './catalog.js';
|
|
3
|
-
import { datetimePass } from './datetime.js';
|
|
4
|
-
import { dmlCtePass } from './dml-cte.js';
|
|
5
|
-
import { jsonFunctionsPass } from './json-functions.js';
|
|
6
|
-
import { rowJsonPass } from './row-json.js';
|
|
7
|
-
import { schemaPass } from './schema.js';
|
|
8
|
-
import { stringFunctionsPass } from './string-functions.js';
|
|
9
|
-
import { typesPass } from './types.js';
|
|
10
|
-
import { unsupportedPass } from './unsupported.js';
|
|
11
|
-
export const DEFAULT_PASSES = [
|
|
12
|
-
// structural rewrites first so later passes see the final statement shape
|
|
13
|
-
dmlCtePass,
|
|
14
|
-
arrayPass,
|
|
15
|
-
typesPass,
|
|
16
|
-
datetimePass,
|
|
17
|
-
stringFunctionsPass,
|
|
18
|
-
jsonFunctionsPass,
|
|
19
|
-
rowJsonPass,
|
|
20
|
-
catalogPass,
|
|
21
|
-
schemaPass,
|
|
22
|
-
unsupportedPass,
|
|
23
|
-
// future:
|
|
24
|
-
// castPass,
|
|
25
|
-
// insertPass,
|
|
26
|
-
];
|
|
27
|
-
/**
|
|
28
|
-
* Run all passes on a single top-level RawStmt entry.
|
|
29
|
-
*
|
|
30
|
-
* Input shape: `{ stmt: { TagName: data } }` (a libpg_query RawStmt).
|
|
31
|
-
* Passes use `walkAst()` (in passes/ast-utils.ts) which expects a tag-wrapped
|
|
32
|
-
* node — so we hand them `rawStmt.stmt`, the inner `{ TagName: data }`.
|
|
33
|
-
* Callbacks receive (data, parent, key) and mutate via `parent[key] = ...`.
|
|
34
|
-
*/
|
|
35
|
-
export function runPasses(rawStmt, ctx) {
|
|
36
|
-
const stmt = rawStmt?.stmt ?? rawStmt;
|
|
37
|
-
if (!stmt || typeof stmt !== 'object')
|
|
38
|
-
return;
|
|
39
|
-
const passes = ctx.passes ?? DEFAULT_PASSES;
|
|
40
|
-
for (const pass of passes) {
|
|
41
|
-
try {
|
|
42
|
-
pass.run(stmt, ctx);
|
|
43
|
-
}
|
|
44
|
-
catch (err) {
|
|
45
|
-
ctx.warnings.push({
|
|
46
|
-
kind: 'pass-error',
|
|
47
|
-
message: `pass ${pass.name} threw: ${err.message}`,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pg-sqlite-compiler/passes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;A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version":3,"file":"json-functions.d.ts","sourceRoot":"","sources":["../../../src/pg-sqlite-compiler/passes/json-functions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AA+BvC,eAAO,MAAM,iBAAiB,EAAE,IAwB/B,CAAA"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { walkAst } from './ast-utils.js';
|
|
2
|
-
/**
|
|
3
|
-
* PG's JSON aggregates and constructors have direct SQLite equivalents with
|
|
4
|
-
* the same argument shapes, but different names. Zero's z2s query compiler
|
|
5
|
-
* emits these (json_agg over json_build_object rows is its relationship
|
|
6
|
-
* hydration shape), so passing them through breaks every consumer on real
|
|
7
|
-
* SQLite with "no such function: json_agg".
|
|
8
|
-
*
|
|
9
|
-
* jsonb variants map to the same SQLite functions: SQLite has one JSON text
|
|
10
|
-
* representation, so the jsonb/json distinction erases.
|
|
11
|
-
*/
|
|
12
|
-
const SQLITE_FUNCTION_BY_PG_JSON_FUNCTION = new Map([
|
|
13
|
-
['json_agg', 'json_group_array'],
|
|
14
|
-
['jsonb_agg', 'json_group_array'],
|
|
15
|
-
['json_build_object', 'json_object'],
|
|
16
|
-
['jsonb_build_object', 'json_object'],
|
|
17
|
-
['json_build_array', 'json_array'],
|
|
18
|
-
['jsonb_build_array', 'json_array'],
|
|
19
|
-
['json_object_agg', 'json_group_object'],
|
|
20
|
-
['jsonb_object_agg', 'json_group_object'],
|
|
21
|
-
]);
|
|
22
|
-
function functionName(func) {
|
|
23
|
-
const parts = func?.funcname;
|
|
24
|
-
if (!Array.isArray(parts) || parts.length === 0)
|
|
25
|
-
return null;
|
|
26
|
-
const last = parts[parts.length - 1];
|
|
27
|
-
const value = last?.String?.sval ?? last?.String?.str;
|
|
28
|
-
return typeof value === 'string' ? value.toLowerCase() : null;
|
|
29
|
-
}
|
|
30
|
-
export const jsonFunctionsPass = {
|
|
31
|
-
name: 'json-functions',
|
|
32
|
-
run(rawStmt, ctx) {
|
|
33
|
-
walkAst(rawStmt, {
|
|
34
|
-
FuncCall: (node) => {
|
|
35
|
-
const name = functionName(node);
|
|
36
|
-
if (!name)
|
|
37
|
-
return;
|
|
38
|
-
const replacement = SQLITE_FUNCTION_BY_PG_JSON_FUNCTION.get(name);
|
|
39
|
-
if (!replacement)
|
|
40
|
-
return;
|
|
41
|
-
// SQLite aggregates accept no ORDER BY / FILTER inside the call; a
|
|
42
|
-
// silent rename would change semantics, so surface it instead.
|
|
43
|
-
if (node.agg_order || node.agg_filter) {
|
|
44
|
-
ctx.warnings.push({
|
|
45
|
-
kind: 'unsupported-function',
|
|
46
|
-
near: 'FuncCall',
|
|
47
|
-
message: `${name}() with ORDER BY/FILTER has no SQLite equivalent`,
|
|
48
|
-
});
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
node.funcname = [{ String: { sval: replacement } }];
|
|
52
|
-
node.funcformat = 'COERCE_EXPLICIT_CALL';
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
//# sourceMappingURL=json-functions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json-functions.js","sourceRoot":"","sources":["../../../src/pg-sqlite-compiler/passes/json-functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAIxC;;;;;;;;;GASG;AACH,MAAM,mCAAmC,GAAG,IAAI,GAAG,CAAC;IAClD,CAAC,UAAU,EAAE,kBAAkB,CAAC;IAChC,CAAC,WAAW,EAAE,kBAAkB,CAAC;IACjC,CAAC,mBAAmB,EAAE,aAAa,CAAC;IACpC,CAAC,oBAAoB,EAAE,aAAa,CAAC;IACrC,CAAC,kBAAkB,EAAE,YAAY,CAAC;IAClC,CAAC,mBAAmB,EAAE,YAAY,CAAC;IACnC,CAAC,iBAAiB,EAAE,mBAAmB,CAAC;IACxC,CAAC,kBAAkB,EAAE,mBAAmB,CAAC;CAC1C,C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E,WAAW,EAAE,EAAE,CAAC,CAAA;gBACnD,IAAI,CAAC,UAAU,GAAG,sBAAsB,CAAA;YAC1C,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"row-json.d.ts","sourceRoot":"","sources":["../../../src/pg-sqlite-compiler/passes/row-json.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,aAAa,CAAA;AA+MpD,eAAO,MAAM,WAAW,EAAE,IA+CzB,CAAA"}
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import { walkAst } from './ast-utils.js';
|
|
2
|
-
function stringValue(node) {
|
|
3
|
-
return node?.String?.sval ?? node?.String?.str ?? null;
|
|
4
|
-
}
|
|
5
|
-
function functionName(func) {
|
|
6
|
-
const parts = func?.funcname;
|
|
7
|
-
if (!Array.isArray(parts) || parts.length === 0)
|
|
8
|
-
return null;
|
|
9
|
-
return stringValue(parts[parts.length - 1])?.toLowerCase() ?? null;
|
|
10
|
-
}
|
|
11
|
-
/** last name of a ColumnRef (e.g. `s.id` → `id`), or null for `*` / non-columns. */
|
|
12
|
-
function columnName(value) {
|
|
13
|
-
const fields = value?.ColumnRef?.fields;
|
|
14
|
-
if (!Array.isArray(fields) || fields.length === 0)
|
|
15
|
-
return null;
|
|
16
|
-
return stringValue(fields[fields.length - 1]);
|
|
17
|
-
}
|
|
18
|
-
/** true when the ColumnRef ends in `*` (bare `*` or qualified `t.*`). */
|
|
19
|
-
function isStarColumnRef(value) {
|
|
20
|
-
const fields = value?.ColumnRef?.fields;
|
|
21
|
-
if (!Array.isArray(fields) || fields.length === 0)
|
|
22
|
-
return false;
|
|
23
|
-
return fields[fields.length - 1]?.A_Star !== undefined;
|
|
24
|
-
}
|
|
25
|
-
/** qualifier of a `t.*` star (the `t`), or null for a bare `*`. */
|
|
26
|
-
function starQualifier(value) {
|
|
27
|
-
const fields = value?.ColumnRef?.fields;
|
|
28
|
-
if (!Array.isArray(fields) || fields.length < 2)
|
|
29
|
-
return null;
|
|
30
|
-
return stringValue(fields[0]);
|
|
31
|
-
}
|
|
32
|
-
/** gather every RangeVar reachable through a FROM clause, descending JoinExprs. */
|
|
33
|
-
function collectRangeVars(node, out) {
|
|
34
|
-
if (!node || typeof node !== 'object')
|
|
35
|
-
return;
|
|
36
|
-
if (Array.isArray(node)) {
|
|
37
|
-
for (const child of node)
|
|
38
|
-
collectRangeVars(child, out);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (node.RangeVar) {
|
|
42
|
-
out.push(node.RangeVar);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (node.JoinExpr) {
|
|
46
|
-
collectRangeVars(node.JoinExpr.larg, out);
|
|
47
|
-
collectRangeVars(node.JoinExpr.rarg, out);
|
|
48
|
-
}
|
|
49
|
-
// RangeSubselect etc. expose no schema-resolvable columns, so the caller
|
|
50
|
-
// declines when a star can't be expanded from a real table.
|
|
51
|
-
}
|
|
52
|
-
function stringNode(value) {
|
|
53
|
-
return { A_Const: { sval: { sval: value }, location: -1 } };
|
|
54
|
-
}
|
|
55
|
-
function columnNode(alias, column) {
|
|
56
|
-
return {
|
|
57
|
-
ColumnRef: {
|
|
58
|
-
fields: [{ String: { sval: alias } }, { String: { sval: column } }],
|
|
59
|
-
location: -1,
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
function decline(ctx, message) {
|
|
64
|
-
ctx.warnings.push({ kind: 'row-json-unsupported', message, near: 'row_to_json' });
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Expand a `*` / `t.*` star into the real column names of its source table,
|
|
69
|
-
* using the authoritative schema. Returns null (already warned) when the shape
|
|
70
|
-
* can't be proven, and never invents column names.
|
|
71
|
-
*/
|
|
72
|
-
function expandStar(fromClause, qualifier, ctx) {
|
|
73
|
-
let rv;
|
|
74
|
-
if (qualifier == null) {
|
|
75
|
-
// a bare `*` covers EVERY source in the FROM clause, so it is only
|
|
76
|
-
// resolvable when that clause is exactly one base table. A second table, a
|
|
77
|
-
// sub-select, a function, or a join contributes columns a single table's
|
|
78
|
-
// shape can't account for, and silently expanding just the one table would
|
|
79
|
-
// drop the rest. Decline instead of guessing.
|
|
80
|
-
rv =
|
|
81
|
-
Array.isArray(fromClause) && fromClause.length === 1
|
|
82
|
-
? fromClause[0]?.RangeVar
|
|
83
|
-
: undefined;
|
|
84
|
-
if (!rv) {
|
|
85
|
-
return decline(ctx, 'row_to_json over SELECT * needs the from clause to be a single known table');
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
// a qualified `t.*` names exactly one table, so it stays resolvable even
|
|
90
|
-
// amid other FROM sources — find that table wherever it sits.
|
|
91
|
-
const rangeVars = [];
|
|
92
|
-
collectRangeVars(fromClause, rangeVars);
|
|
93
|
-
rv = rangeVars.find((v) => (v.alias?.aliasname ?? v.relname) === qualifier);
|
|
94
|
-
if (!rv) {
|
|
95
|
-
return decline(ctx, `row_to_json star qualifier ${qualifier} matches no table`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
const columns = ctx.schema.getTableColumns(rv.schemaname ?? 'public', rv.relname);
|
|
99
|
-
if (!columns || columns.length === 0) {
|
|
100
|
-
return decline(ctx, `row_to_json over ${rv.relname}.* needs schema info that is unavailable`);
|
|
101
|
-
}
|
|
102
|
-
return [...columns];
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Resolve the output column names a subquery produces, so row_to_json can be
|
|
106
|
-
* rewritten to json_object() referencing real columns. Returns null (already
|
|
107
|
-
* warned) when the shape can't be proven. Any synthetic aliases it needs are
|
|
108
|
-
* applied to the subquery targets only on success, so a declined rewrite leaves
|
|
109
|
-
* the AST untouched.
|
|
110
|
-
*/
|
|
111
|
-
function resolveShape(subselect, ctx) {
|
|
112
|
-
const sub = subselect?.subquery?.SelectStmt;
|
|
113
|
-
const targets = sub?.targetList;
|
|
114
|
-
if (!Array.isArray(targets) || targets.length === 0) {
|
|
115
|
-
return decline(ctx, 'row_to_json subquery has no resolvable target list');
|
|
116
|
-
}
|
|
117
|
-
const resolvedTargets = [];
|
|
118
|
-
for (let i = 0; i < targets.length; i++) {
|
|
119
|
-
const target = targets[i]?.ResTarget;
|
|
120
|
-
if (!target)
|
|
121
|
-
return decline(ctx, 'row_to_json subquery has an unrecognized target');
|
|
122
|
-
// an explicit alias is already the real output column name
|
|
123
|
-
if (target.name) {
|
|
124
|
-
resolvedTargets.push({ target, columns: [target.name], needsAlias: false });
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
const val = target.val;
|
|
128
|
-
// `*` / `t.*`: expand from the authoritative table shape or decline
|
|
129
|
-
if (isStarColumnRef(val)) {
|
|
130
|
-
const expanded = expandStar(sub.fromClause, starQualifier(val), ctx);
|
|
131
|
-
if (!expanded)
|
|
132
|
-
return null;
|
|
133
|
-
resolvedTargets.push({ target, columns: expanded, needsAlias: false });
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
// a plain column reference already names its output column (`s.id` → `id`)
|
|
137
|
-
const named = columnName(val);
|
|
138
|
-
if (named) {
|
|
139
|
-
resolvedTargets.push({ target, columns: [named], needsAlias: false });
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
resolvedTargets.push({ target, columns: [], needsAlias: true });
|
|
143
|
-
}
|
|
144
|
-
// The rewrite addresses each subquery column as `alias.<name>`, so the real
|
|
145
|
-
// (non-generated) output names must be unique or that reference is ambiguous:
|
|
146
|
-
// duplicate columns (a.id, b.id), duplicate explicit aliases, and a star that
|
|
147
|
-
// re-expands an explicitly-listed column all make two outputs share a name,
|
|
148
|
-
// and SQLite silently resolves the reference to just one, losing the other.
|
|
149
|
-
// SQLite matches column names case-insensitively, so compare case-folded.
|
|
150
|
-
// Decline before mutating any target so a declined rewrite leaves the AST
|
|
151
|
-
// untouched.
|
|
152
|
-
const usedNames = new Set();
|
|
153
|
-
for (const resolved of resolvedTargets) {
|
|
154
|
-
if (resolved.needsAlias)
|
|
155
|
-
continue;
|
|
156
|
-
for (const column of resolved.columns) {
|
|
157
|
-
const key = column.toLowerCase();
|
|
158
|
-
if (usedNames.has(key)) {
|
|
159
|
-
return decline(ctx, `row_to_json subquery has duplicate output column ${column}; cannot address it unambiguously`);
|
|
160
|
-
}
|
|
161
|
-
usedNames.add(key);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
for (let i = 0; i < resolvedTargets.length; i++) {
|
|
165
|
-
const resolved = resolvedTargets[i];
|
|
166
|
-
if (!resolved.needsAlias)
|
|
167
|
-
continue;
|
|
168
|
-
// an unnamed expression has no stable output name in SQLite. Give it a
|
|
169
|
-
// real alias that cannot collide with another target or expanded star.
|
|
170
|
-
let suffix = i + 1;
|
|
171
|
-
let generated = `_orez_col_${suffix}`;
|
|
172
|
-
while (usedNames.has(generated.toLowerCase()))
|
|
173
|
-
generated = `_orez_col_${++suffix}`;
|
|
174
|
-
resolved.target.name = generated;
|
|
175
|
-
resolved.columns = [generated];
|
|
176
|
-
usedNames.add(generated.toLowerCase());
|
|
177
|
-
}
|
|
178
|
-
return resolvedTargets.flatMap((target) => target.columns);
|
|
179
|
-
}
|
|
180
|
-
export const rowJsonPass = {
|
|
181
|
-
name: 'row-json',
|
|
182
|
-
run(rawStmt, ctx) {
|
|
183
|
-
walkAst(rawStmt, {
|
|
184
|
-
SelectStmt: (select) => {
|
|
185
|
-
const subselects = new Map();
|
|
186
|
-
for (const fromNode of select?.fromClause ?? []) {
|
|
187
|
-
const subselect = fromNode?.RangeSubselect;
|
|
188
|
-
const alias = subselect?.alias?.aliasname;
|
|
189
|
-
if (alias && subselect?.subquery?.SelectStmt) {
|
|
190
|
-
subselects.set(alias, subselect);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
if (subselects.size === 0)
|
|
194
|
-
return;
|
|
195
|
-
// resolve each referenced subquery shape at most once (and warn once)
|
|
196
|
-
const resolved = new Map();
|
|
197
|
-
const shapeFor = (alias) => {
|
|
198
|
-
if (!resolved.has(alias)) {
|
|
199
|
-
resolved.set(alias, resolveShape(subselects.get(alias), ctx));
|
|
200
|
-
}
|
|
201
|
-
return resolved.get(alias) ?? null;
|
|
202
|
-
};
|
|
203
|
-
walkAst(select.targetList ?? [], {
|
|
204
|
-
FuncCall: (func, parent, key) => {
|
|
205
|
-
if (functionName(func) !== 'row_to_json')
|
|
206
|
-
return;
|
|
207
|
-
const alias = columnName(func.args?.[0]);
|
|
208
|
-
if (!alias || !subselects.has(alias))
|
|
209
|
-
return;
|
|
210
|
-
const columns = shapeFor(alias);
|
|
211
|
-
if (!columns || columns.length === 0)
|
|
212
|
-
return;
|
|
213
|
-
parent[key] = {
|
|
214
|
-
FuncCall: {
|
|
215
|
-
funcname: [{ String: { sval: 'json_object' } }],
|
|
216
|
-
args: columns.flatMap((column) => [
|
|
217
|
-
stringNode(column),
|
|
218
|
-
columnNode(alias, column),
|
|
219
|
-
]),
|
|
220
|
-
funcformat: 'COERCE_EXPLICIT_CALL',
|
|
221
|
-
location: -1,
|
|
222
|
-
},
|
|
223
|
-
};
|
|
224
|
-
},
|
|
225
|
-
});
|
|
226
|
-
},
|
|
227
|
-
});
|
|
228
|
-
},
|
|
229
|
-
};
|
|
230
|
-
//# sourceMappingURL=row-json.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"row-json.js","sourceRoot":"","sources":["../../../src/pg-sqlite-compiler/passes/row-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAIxC,SAAS,WAAW,CAAC,IAAS;IAC5B,OAAO,IAAI,EAAE,MAAM,EAAE,IAAI,IAAI,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,IAAI,CAAA;AACxD,CAAC;AAED,SAAS,YAAY,CAAC,IAAS;IAC7B,MAAM,KAAK,GAAG,IAAI,E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