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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/pg-sqlite-compiler/passes/array.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,aAAa,CAAA;AA4LpD,eAAO,MAAM,SAAS,EAAE,IAsCvB,CAAA"}
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import { walkAst } from './ast-utils.js';
|
|
2
|
-
/**
|
|
3
|
-
* PG's `col = ANY(<array>)` is the portable variable-length IN list: one bind
|
|
4
|
-
* slot holds the whole array, so callers don't have to build `IN ($1,$2,$3)`
|
|
5
|
-
* per call. SQLite has no ANY/ALL operator, so passing it through fails at
|
|
6
|
-
* prepare with "no such function: ANY" — the same shape as the json_agg gap.
|
|
7
|
-
*
|
|
8
|
-
* The rewrite mirrors what the DO proxy already does for its own SQL:
|
|
9
|
-
*
|
|
10
|
-
* col = ANY(<array>) → col IN (SELECT value FROM json_each(<array>))
|
|
11
|
-
* col <> ALL(<array>) → NOT (col IN (SELECT value FROM json_each(<array>)))
|
|
12
|
-
*
|
|
13
|
-
* json_each() reads a JSON array, so the operand has to arrive as JSON text:
|
|
14
|
-
*
|
|
15
|
-
* - ARRAY[...] / '{a,b}' literals are folded to a JSON string here.
|
|
16
|
-
* - a bind param can't be: its value shows up at execute, not compile. So we
|
|
17
|
-
* record its number in `arrayParamNumbers` and the caller JSON-encodes that
|
|
18
|
-
* slot. Everything else (a column already holding JSON text) passes through.
|
|
19
|
-
*
|
|
20
|
-
* `= ANY(SELECT …)` is a SubLink, not an A_Expr, and is left alone.
|
|
21
|
-
*/
|
|
22
|
-
function operatorName(expr) {
|
|
23
|
-
const parts = expr?.name;
|
|
24
|
-
if (!Array.isArray(parts) || parts.length === 0)
|
|
25
|
-
return null;
|
|
26
|
-
const value = parts[parts.length - 1]?.String?.sval;
|
|
27
|
-
return typeof value === 'string' ? value : null;
|
|
28
|
-
}
|
|
29
|
-
function stringConst(value) {
|
|
30
|
-
return { A_Const: { sval: { sval: value } } };
|
|
31
|
-
}
|
|
32
|
-
/** `{a,"b c",NULL}` → ['a', 'b c', null]; null when not an array literal. */
|
|
33
|
-
function parsePgArrayLiteral(value) {
|
|
34
|
-
if (value[0] !== '{' || value[value.length - 1] !== '}')
|
|
35
|
-
return null;
|
|
36
|
-
const items = [];
|
|
37
|
-
let i = 1;
|
|
38
|
-
while (i < value.length - 1) {
|
|
39
|
-
if (value[i] === ',') {
|
|
40
|
-
i++;
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
if (value[i] === '"') {
|
|
44
|
-
i++;
|
|
45
|
-
let out = '';
|
|
46
|
-
while (i < value.length - 1) {
|
|
47
|
-
const ch = value[i];
|
|
48
|
-
if (ch === '\\') {
|
|
49
|
-
if (i + 1 < value.length - 1)
|
|
50
|
-
out += value[i + 1];
|
|
51
|
-
i += 2;
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
if (ch === '"') {
|
|
55
|
-
i++;
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
out += ch;
|
|
59
|
-
i++;
|
|
60
|
-
}
|
|
61
|
-
items.push(out);
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
const start = i;
|
|
65
|
-
while (i < value.length - 1 && value[i] !== ',')
|
|
66
|
-
i++;
|
|
67
|
-
const token = value.slice(start, i);
|
|
68
|
-
items.push(token === 'NULL' ? null : token);
|
|
69
|
-
}
|
|
70
|
-
return items;
|
|
71
|
-
}
|
|
72
|
-
const NON_LITERAL = Symbol('non-literal');
|
|
73
|
-
function literalValue(node) {
|
|
74
|
-
const constValue = node?.A_Const;
|
|
75
|
-
if (constValue) {
|
|
76
|
-
if (Object.hasOwn(constValue, 'isnull'))
|
|
77
|
-
return null;
|
|
78
|
-
if (Object.hasOwn(constValue, 'sval'))
|
|
79
|
-
return constValue.sval?.sval ?? '';
|
|
80
|
-
if (Object.hasOwn(constValue, 'ival'))
|
|
81
|
-
return constValue.ival?.ival ?? 0;
|
|
82
|
-
if (Object.hasOwn(constValue, 'fval')) {
|
|
83
|
-
const raw = constValue.fval?.fval ?? '';
|
|
84
|
-
const parsed = Number(raw);
|
|
85
|
-
return Number.isFinite(parsed) ? parsed : raw;
|
|
86
|
-
}
|
|
87
|
-
if (Object.hasOwn(constValue, 'boolval'))
|
|
88
|
-
return constValue.boolval?.boolval === true;
|
|
89
|
-
}
|
|
90
|
-
if (node?.A_ArrayExpr)
|
|
91
|
-
return arrayLiteralValue(node.A_ArrayExpr);
|
|
92
|
-
return NON_LITERAL;
|
|
93
|
-
}
|
|
94
|
-
function arrayLiteralValue(arrayExpr) {
|
|
95
|
-
const values = [];
|
|
96
|
-
for (const element of arrayExpr?.elements ?? []) {
|
|
97
|
-
const value = literalValue(element);
|
|
98
|
-
if (value === NON_LITERAL)
|
|
99
|
-
return NON_LITERAL;
|
|
100
|
-
values.push(value);
|
|
101
|
-
}
|
|
102
|
-
return values;
|
|
103
|
-
}
|
|
104
|
-
/** Strip casts down to the node that carries the value (`$1::text[]` → `$1`). */
|
|
105
|
-
function unwrapTypeCast(node) {
|
|
106
|
-
let current = node;
|
|
107
|
-
while (current?.TypeCast)
|
|
108
|
-
current = current.TypeCast.arg;
|
|
109
|
-
return current;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Turn an ANY/ALL operand into something json_each() can read, recording the
|
|
113
|
-
* bind slot when the value only exists at execute time.
|
|
114
|
-
*/
|
|
115
|
-
function jsonArrayOperand(node, ctx) {
|
|
116
|
-
const inner = unwrapTypeCast(node);
|
|
117
|
-
const paramNumber = inner?.ParamRef?.number;
|
|
118
|
-
if (typeof paramNumber === 'number') {
|
|
119
|
-
ctx.arrayParamNumbers?.add(paramNumber);
|
|
120
|
-
return inner;
|
|
121
|
-
}
|
|
122
|
-
if (inner?.A_ArrayExpr) {
|
|
123
|
-
const values = arrayLiteralValue(inner.A_ArrayExpr);
|
|
124
|
-
if (values !== NON_LITERAL)
|
|
125
|
-
return stringConst(JSON.stringify(values));
|
|
126
|
-
return inner;
|
|
127
|
-
}
|
|
128
|
-
const literal = inner?.A_Const?.sval?.sval;
|
|
129
|
-
if (typeof literal === 'string') {
|
|
130
|
-
const items = parsePgArrayLiteral(literal);
|
|
131
|
-
if (items)
|
|
132
|
-
return stringConst(JSON.stringify(items));
|
|
133
|
-
}
|
|
134
|
-
return inner;
|
|
135
|
-
}
|
|
136
|
-
function jsonEachSelect(operand) {
|
|
137
|
-
return {
|
|
138
|
-
SelectStmt: {
|
|
139
|
-
targetList: [
|
|
140
|
-
{
|
|
141
|
-
ResTarget: {
|
|
142
|
-
val: { ColumnRef: { fields: [{ String: { sval: 'value' } }], location: -1 } },
|
|
143
|
-
location: -1,
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
],
|
|
147
|
-
fromClause: [
|
|
148
|
-
{
|
|
149
|
-
RangeFunction: {
|
|
150
|
-
functions: [
|
|
151
|
-
{
|
|
152
|
-
List: {
|
|
153
|
-
items: [
|
|
154
|
-
{
|
|
155
|
-
FuncCall: {
|
|
156
|
-
funcname: [{ String: { sval: 'json_each' } }],
|
|
157
|
-
args: [operand],
|
|
158
|
-
funcformat: 'COERCE_EXPLICIT_CALL',
|
|
159
|
-
location: -1,
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
{},
|
|
163
|
-
],
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
],
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
],
|
|
170
|
-
limitOption: 'LIMIT_OPTION_DEFAULT',
|
|
171
|
-
op: 'SETOP_NONE',
|
|
172
|
-
},
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
/** `testexpr IN (SELECT value FROM json_each(operand))` */
|
|
176
|
-
function inJsonEach(testexpr, operand) {
|
|
177
|
-
return {
|
|
178
|
-
SubLink: {
|
|
179
|
-
subLinkType: 'ANY_SUBLINK',
|
|
180
|
-
testexpr,
|
|
181
|
-
subselect: jsonEachSelect(operand),
|
|
182
|
-
location: -1,
|
|
183
|
-
},
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
export const arrayPass = {
|
|
187
|
-
name: 'array',
|
|
188
|
-
run(rawStmt, ctx) {
|
|
189
|
-
walkAst(rawStmt, {
|
|
190
|
-
A_Expr: (node, parent, key) => {
|
|
191
|
-
if (!parent)
|
|
192
|
-
return;
|
|
193
|
-
const op = operatorName(node);
|
|
194
|
-
if (node.kind === 'AEXPR_OP_ANY' && op === '=') {
|
|
195
|
-
parent[key] = inJsonEach(node.lexpr, jsonArrayOperand(node.rexpr, ctx));
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
if (node.kind === 'AEXPR_OP_ALL' && op === '<>') {
|
|
199
|
-
parent[key] = {
|
|
200
|
-
BoolExpr: {
|
|
201
|
-
boolop: 'NOT_EXPR',
|
|
202
|
-
args: [inJsonEach(node.lexpr, jsonArrayOperand(node.rexpr, ctx))],
|
|
203
|
-
location: -1,
|
|
204
|
-
},
|
|
205
|
-
};
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
// every other ANY/ALL operator (> ANY, <= ALL, LIKE ANY …) has no
|
|
209
|
-
// json_each equivalent that preserves semantics, so say so rather than
|
|
210
|
-
// emit SQL that dies at prepare.
|
|
211
|
-
if (node.kind === 'AEXPR_OP_ANY' || node.kind === 'AEXPR_OP_ALL') {
|
|
212
|
-
const form = node.kind === 'AEXPR_OP_ANY' ? 'ANY' : 'ALL';
|
|
213
|
-
ctx.warnings.push({
|
|
214
|
-
kind: 'unsupported-array-operator',
|
|
215
|
-
near: 'A_Expr',
|
|
216
|
-
message: `${op ?? '?'} ${form}(...) is not supported by pg-to-sqlite`,
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
|
-
});
|
|
221
|
-
},
|
|
222
|
-
};
|
|
223
|
-
//# sourceMappingURL=array.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array.js","sourceRoot":"","sources":["../../../src/pg-sqlite-compiler/passes/array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAIxC;;;;;;;;;;;;;;;;;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AC,GAAG,CAAC,GAAG;wBACZ,QAAQ,EAAE;4BACR,MAAM,EAAE,UAAU;4BAClB,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,gBAAgB,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;4BACjE,QAAQ,EAAE,CAAC,CAAC;yBACb;qBACF,CAAA;oBACD,OAAM;gBACR,CAAC;gBAED,kEAAkE;gBAClE,uEAAuE;gBACvE,iCAAiC;gBACjC,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;oBACjE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA;oBACzD,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;wBAChB,IAAI,EAAE,4BAA4B;wBAClC,IAAI,EAAE,QAAQ;wBACd,OAAO,EAAE,GAAG,EAAE,IAAI,GAAG,IAAI,IAAI,wCAAwC;qBACtE,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AST traversal helpers tailored to the libpg_query output.
|
|
3
|
-
*
|
|
4
|
-
* The official @pgsql/traverse offers two APIs:
|
|
5
|
-
*
|
|
6
|
-
* walk() — uses a runtime schema; recurses into both tag-wrapped nodes
|
|
7
|
-
* ({SelectStmt:...}) AND unwrapped sub-fields (ColumnDef.typeName
|
|
8
|
-
* is *not* tag-wrapped — it's a plain object). Good for traversal,
|
|
9
|
-
* but mutation requires keyPath bookkeeping.
|
|
10
|
-
*
|
|
11
|
-
* visit() — only recurses into tag-wrapped objects with exactly one key.
|
|
12
|
-
* Misses non-wrapped sub-fields like typeName.
|
|
13
|
-
*
|
|
14
|
-
* For our compiler passes we want: "visit every node of a given tag, AND
|
|
15
|
-
* also visit unwrapped sub-objects that have a known tag-like field set."
|
|
16
|
-
* The simplest reliable approach is a hand-rolled walk: recurse over every
|
|
17
|
-
* object/array, fire callbacks keyed by either (a) the tag wrapper key, or
|
|
18
|
-
* (b) the parent field-name for in-place node types we want to visit
|
|
19
|
-
* (typeName etc.).
|
|
20
|
-
*
|
|
21
|
-
* Each callback gets `(node, parent, key)` so mutation is local: just
|
|
22
|
-
* reassign `parent[key]` (for tag-wrapped) or mutate `node` in place (for
|
|
23
|
-
* unwrapped sub-fields).
|
|
24
|
-
*/
|
|
25
|
-
export type NodeCallback = (node: any, parent: any, key: string | number) => void;
|
|
26
|
-
export interface VisitorMap {
|
|
27
|
-
/**
|
|
28
|
-
* Tag-wrapped nodes: keyed by the wrapper tag name (FuncCall, SelectStmt,
|
|
29
|
-
* SQLValueFunction, etc.). The callback receives the *inner* node data.
|
|
30
|
-
*
|
|
31
|
-
* Also accepts the synthetic tag names for unwrapped sub-fields listed in
|
|
32
|
-
* UNWRAPPED_FIELDS — e.g. `TypeName` fires for the value at any
|
|
33
|
-
* `someParent.typeName` slot.
|
|
34
|
-
*/
|
|
35
|
-
[tag: string]: NodeCallback | undefined;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Walk a node tree firing callbacks. For tag-wrapped nodes ({Tag: data}),
|
|
39
|
-
* the callback fires on `data` (inner) with parent=the wrapper's parent,
|
|
40
|
-
* key=where the wrapper sits. For unwrapped sub-fields (typeName etc.),
|
|
41
|
-
* fires on the object directly with parent=its container, key=field name.
|
|
42
|
-
*
|
|
43
|
-
* Mutation rules:
|
|
44
|
-
* - tag-wrapped: assign `parent[key] = newWrapper` to replace the node
|
|
45
|
-
* - unwrapped: mutate `node` in place (it's already the live object)
|
|
46
|
-
*/
|
|
47
|
-
export declare function walkAst(root: any, visitors: VisitorMap): void;
|
|
48
|
-
//# sourceMappingURL=ast-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ast-utils.d.ts","sourceRoot":"","sources":["../../../src/pg-sqlite-compiler/passes/ast-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAA;AAEjF,MAAM,WAAW,UAAU;IACzB;;;;;;;OAOG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAAA;CACxC;AA4BD;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,GAAG,IAAI,CAqC7D"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AST traversal helpers tailored to the libpg_query output.
|
|
3
|
-
*
|
|
4
|
-
* The official @pgsql/traverse offers two APIs:
|
|
5
|
-
*
|
|
6
|
-
* walk() — uses a runtime schema; recurses into both tag-wrapped nodes
|
|
7
|
-
* ({SelectStmt:...}) AND unwrapped sub-fields (ColumnDef.typeName
|
|
8
|
-
* is *not* tag-wrapped — it's a plain object). Good for traversal,
|
|
9
|
-
* but mutation requires keyPath bookkeeping.
|
|
10
|
-
*
|
|
11
|
-
* visit() — only recurses into tag-wrapped objects with exactly one key.
|
|
12
|
-
* Misses non-wrapped sub-fields like typeName.
|
|
13
|
-
*
|
|
14
|
-
* For our compiler passes we want: "visit every node of a given tag, AND
|
|
15
|
-
* also visit unwrapped sub-objects that have a known tag-like field set."
|
|
16
|
-
* The simplest reliable approach is a hand-rolled walk: recurse over every
|
|
17
|
-
* object/array, fire callbacks keyed by either (a) the tag wrapper key, or
|
|
18
|
-
* (b) the parent field-name for in-place node types we want to visit
|
|
19
|
-
* (typeName etc.).
|
|
20
|
-
*
|
|
21
|
-
* Each callback gets `(node, parent, key)` so mutation is local: just
|
|
22
|
-
* reassign `parent[key]` (for tag-wrapped) or mutate `node` in place (for
|
|
23
|
-
* unwrapped sub-fields).
|
|
24
|
-
*/
|
|
25
|
-
/**
|
|
26
|
-
* Unwrapped fields: child-key → semantic tag name. When a node has a child
|
|
27
|
-
* field with one of these names whose value is a plain object (no tag wrapper),
|
|
28
|
-
* we fire the corresponding visitor against that value.
|
|
29
|
-
*/
|
|
30
|
-
const UNWRAPPED_FIELDS = {
|
|
31
|
-
// ColumnDef.typeName, TypeCast.typeName, etc. are TypeName nodes, not wrapped
|
|
32
|
-
typeName: 'TypeName',
|
|
33
|
-
// SelectStmt.fromClause[i] is sometimes a wrapped RangeVar but in some
|
|
34
|
-
// sub-positions (FROM-list with single table) it appears unwrapped.
|
|
35
|
-
relation: 'RangeVar',
|
|
36
|
-
};
|
|
37
|
-
function fireForChild(visitors, childKey, childValue, parent) {
|
|
38
|
-
const tag = UNWRAPPED_FIELDS[childKey];
|
|
39
|
-
if (!tag)
|
|
40
|
-
return;
|
|
41
|
-
if (!childValue || typeof childValue !== 'object' || Array.isArray(childValue))
|
|
42
|
-
return;
|
|
43
|
-
const cb = visitors[tag];
|
|
44
|
-
if (cb)
|
|
45
|
-
cb(childValue, parent, childKey);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Walk a node tree firing callbacks. For tag-wrapped nodes ({Tag: data}),
|
|
49
|
-
* the callback fires on `data` (inner) with parent=the wrapper's parent,
|
|
50
|
-
* key=where the wrapper sits. For unwrapped sub-fields (typeName etc.),
|
|
51
|
-
* fires on the object directly with parent=its container, key=field name.
|
|
52
|
-
*
|
|
53
|
-
* Mutation rules:
|
|
54
|
-
* - tag-wrapped: assign `parent[key] = newWrapper` to replace the node
|
|
55
|
-
* - unwrapped: mutate `node` in place (it's already the live object)
|
|
56
|
-
*/
|
|
57
|
-
export function walkAst(root, visitors) {
|
|
58
|
-
function recurse(node, parent, key) {
|
|
59
|
-
if (node == null || typeof node !== 'object')
|
|
60
|
-
return;
|
|
61
|
-
if (Array.isArray(node)) {
|
|
62
|
-
for (let i = 0; i < node.length; i++)
|
|
63
|
-
recurse(node[i], node, i);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const keys = Object.keys(node);
|
|
67
|
-
// Tag-wrapper case: {Tag: data}
|
|
68
|
-
if (keys.length === 1 && /^[A-Z]/.test(keys[0])) {
|
|
69
|
-
const tag = keys[0];
|
|
70
|
-
const data = node[tag];
|
|
71
|
-
const cb = visitors[tag];
|
|
72
|
-
if (cb)
|
|
73
|
-
cb(data, parent, key);
|
|
74
|
-
// recurse into the inner data
|
|
75
|
-
if (data && typeof data === 'object') {
|
|
76
|
-
for (const childKey of Object.keys(data)) {
|
|
77
|
-
// fire unwrapped-field visitors BEFORE recursing into the field
|
|
78
|
-
fireForChild(visitors, childKey, data[childKey], data);
|
|
79
|
-
recurse(data[childKey], data, childKey);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
// Non-wrapper object case (already an unwrapped sub-tree). Recurse,
|
|
85
|
-
// firing unwrapped-field visitors as we encounter named child fields.
|
|
86
|
-
for (const childKey of keys) {
|
|
87
|
-
fireForChild(visitors, childKey, node[childKey], node);
|
|
88
|
-
recurse(node[childKey], node, childKey);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
recurse(root, null, '');
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=ast-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ast-utils.js","sourceRoot":"","sources":["../../../src/pg-sqlite-compiler/passes/ast-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAgBH;;;;GAIG;AACH,MAAM,gBAAgB,GAA2B;IAC/C,8EAA8E;IAC9E,QAAQ,EAAE,UAAU;IACpB,uEAAuE;IACvE,oEAAoE;IACpE,QAAQ,EAAE,UAAU;CACrB,CAAA;AAED,SAAS,YAAY,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BAAE,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA;YAC7B,8BAA8B;YAC9B,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACrC,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;oBACzC,gEAAgE;oBAChE,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAA;oBACtD,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAA;gBACzC,CAAC;YACH,CAAC;YACD,OAAM;QACR,CAAC;QAED,oEAAoE;QACpE,sEAAsE;QACtE,KAAK,MAAM,QAAQ,IAAI,IAAI,EAAE,CAAC;YAC5B,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAA;YACtD,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAA;QACzC,CAAC;IACH,CAAC;IAED,OAAO,CAAC,IAAI,EAAE,IAAW,EAAE,EAAS,CAAC,CAAA;AACvC,CAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Catalog pass.
|
|
3
|
-
*
|
|
4
|
-
* Rewrites schema-qualified PG catalog references to the
|
|
5
|
-
* `_orez_catalog__*` namespace (seeded by `catalog/seed.ts` at DO init):
|
|
6
|
-
*
|
|
7
|
-
* pg_catalog.pg_class → _orez_catalog__pg_class
|
|
8
|
-
* information_schema.columns → _orez_catalog__information_schema_columns
|
|
9
|
-
*
|
|
10
|
-
* Why this matters:
|
|
11
|
-
* zero-cache (and most PG client libraries) probes the PG system catalog
|
|
12
|
-
* on startup. They always qualify these references with `pg_catalog.` or
|
|
13
|
-
* `information_schema.` — that's how `search_path` resolution works in PG
|
|
14
|
-
* and how every generated catalog query (libpq, psql, postgres.js) emits
|
|
15
|
-
* them.
|
|
16
|
-
*
|
|
17
|
-
* Why we DON'T rewrite bare `pg_class` (no schema):
|
|
18
|
-
* - it's user-table-namespace ambiguous (an app could legitimately call
|
|
19
|
-
* a table `pg_user`, `pg_views`, etc.)
|
|
20
|
-
* - bare catalog refs only resolve in PG via search_path; clients
|
|
21
|
-
* emitting catalog queries qualify them explicitly. Bare references in
|
|
22
|
-
* real apps are essentially always user tables.
|
|
23
|
-
* - silently hijacking them caused WRITE-path bugs (DML against a user
|
|
24
|
-
* table got routed to a synthetic catalog table) in earlier iterations
|
|
25
|
-
*
|
|
26
|
-
* If a future workload sends bare catalog refs we'll add a per-statement
|
|
27
|
-
* opt-in (e.g. `WHERE rewrite_unqualified_catalog`) rather than a
|
|
28
|
-
* footgun-prone global toggle.
|
|
29
|
-
*
|
|
30
|
-
* Companion module: `catalog/seed.ts` creates the target tables on DO init.
|
|
31
|
-
*/
|
|
32
|
-
import type { Pass } from '../types.js';
|
|
33
|
-
export declare const catalogPass: Pass;
|
|
34
|
-
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/pg-sqlite-compiler/passes/catalog.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAqBvC,eAAO,MAAM,WAAW,EAAE,IAUzB,CAAA"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { walkAst } from './ast-utils.js';
|
|
2
|
-
const CATALOG_PREFIX = '_orez_catalog__';
|
|
3
|
-
const FLATTENED_SCHEMAS = new Set(['information_schema']);
|
|
4
|
-
function rewriteRangeVar(node) {
|
|
5
|
-
// pg_catalog.X — strip schema, prefix relname
|
|
6
|
-
if (node.schemaname === 'pg_catalog') {
|
|
7
|
-
node.relname = `${CATALOG_PREFIX}${node.relname}`;
|
|
8
|
-
delete node.schemaname;
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
// information_schema.X — flatten to _orez_catalog__information_schema_X
|
|
12
|
-
if (FLATTENED_SCHEMAS.has(node.schemaname)) {
|
|
13
|
-
node.relname = `${CATALOG_PREFIX}${node.schemaname}_${node.relname}`;
|
|
14
|
-
delete node.schemaname;
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export const catalogPass = {
|
|
19
|
-
name: 'catalog',
|
|
20
|
-
run(rawStmt, _ctx) {
|
|
21
|
-
walkAst(rawStmt, {
|
|
22
|
-
RangeVar: (node) => {
|
|
23
|
-
if (!node || typeof node !== 'object')
|
|
24
|
-
return;
|
|
25
|
-
rewriteRangeVar(node);
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=catalog.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../../src/pg-sqlite-compiler/passes/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAmCxC,MAAM,cAAc,GAAG,iBAAiB,CAAA;AACxC,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAA;AAEzD,SAAS,eAAe,CAAC,IAAS;IAChC,8CAA8C;IAC9C,IAAI,IAAI,CAAC,UAAU,KAAK,YAAY,EAAE,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,GAAG,cAAc,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;QACjD,OAAO,IAAI,CAAC,UAAU,CAAA;QACtB,OAAM;IACR,CAAC;IAED,wEAAwE;IACxE,IAAI,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3C,IAAI,CAAC,OAAO,GAAG,GAAG,cAAc,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,OAAO,EAAE,CAAA;QACpE,OAAO,IAAI,CAAC,UAAU,CAAA;QACtB,OAAM;IACR,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAS;IAC/B,IAAI,EAAE,SAAS;IACf,GAAG,CAAC,OAAO,EAAE,IAAI;QACf,OAAO,CAAC,OAAO,EAAE;YACf,QAAQ,EAAE,CAAC,IAAS,EAAE,EAAE;gBACtB,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;oBAAE,OAAM;gBAC7C,eAAe,CAAC,IAAI,CAAC,CAAA;YACvB,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* datetime pass.
|
|
3
|
-
*
|
|
4
|
-
* Rewrites PG datetime functions to SQLite-native equivalents:
|
|
5
|
-
* NOW() → CURRENT_TIMESTAMP (function call → keyword)
|
|
6
|
-
* CURRENT_TIMESTAMP() → CURRENT_TIMESTAMP (if it ever parses as a FuncCall)
|
|
7
|
-
* CURRENT_DATE() → CURRENT_DATE
|
|
8
|
-
* CURRENT_TIME() → CURRENT_TIME
|
|
9
|
-
* pg_catalog.now() → CURRENT_TIMESTAMP
|
|
10
|
-
*
|
|
11
|
-
* Why it matters: in SQLite, `DEFAULT NOW()` is rejected because column
|
|
12
|
-
* defaults only accept a small expression grammar. `DEFAULT CURRENT_TIMESTAMP`
|
|
13
|
-
* is accepted everywhere (and is what every "I want NOW() in a default" PG
|
|
14
|
-
* user actually wants).
|
|
15
|
-
*
|
|
16
|
-
* For richer datetime work (EXTRACT, DATE_TRUNC, INTERVAL arithmetic) we'll
|
|
17
|
-
* extend this pass in follow-ups. v1 covers the high-frequency cases.
|
|
18
|
-
*/
|
|
19
|
-
import type { Pass } from '../types.js';
|
|
20
|
-
/** Return the SQLite-compatible value node for one PG datetime call. */
|
|
21
|
-
export declare function rewriteDatetimeFunctionCall(node: any): any | undefined;
|
|
22
|
-
export declare const datetimePass: Pass;
|
|
23
|
-
//# sourceMappingURL=datetime.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"datetime.d.ts","sourceRoot":"","sources":["../../../src/pg-sqlite-compiler/passes/datetime.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAuBvC,wEAAwE;AACxE,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,GAAG,SAAS,CAYtE;AAED,eAAO,MAAM,YAAY,EAAE,IAe1B,CAAA"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { walkAst } from './ast-utils.js';
|
|
2
|
-
function lowerFuncName(funcname) {
|
|
3
|
-
if (!funcname || funcname.length === 0)
|
|
4
|
-
return undefined;
|
|
5
|
-
const last = funcname[funcname.length - 1];
|
|
6
|
-
const str = last?.String?.sval ?? last?.String?.str;
|
|
7
|
-
return typeof str === 'string' ? str.toLowerCase() : undefined;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Build a PG `SQLValueFunction` node — this is the canonical AST representation
|
|
11
|
-
* of bareword time keywords like CURRENT_TIMESTAMP / CURRENT_DATE / CURRENT_TIME.
|
|
12
|
-
* The deparser emits these as bareword keywords (no quotes, no parens), and
|
|
13
|
-
* SQLite accepts CURRENT_TIMESTAMP/CURRENT_DATE/CURRENT_TIME as keywords too.
|
|
14
|
-
*/
|
|
15
|
-
function svfWrapper(op) {
|
|
16
|
-
return {
|
|
17
|
-
SQLValueFunction: { op, typmod: -1, location: 0 },
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
/** Return the SQLite-compatible value node for one PG datetime call. */
|
|
21
|
-
export function rewriteDatetimeFunctionCall(node) {
|
|
22
|
-
const name = lowerFuncName(node?.funcname);
|
|
23
|
-
if (!name)
|
|
24
|
-
return undefined;
|
|
25
|
-
const argless = !node.args || (Array.isArray(node.args) && node.args.length === 0);
|
|
26
|
-
if (!argless)
|
|
27
|
-
return undefined;
|
|
28
|
-
if (name === 'now' || name === 'current_timestamp' || name === 'clock_timestamp') {
|
|
29
|
-
return svfWrapper('SVFOP_CURRENT_TIMESTAMP');
|
|
30
|
-
}
|
|
31
|
-
if (name === 'current_date')
|
|
32
|
-
return svfWrapper('SVFOP_CURRENT_DATE');
|
|
33
|
-
if (name === 'current_time')
|
|
34
|
-
return svfWrapper('SVFOP_CURRENT_TIME');
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
export const datetimePass = {
|
|
38
|
-
name: 'datetime',
|
|
39
|
-
run(rawStmt, _ctx) {
|
|
40
|
-
walkAst(rawStmt, {
|
|
41
|
-
FuncCall: (node, parent, key) => {
|
|
42
|
-
if (parent == null)
|
|
43
|
-
return; // can't replace a root-positioned FuncCall
|
|
44
|
-
// Map PG datetime function calls → SQL bareword time keywords. The PG
|
|
45
|
-
// AST distinguishes function-form (`now()`) from keyword-form
|
|
46
|
-
// (`CURRENT_TIMESTAMP`) at the parse level; SQLite only accepts the
|
|
47
|
-
// keyword form in DEFAULT clauses and uniformly elsewhere.
|
|
48
|
-
const rewritten = rewriteDatetimeFunctionCall(node);
|
|
49
|
-
if (rewritten)
|
|
50
|
-
parent[key] = rewritten;
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
//# sourceMappingURL=datetime.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"datetime.js","sourceRoot":"","sources":["../../../src/pg-sqlite-compiler/passes/datetime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAsBxC,SAAS,aAAa,CAAC,QAA2B;IAChD,IAAI,CAAC,QAAQ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AO,SAAS,CAAA;AAClB,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAS;IAChC,IAAI,EAAE,UAAU;IAChB,GAAG,CAAC,OAAO,EAAE,IAAI;QACf,OAAO,CAAC,OAAO,EAAE;YACf,QAAQ,EAAE,CAAC,IAAS,EAAE,MAAW,EAAE,GAAoB,EAAE,EAAE;gBACzD,IAAI,MAAM,IAAI,IAAI;oBAAE,OAAM,CAAC,2CAA2C;gBACtE,sEAAsE;gBACtE,8DAA8D;gBAC9D,oEAAoE;gBACpE,2DAA2D;gBAC3D,MAAM,SAAS,GAAG,2BAA2B,CAAC,IAAI,CAAC,CAAA;gBACnD,IAAI,SAAS;oBAAE,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAA;YACxC,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Pass } from '../types.js';
|
|
2
|
-
export declare const COUNT_MARKER_PREFIX = "__orez_count__";
|
|
3
|
-
/**
|
|
4
|
-
* Restructure a counted-delete CTE statement in place. `stmt` is the inner
|
|
5
|
-
* tag-wrapped statement node (`{ SelectStmt: … }`). Returns the count column
|
|
6
|
-
* name when the statement matched and was rewritten, else null (untouched).
|
|
7
|
-
*/
|
|
8
|
-
export declare function transformCountedDeleteCte(stmt: any): {
|
|
9
|
-
countColumn: string;
|
|
10
|
-
} | null;
|
|
11
|
-
/**
|
|
12
|
-
* Fold an executed counted-delete result back into the original statement's
|
|
13
|
-
* shape: N marker rows → `[{ <col>: N }]`. `columnsOrSql` is either the
|
|
14
|
-
* result column list or the executed SQL (for zero-row results, where some
|
|
15
|
-
* drivers report no columns). Returns null when the marker is absent.
|
|
16
|
-
*/
|
|
17
|
-
export declare function foldCountMarkerResult(rowCount: number, columnsOrSql: readonly string[] | string): {
|
|
18
|
-
rows: Array<Record<string, number>>;
|
|
19
|
-
columns: string[];
|
|
20
|
-
} | null;
|
|
21
|
-
export declare const dmlCtePass: Pass;
|
|
22
|
-
//# sourceMappingURL=dml-cte.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dml-cte.d.ts","sourceRoot":"","sources":["../../../src/pg-sqlite-compiler/passes/dml-cte.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAEvC,eAAO,MAAM,mBAAmB,mBAAmB,CAAA;AAiCnD;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,GAAG,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CA2DnF;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GACvC;IAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,IAAI,CAWnE;AAED,eAAO,MAAM,UAAU,EAAE,IAuBxB,CAAA"}
|