@polyglot-sql/sdk 0.5.2 → 0.5.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/README.md +62 -14
- package/dist/cdn/polyglot.esm.js +1775 -1702
- package/dist/index.cjs +146 -27
- package/dist/index.d.cts +38 -1
- package/dist/index.d.ts +38 -1
- package/dist/index.js +163 -27
- package/dist/index.node.js +143 -27
- package/dist/manual.js +157 -25
- package/dist/polyglot_sql.wasm +0 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1864,6 +1864,30 @@ function ast_get_table_names$1(ast_json) {
|
|
|
1864
1864
|
}
|
|
1865
1865
|
}
|
|
1866
1866
|
|
|
1867
|
+
/**
|
|
1868
|
+
* Get all table nodes from an AST (as JSON string).
|
|
1869
|
+
* @param {string} ast_json
|
|
1870
|
+
* @returns {string}
|
|
1871
|
+
*/
|
|
1872
|
+
function ast_get_tables$1(ast_json) {
|
|
1873
|
+
let deferred2_0;
|
|
1874
|
+
let deferred2_1;
|
|
1875
|
+
try {
|
|
1876
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
1877
|
+
const ptr0 = passStringToWasm0(ast_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
1878
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1879
|
+
wasm$3.ast_get_tables(retptr, ptr0, len0);
|
|
1880
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1881
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1882
|
+
deferred2_0 = r0;
|
|
1883
|
+
deferred2_1 = r1;
|
|
1884
|
+
return getStringFromWasm0(r0, r1);
|
|
1885
|
+
} finally {
|
|
1886
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
1887
|
+
wasm$3.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1867
1891
|
/**
|
|
1868
1892
|
* Get all window functions from an AST (as JSON string).
|
|
1869
1893
|
* @param {string} ast_json
|
|
@@ -2124,6 +2148,58 @@ function ast_set_limit$1(ast_json, limit) {
|
|
|
2124
2148
|
}
|
|
2125
2149
|
}
|
|
2126
2150
|
|
|
2151
|
+
/**
|
|
2152
|
+
* Set the OFFSET on a SELECT or set-operation AST.
|
|
2153
|
+
* @param {string} ast_json
|
|
2154
|
+
* @param {number} offset
|
|
2155
|
+
* @returns {string}
|
|
2156
|
+
*/
|
|
2157
|
+
function ast_set_offset$1(ast_json, offset) {
|
|
2158
|
+
let deferred2_0;
|
|
2159
|
+
let deferred2_1;
|
|
2160
|
+
try {
|
|
2161
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
2162
|
+
const ptr0 = passStringToWasm0(ast_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2163
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2164
|
+
wasm$3.ast_set_offset(retptr, ptr0, len0, offset);
|
|
2165
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2166
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2167
|
+
deferred2_0 = r0;
|
|
2168
|
+
deferred2_1 = r1;
|
|
2169
|
+
return getStringFromWasm0(r0, r1);
|
|
2170
|
+
} finally {
|
|
2171
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
2172
|
+
wasm$3.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
/**
|
|
2177
|
+
* Set the ORDER BY clause on a SELECT or set-operation AST.
|
|
2178
|
+
* @param {string} ast_json
|
|
2179
|
+
* @param {string} order_by_json
|
|
2180
|
+
* @returns {string}
|
|
2181
|
+
*/
|
|
2182
|
+
function ast_set_order_by$1(ast_json, order_by_json) {
|
|
2183
|
+
let deferred3_0;
|
|
2184
|
+
let deferred3_1;
|
|
2185
|
+
try {
|
|
2186
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
2187
|
+
const ptr0 = passStringToWasm0(ast_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2188
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2189
|
+
const ptr1 = passStringToWasm0(order_by_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2190
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2191
|
+
wasm$3.ast_set_order_by(retptr, ptr0, len0, ptr1, len1);
|
|
2192
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2193
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2194
|
+
deferred3_0 = r0;
|
|
2195
|
+
deferred3_1 = r1;
|
|
2196
|
+
return getStringFromWasm0(r0, r1);
|
|
2197
|
+
} finally {
|
|
2198
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
2199
|
+
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
|
|
2127
2203
|
/**
|
|
2128
2204
|
* Diff two SQL statements and return edit operations.
|
|
2129
2205
|
*
|
|
@@ -3307,10 +3383,6 @@ function __wbg_call_389efe28435a9388() { return handleError(function (arg0, arg1
|
|
|
3307
3383
|
const ret = getObject(arg0).call(getObject(arg1));
|
|
3308
3384
|
return addHeapObject(ret);
|
|
3309
3385
|
}, arguments); }
|
|
3310
|
-
function __wbg_codePointAt_bf59dbf74d8db275(arg0, arg1) {
|
|
3311
|
-
const ret = getObject(arg0).codePointAt(arg1 >>> 0);
|
|
3312
|
-
return addHeapObject(ret);
|
|
3313
|
-
}
|
|
3314
3386
|
function __wbg_done_57b39ecd9addfe81(arg0) {
|
|
3315
3387
|
const ret = getObject(arg0).done;
|
|
3316
3388
|
return ret;
|
|
@@ -3396,10 +3468,6 @@ function __wbg_length_35a7bace40f36eac(arg0) {
|
|
|
3396
3468
|
const ret = getObject(arg0).length;
|
|
3397
3469
|
return ret;
|
|
3398
3470
|
}
|
|
3399
|
-
function __wbg_length_68dc7c5cf1b6d349(arg0) {
|
|
3400
|
-
const ret = getObject(arg0).length;
|
|
3401
|
-
return ret;
|
|
3402
|
-
}
|
|
3403
3471
|
function __wbg_new_361308b2356cecd0() {
|
|
3404
3472
|
const ret = new Object();
|
|
3405
3473
|
return addHeapObject(ret);
|
|
@@ -3764,9 +3832,7 @@ const __vite__wasmModule = await __vite__initWasm({ "./polyglot_sql_wasm_bg.js":
|
|
|
3764
3832
|
"__wbg_call_389efe28435a9388": __wbg_call_389efe28435a9388,
|
|
3765
3833
|
"__wbg_next_418f80d8f5303233": __wbg_next_418f80d8f5303233,
|
|
3766
3834
|
"__wbg_next_3482f54c49e8af19": __wbg_next_3482f54c49e8af19,
|
|
3767
|
-
"__wbg_codePointAt_bf59dbf74d8db275": __wbg_codePointAt_bf59dbf74d8db275,
|
|
3768
3835
|
"__wbg_fromCodePoint_22365db7b7d6ac39": __wbg_fromCodePoint_22365db7b7d6ac39,
|
|
3769
|
-
"__wbg_length_68dc7c5cf1b6d349": __wbg_length_68dc7c5cf1b6d349,
|
|
3770
3836
|
"__wbg___wbindgen_in_47fa6863be6f2f25": __wbg___wbindgen_in_47fa6863be6f2f25,
|
|
3771
3837
|
"__wbg___wbindgen_throw_be289d5034ed271b": __wbg___wbindgen_throw_be289d5034ed271b,
|
|
3772
3838
|
"__wbg___wbindgen_is_null_ac34f5003991759a": __wbg___wbindgen_is_null_ac34f5003991759a,
|
|
@@ -3811,6 +3877,7 @@ const ast_get_functions = __vite__wasmModule.ast_get_functions;
|
|
|
3811
3877
|
const ast_get_literals = __vite__wasmModule.ast_get_literals;
|
|
3812
3878
|
const ast_get_subqueries = __vite__wasmModule.ast_get_subqueries;
|
|
3813
3879
|
const ast_get_table_names = __vite__wasmModule.ast_get_table_names;
|
|
3880
|
+
const ast_get_tables = __vite__wasmModule.ast_get_tables;
|
|
3814
3881
|
const ast_get_window_functions = __vite__wasmModule.ast_get_window_functions;
|
|
3815
3882
|
const ast_node_count = __vite__wasmModule.ast_node_count;
|
|
3816
3883
|
const ast_qualify_columns = __vite__wasmModule.ast_qualify_columns;
|
|
@@ -3821,6 +3888,8 @@ const ast_rename_tables = __vite__wasmModule.ast_rename_tables;
|
|
|
3821
3888
|
const ast_rename_tables_with_options = __vite__wasmModule.ast_rename_tables_with_options;
|
|
3822
3889
|
const ast_set_distinct = __vite__wasmModule.ast_set_distinct;
|
|
3823
3890
|
const ast_set_limit = __vite__wasmModule.ast_set_limit;
|
|
3891
|
+
const ast_set_offset = __vite__wasmModule.ast_set_offset;
|
|
3892
|
+
const ast_set_order_by = __vite__wasmModule.ast_set_order_by;
|
|
3824
3893
|
const diff_sql = __vite__wasmModule.diff_sql;
|
|
3825
3894
|
const format_sql = __vite__wasmModule.format_sql;
|
|
3826
3895
|
const format_sql_value = __vite__wasmModule.format_sql_value;
|
|
@@ -4013,6 +4082,7 @@ const wasm$2 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
4013
4082
|
ast_get_literals,
|
|
4014
4083
|
ast_get_subqueries,
|
|
4015
4084
|
ast_get_table_names,
|
|
4085
|
+
ast_get_tables,
|
|
4016
4086
|
ast_get_window_functions,
|
|
4017
4087
|
ast_node_count,
|
|
4018
4088
|
ast_qualify_columns,
|
|
@@ -4023,6 +4093,8 @@ const wasm$2 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
4023
4093
|
ast_rename_tables_with_options,
|
|
4024
4094
|
ast_set_distinct,
|
|
4025
4095
|
ast_set_limit,
|
|
4096
|
+
ast_set_offset,
|
|
4097
|
+
ast_set_order_by,
|
|
4026
4098
|
diff_sql,
|
|
4027
4099
|
format_sql,
|
|
4028
4100
|
format_sql_value,
|
|
@@ -4211,6 +4283,7 @@ const wasmModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty
|
|
|
4211
4283
|
ast_get_literals: ast_get_literals$1,
|
|
4212
4284
|
ast_get_subqueries: ast_get_subqueries$1,
|
|
4213
4285
|
ast_get_table_names: ast_get_table_names$1,
|
|
4286
|
+
ast_get_tables: ast_get_tables$1,
|
|
4214
4287
|
ast_get_window_functions: ast_get_window_functions$1,
|
|
4215
4288
|
ast_node_count: ast_node_count$1,
|
|
4216
4289
|
ast_qualify_columns: ast_qualify_columns$1,
|
|
@@ -4221,6 +4294,8 @@ const wasmModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty
|
|
|
4221
4294
|
ast_rename_tables_with_options: ast_rename_tables_with_options$1,
|
|
4222
4295
|
ast_set_distinct: ast_set_distinct$1,
|
|
4223
4296
|
ast_set_limit: ast_set_limit$1,
|
|
4297
|
+
ast_set_offset: ast_set_offset$1,
|
|
4298
|
+
ast_set_order_by: ast_set_order_by$1,
|
|
4224
4299
|
diff_sql: diff_sql$1,
|
|
4225
4300
|
format_sql: format_sql$1,
|
|
4226
4301
|
format_sql_value: format_sql_value$1,
|
|
@@ -4407,6 +4482,69 @@ function parseAstResult(json) {
|
|
|
4407
4482
|
const result = JSON.parse(json);
|
|
4408
4483
|
return result.success ? JSON.parse(result.ast) : null;
|
|
4409
4484
|
}
|
|
4485
|
+
function isQueryWithOuterClauses(node) {
|
|
4486
|
+
return ["select", "union", "intersect", "except"].includes(getExprType(node));
|
|
4487
|
+
}
|
|
4488
|
+
function applyLimitExpr(node, limit) {
|
|
4489
|
+
const type = getExprType(node);
|
|
4490
|
+
if (!isQueryWithOuterClauses(node)) {
|
|
4491
|
+
return node;
|
|
4492
|
+
}
|
|
4493
|
+
const data = getExprData(node);
|
|
4494
|
+
if (type === "select") {
|
|
4495
|
+
return makeExpr("select", {
|
|
4496
|
+
...data,
|
|
4497
|
+
limit: { this: limit, percent: false, comments: [] }
|
|
4498
|
+
});
|
|
4499
|
+
}
|
|
4500
|
+
return makeExpr(type, {
|
|
4501
|
+
...data,
|
|
4502
|
+
limit
|
|
4503
|
+
});
|
|
4504
|
+
}
|
|
4505
|
+
function applyOffsetExpr(node, offset) {
|
|
4506
|
+
const type = getExprType(node);
|
|
4507
|
+
if (!isQueryWithOuterClauses(node)) {
|
|
4508
|
+
return node;
|
|
4509
|
+
}
|
|
4510
|
+
const data = getExprData(node);
|
|
4511
|
+
if (type === "select") {
|
|
4512
|
+
return makeExpr("select", {
|
|
4513
|
+
...data,
|
|
4514
|
+
offset: { this: offset, rows: null }
|
|
4515
|
+
});
|
|
4516
|
+
}
|
|
4517
|
+
return makeExpr(type, {
|
|
4518
|
+
...data,
|
|
4519
|
+
offset
|
|
4520
|
+
});
|
|
4521
|
+
}
|
|
4522
|
+
function applyOrderBy(node, orderBy) {
|
|
4523
|
+
const type = getExprType(node);
|
|
4524
|
+
if (!isQueryWithOuterClauses(node)) {
|
|
4525
|
+
return node;
|
|
4526
|
+
}
|
|
4527
|
+
const expressions = orderBy.map((expression) => {
|
|
4528
|
+
if (getExprType(expression) === "ordered") {
|
|
4529
|
+
return getExprData(expression);
|
|
4530
|
+
}
|
|
4531
|
+
return {
|
|
4532
|
+
this: expression,
|
|
4533
|
+
desc: false,
|
|
4534
|
+
nulls_first: null,
|
|
4535
|
+
explicit_asc: false,
|
|
4536
|
+
with_fill: null
|
|
4537
|
+
};
|
|
4538
|
+
});
|
|
4539
|
+
return makeExpr(type, {
|
|
4540
|
+
...getExprData(node),
|
|
4541
|
+
order_by: {
|
|
4542
|
+
expressions,
|
|
4543
|
+
siblings: false,
|
|
4544
|
+
comments: []
|
|
4545
|
+
}
|
|
4546
|
+
});
|
|
4547
|
+
}
|
|
4410
4548
|
function transformValue(value, config, parent) {
|
|
4411
4549
|
if (value === null || value === void 0) return value;
|
|
4412
4550
|
if (Array.isArray(value)) {
|
|
@@ -4576,25 +4714,21 @@ function setLimit(node, limit) {
|
|
|
4576
4714
|
const result = parseAstResult(ast_set_limit$1(exprToJson$1(node), limit));
|
|
4577
4715
|
return result ?? node;
|
|
4578
4716
|
}
|
|
4579
|
-
|
|
4580
|
-
return node;
|
|
4581
|
-
}
|
|
4582
|
-
const selectData = getExprData(node);
|
|
4583
|
-
return makeExpr("select", {
|
|
4584
|
-
...selectData,
|
|
4585
|
-
limit: { this: limit }
|
|
4586
|
-
});
|
|
4717
|
+
return applyLimitExpr(node, limit);
|
|
4587
4718
|
}
|
|
4588
4719
|
function setOffset(node, offset) {
|
|
4589
|
-
if (
|
|
4590
|
-
|
|
4720
|
+
if (typeof offset === "number") {
|
|
4721
|
+
const result = parseAstResult(ast_set_offset$1(exprToJson$1(node), offset));
|
|
4722
|
+
return result ?? node;
|
|
4591
4723
|
}
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4724
|
+
return applyOffsetExpr(node, offset);
|
|
4725
|
+
}
|
|
4726
|
+
function setOrderBy(node, orderBy) {
|
|
4727
|
+
const orderByExpressions = Array.isArray(orderBy) ? orderBy : [orderBy];
|
|
4728
|
+
const result = parseAstResult(
|
|
4729
|
+
ast_set_order_by$1(exprToJson$1(node), JSON.stringify(orderByExpressions))
|
|
4730
|
+
);
|
|
4731
|
+
return result ?? applyOrderBy(node, orderByExpressions);
|
|
4598
4732
|
}
|
|
4599
4733
|
function removeLimitOffset(node) {
|
|
4600
4734
|
if (getExprType(node) !== "select") {
|
|
@@ -4762,7 +4896,8 @@ function getColumns(node) {
|
|
|
4762
4896
|
return findByType(node, "column");
|
|
4763
4897
|
}
|
|
4764
4898
|
function getTables(node) {
|
|
4765
|
-
|
|
4899
|
+
const result = JSON.parse(ast_get_tables$1(exprToJson(node)));
|
|
4900
|
+
return result.success ? JSON.parse(result.ast) : [];
|
|
4766
4901
|
}
|
|
4767
4902
|
function getIdentifiers(node) {
|
|
4768
4903
|
return findByType(node, "identifier");
|
|
@@ -4996,6 +5131,7 @@ const index$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
4996
5131
|
setDistinct,
|
|
4997
5132
|
setLimit,
|
|
4998
5133
|
setOffset,
|
|
5134
|
+
setOrderBy,
|
|
4999
5135
|
some,
|
|
5000
5136
|
transform,
|
|
5001
5137
|
walk
|
package/dist/index.node.js
CHANGED
|
@@ -1728,6 +1728,24 @@ function ast_get_table_names$1(ast_json) {
|
|
|
1728
1728
|
wasm$3.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
1729
1729
|
}
|
|
1730
1730
|
}
|
|
1731
|
+
function ast_get_tables$1(ast_json) {
|
|
1732
|
+
let deferred2_0;
|
|
1733
|
+
let deferred2_1;
|
|
1734
|
+
try {
|
|
1735
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
1736
|
+
const ptr0 = passStringToWasm0(ast_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
1737
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1738
|
+
wasm$3.ast_get_tables(retptr, ptr0, len0);
|
|
1739
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1740
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1741
|
+
deferred2_0 = r0;
|
|
1742
|
+
deferred2_1 = r1;
|
|
1743
|
+
return getStringFromWasm0(r0, r1);
|
|
1744
|
+
} finally {
|
|
1745
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
1746
|
+
wasm$3.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1731
1749
|
function ast_get_window_functions$1(ast_json) {
|
|
1732
1750
|
let deferred2_0;
|
|
1733
1751
|
let deferred2_1;
|
|
@@ -1920,6 +1938,44 @@ function ast_set_limit$1(ast_json, limit) {
|
|
|
1920
1938
|
wasm$3.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
1921
1939
|
}
|
|
1922
1940
|
}
|
|
1941
|
+
function ast_set_offset$1(ast_json, offset) {
|
|
1942
|
+
let deferred2_0;
|
|
1943
|
+
let deferred2_1;
|
|
1944
|
+
try {
|
|
1945
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
1946
|
+
const ptr0 = passStringToWasm0(ast_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
1947
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1948
|
+
wasm$3.ast_set_offset(retptr, ptr0, len0, offset);
|
|
1949
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1950
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1951
|
+
deferred2_0 = r0;
|
|
1952
|
+
deferred2_1 = r1;
|
|
1953
|
+
return getStringFromWasm0(r0, r1);
|
|
1954
|
+
} finally {
|
|
1955
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
1956
|
+
wasm$3.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
function ast_set_order_by$1(ast_json, order_by_json) {
|
|
1960
|
+
let deferred3_0;
|
|
1961
|
+
let deferred3_1;
|
|
1962
|
+
try {
|
|
1963
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
1964
|
+
const ptr0 = passStringToWasm0(ast_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
1965
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1966
|
+
const ptr1 = passStringToWasm0(order_by_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
1967
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1968
|
+
wasm$3.ast_set_order_by(retptr, ptr0, len0, ptr1, len1);
|
|
1969
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1970
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1971
|
+
deferred3_0 = r0;
|
|
1972
|
+
deferred3_1 = r1;
|
|
1973
|
+
return getStringFromWasm0(r0, r1);
|
|
1974
|
+
} finally {
|
|
1975
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
1976
|
+
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1923
1979
|
function diff_sql$1(source_sql, target_sql, dialect, delta_only, f, t) {
|
|
1924
1980
|
let deferred4_0;
|
|
1925
1981
|
let deferred4_1;
|
|
@@ -2652,10 +2708,6 @@ function __wbg_call_389efe28435a9388() {
|
|
|
2652
2708
|
return addHeapObject(ret);
|
|
2653
2709
|
}, arguments);
|
|
2654
2710
|
}
|
|
2655
|
-
function __wbg_codePointAt_bf59dbf74d8db275(arg0, arg1) {
|
|
2656
|
-
const ret = getObject(arg0).codePointAt(arg1 >>> 0);
|
|
2657
|
-
return addHeapObject(ret);
|
|
2658
|
-
}
|
|
2659
2711
|
function __wbg_done_57b39ecd9addfe81(arg0) {
|
|
2660
2712
|
const ret = getObject(arg0).done;
|
|
2661
2713
|
return ret;
|
|
@@ -2745,10 +2797,6 @@ function __wbg_length_35a7bace40f36eac(arg0) {
|
|
|
2745
2797
|
const ret = getObject(arg0).length;
|
|
2746
2798
|
return ret;
|
|
2747
2799
|
}
|
|
2748
|
-
function __wbg_length_68dc7c5cf1b6d349(arg0) {
|
|
2749
|
-
const ret = getObject(arg0).length;
|
|
2750
|
-
return ret;
|
|
2751
|
-
}
|
|
2752
2800
|
function __wbg_new_361308b2356cecd0() {
|
|
2753
2801
|
const ret = new Object();
|
|
2754
2802
|
return addHeapObject(ret);
|
|
@@ -3076,9 +3124,7 @@ const __vite__wasmModule = await __vite__initWasm({ "./polyglot_sql_wasm_bg.js":
|
|
|
3076
3124
|
"__wbg_call_389efe28435a9388": __wbg_call_389efe28435a9388,
|
|
3077
3125
|
"__wbg_next_418f80d8f5303233": __wbg_next_418f80d8f5303233,
|
|
3078
3126
|
"__wbg_next_3482f54c49e8af19": __wbg_next_3482f54c49e8af19,
|
|
3079
|
-
"__wbg_codePointAt_bf59dbf74d8db275": __wbg_codePointAt_bf59dbf74d8db275,
|
|
3080
3127
|
"__wbg_fromCodePoint_22365db7b7d6ac39": __wbg_fromCodePoint_22365db7b7d6ac39,
|
|
3081
|
-
"__wbg_length_68dc7c5cf1b6d349": __wbg_length_68dc7c5cf1b6d349,
|
|
3082
3128
|
"__wbg___wbindgen_in_47fa6863be6f2f25": __wbg___wbindgen_in_47fa6863be6f2f25,
|
|
3083
3129
|
"__wbg___wbindgen_throw_be289d5034ed271b": __wbg___wbindgen_throw_be289d5034ed271b,
|
|
3084
3130
|
"__wbg___wbindgen_is_null_ac34f5003991759a": __wbg___wbindgen_is_null_ac34f5003991759a,
|
|
@@ -3124,6 +3170,7 @@ const ast_get_functions = __vite__wasmModule.ast_get_functions;
|
|
|
3124
3170
|
const ast_get_literals = __vite__wasmModule.ast_get_literals;
|
|
3125
3171
|
const ast_get_subqueries = __vite__wasmModule.ast_get_subqueries;
|
|
3126
3172
|
const ast_get_table_names = __vite__wasmModule.ast_get_table_names;
|
|
3173
|
+
const ast_get_tables = __vite__wasmModule.ast_get_tables;
|
|
3127
3174
|
const ast_get_window_functions = __vite__wasmModule.ast_get_window_functions;
|
|
3128
3175
|
const ast_node_count = __vite__wasmModule.ast_node_count;
|
|
3129
3176
|
const ast_qualify_columns = __vite__wasmModule.ast_qualify_columns;
|
|
@@ -3134,6 +3181,8 @@ const ast_rename_tables = __vite__wasmModule.ast_rename_tables;
|
|
|
3134
3181
|
const ast_rename_tables_with_options = __vite__wasmModule.ast_rename_tables_with_options;
|
|
3135
3182
|
const ast_set_distinct = __vite__wasmModule.ast_set_distinct;
|
|
3136
3183
|
const ast_set_limit = __vite__wasmModule.ast_set_limit;
|
|
3184
|
+
const ast_set_offset = __vite__wasmModule.ast_set_offset;
|
|
3185
|
+
const ast_set_order_by = __vite__wasmModule.ast_set_order_by;
|
|
3137
3186
|
const diff_sql = __vite__wasmModule.diff_sql;
|
|
3138
3187
|
const format_sql = __vite__wasmModule.format_sql;
|
|
3139
3188
|
const format_sql_value = __vite__wasmModule.format_sql_value;
|
|
@@ -3325,6 +3374,7 @@ const wasm$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
|
|
|
3325
3374
|
ast_get_literals,
|
|
3326
3375
|
ast_get_subqueries,
|
|
3327
3376
|
ast_get_table_names,
|
|
3377
|
+
ast_get_tables,
|
|
3328
3378
|
ast_get_window_functions,
|
|
3329
3379
|
ast_node_count,
|
|
3330
3380
|
ast_qualify_columns,
|
|
@@ -3335,6 +3385,8 @@ const wasm$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
|
|
|
3335
3385
|
ast_rename_tables_with_options,
|
|
3336
3386
|
ast_set_distinct,
|
|
3337
3387
|
ast_set_limit,
|
|
3388
|
+
ast_set_offset,
|
|
3389
|
+
ast_set_order_by,
|
|
3338
3390
|
diff_sql,
|
|
3339
3391
|
format_sql,
|
|
3340
3392
|
format_sql_value,
|
|
@@ -3519,6 +3571,7 @@ const wasmModule = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
3519
3571
|
ast_get_literals: ast_get_literals$1,
|
|
3520
3572
|
ast_get_subqueries: ast_get_subqueries$1,
|
|
3521
3573
|
ast_get_table_names: ast_get_table_names$1,
|
|
3574
|
+
ast_get_tables: ast_get_tables$1,
|
|
3522
3575
|
ast_get_window_functions: ast_get_window_functions$1,
|
|
3523
3576
|
ast_node_count: ast_node_count$1,
|
|
3524
3577
|
ast_qualify_columns: ast_qualify_columns$1,
|
|
@@ -3529,6 +3582,8 @@ const wasmModule = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
3529
3582
|
ast_rename_tables_with_options: ast_rename_tables_with_options$1,
|
|
3530
3583
|
ast_set_distinct: ast_set_distinct$1,
|
|
3531
3584
|
ast_set_limit: ast_set_limit$1,
|
|
3585
|
+
ast_set_offset: ast_set_offset$1,
|
|
3586
|
+
ast_set_order_by: ast_set_order_by$1,
|
|
3532
3587
|
diff_sql: diff_sql$1,
|
|
3533
3588
|
format_sql: format_sql$1,
|
|
3534
3589
|
format_sql_value: format_sql_value$1,
|
|
@@ -3712,6 +3767,69 @@ function parseAstResult(json) {
|
|
|
3712
3767
|
const result = JSON.parse(json);
|
|
3713
3768
|
return result.success ? JSON.parse(result.ast) : null;
|
|
3714
3769
|
}
|
|
3770
|
+
function isQueryWithOuterClauses(node) {
|
|
3771
|
+
return ["select", "union", "intersect", "except"].includes(getExprType(node));
|
|
3772
|
+
}
|
|
3773
|
+
function applyLimitExpr(node, limit) {
|
|
3774
|
+
const type = getExprType(node);
|
|
3775
|
+
if (!isQueryWithOuterClauses(node)) {
|
|
3776
|
+
return node;
|
|
3777
|
+
}
|
|
3778
|
+
const data = getExprData(node);
|
|
3779
|
+
if (type === "select") {
|
|
3780
|
+
return makeExpr("select", {
|
|
3781
|
+
...data,
|
|
3782
|
+
limit: { this: limit, percent: false, comments: [] }
|
|
3783
|
+
});
|
|
3784
|
+
}
|
|
3785
|
+
return makeExpr(type, {
|
|
3786
|
+
...data,
|
|
3787
|
+
limit
|
|
3788
|
+
});
|
|
3789
|
+
}
|
|
3790
|
+
function applyOffsetExpr(node, offset) {
|
|
3791
|
+
const type = getExprType(node);
|
|
3792
|
+
if (!isQueryWithOuterClauses(node)) {
|
|
3793
|
+
return node;
|
|
3794
|
+
}
|
|
3795
|
+
const data = getExprData(node);
|
|
3796
|
+
if (type === "select") {
|
|
3797
|
+
return makeExpr("select", {
|
|
3798
|
+
...data,
|
|
3799
|
+
offset: { this: offset, rows: null }
|
|
3800
|
+
});
|
|
3801
|
+
}
|
|
3802
|
+
return makeExpr(type, {
|
|
3803
|
+
...data,
|
|
3804
|
+
offset
|
|
3805
|
+
});
|
|
3806
|
+
}
|
|
3807
|
+
function applyOrderBy(node, orderBy) {
|
|
3808
|
+
const type = getExprType(node);
|
|
3809
|
+
if (!isQueryWithOuterClauses(node)) {
|
|
3810
|
+
return node;
|
|
3811
|
+
}
|
|
3812
|
+
const expressions = orderBy.map((expression) => {
|
|
3813
|
+
if (getExprType(expression) === "ordered") {
|
|
3814
|
+
return getExprData(expression);
|
|
3815
|
+
}
|
|
3816
|
+
return {
|
|
3817
|
+
this: expression,
|
|
3818
|
+
desc: false,
|
|
3819
|
+
nulls_first: null,
|
|
3820
|
+
explicit_asc: false,
|
|
3821
|
+
with_fill: null
|
|
3822
|
+
};
|
|
3823
|
+
});
|
|
3824
|
+
return makeExpr(type, {
|
|
3825
|
+
...getExprData(node),
|
|
3826
|
+
order_by: {
|
|
3827
|
+
expressions,
|
|
3828
|
+
siblings: false,
|
|
3829
|
+
comments: []
|
|
3830
|
+
}
|
|
3831
|
+
});
|
|
3832
|
+
}
|
|
3715
3833
|
function transformValue(value, config, parent) {
|
|
3716
3834
|
if (value === null || value === void 0) return value;
|
|
3717
3835
|
if (Array.isArray(value)) {
|
|
@@ -3881,25 +3999,21 @@ function setLimit(node, limit) {
|
|
|
3881
3999
|
const result = parseAstResult(ast_set_limit$1(exprToJson$1(node), limit));
|
|
3882
4000
|
return result ?? node;
|
|
3883
4001
|
}
|
|
3884
|
-
|
|
3885
|
-
return node;
|
|
3886
|
-
}
|
|
3887
|
-
const selectData = getExprData(node);
|
|
3888
|
-
return makeExpr("select", {
|
|
3889
|
-
...selectData,
|
|
3890
|
-
limit: { this: limit }
|
|
3891
|
-
});
|
|
4002
|
+
return applyLimitExpr(node, limit);
|
|
3892
4003
|
}
|
|
3893
4004
|
function setOffset(node, offset) {
|
|
3894
|
-
if (
|
|
3895
|
-
|
|
4005
|
+
if (typeof offset === "number") {
|
|
4006
|
+
const result = parseAstResult(ast_set_offset$1(exprToJson$1(node), offset));
|
|
4007
|
+
return result ?? node;
|
|
3896
4008
|
}
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
4009
|
+
return applyOffsetExpr(node, offset);
|
|
4010
|
+
}
|
|
4011
|
+
function setOrderBy(node, orderBy) {
|
|
4012
|
+
const orderByExpressions = Array.isArray(orderBy) ? orderBy : [orderBy];
|
|
4013
|
+
const result = parseAstResult(
|
|
4014
|
+
ast_set_order_by$1(exprToJson$1(node), JSON.stringify(orderByExpressions))
|
|
4015
|
+
);
|
|
4016
|
+
return result ?? applyOrderBy(node, orderByExpressions);
|
|
3903
4017
|
}
|
|
3904
4018
|
function removeLimitOffset(node) {
|
|
3905
4019
|
if (getExprType(node) !== "select") {
|
|
@@ -4066,7 +4180,8 @@ function getColumns(node) {
|
|
|
4066
4180
|
return findByType(node, "column");
|
|
4067
4181
|
}
|
|
4068
4182
|
function getTables(node) {
|
|
4069
|
-
|
|
4183
|
+
const result = JSON.parse(ast_get_tables$1(exprToJson(node)));
|
|
4184
|
+
return result.success ? JSON.parse(result.ast) : [];
|
|
4070
4185
|
}
|
|
4071
4186
|
function getIdentifiers(node) {
|
|
4072
4187
|
return findByType(node, "identifier");
|
|
@@ -4299,6 +4414,7 @@ const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
4299
4414
|
setDistinct,
|
|
4300
4415
|
setLimit,
|
|
4301
4416
|
setOffset,
|
|
4417
|
+
setOrderBy,
|
|
4302
4418
|
some,
|
|
4303
4419
|
transform,
|
|
4304
4420
|
walk
|