@polyglot-sql/sdk 0.5.3 → 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 +8 -2
- package/dist/cdn/polyglot.esm.js +1746 -1673
- package/dist/index.cjs +146 -27
- package/dist/index.d.cts +20 -1
- package/dist/index.d.ts +20 -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.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
|
package/dist/manual.js
CHANGED
|
@@ -1824,6 +1824,30 @@ function ast_get_table_names(ast_json) {
|
|
|
1824
1824
|
}
|
|
1825
1825
|
}
|
|
1826
1826
|
|
|
1827
|
+
/**
|
|
1828
|
+
* Get all table nodes from an AST (as JSON string).
|
|
1829
|
+
* @param {string} ast_json
|
|
1830
|
+
* @returns {string}
|
|
1831
|
+
*/
|
|
1832
|
+
function ast_get_tables(ast_json) {
|
|
1833
|
+
let deferred2_0;
|
|
1834
|
+
let deferred2_1;
|
|
1835
|
+
try {
|
|
1836
|
+
const retptr = wasm$2.__wbindgen_add_to_stack_pointer(-16);
|
|
1837
|
+
const ptr0 = passStringToWasm0(ast_json, wasm$2.__wbindgen_export, wasm$2.__wbindgen_export2);
|
|
1838
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1839
|
+
wasm$2.ast_get_tables(retptr, ptr0, len0);
|
|
1840
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1841
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1842
|
+
deferred2_0 = r0;
|
|
1843
|
+
deferred2_1 = r1;
|
|
1844
|
+
return getStringFromWasm0(r0, r1);
|
|
1845
|
+
} finally {
|
|
1846
|
+
wasm$2.__wbindgen_add_to_stack_pointer(16);
|
|
1847
|
+
wasm$2.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1827
1851
|
/**
|
|
1828
1852
|
* Get all window functions from an AST (as JSON string).
|
|
1829
1853
|
* @param {string} ast_json
|
|
@@ -2084,6 +2108,58 @@ function ast_set_limit(ast_json, limit) {
|
|
|
2084
2108
|
}
|
|
2085
2109
|
}
|
|
2086
2110
|
|
|
2111
|
+
/**
|
|
2112
|
+
* Set the OFFSET on a SELECT or set-operation AST.
|
|
2113
|
+
* @param {string} ast_json
|
|
2114
|
+
* @param {number} offset
|
|
2115
|
+
* @returns {string}
|
|
2116
|
+
*/
|
|
2117
|
+
function ast_set_offset(ast_json, offset) {
|
|
2118
|
+
let deferred2_0;
|
|
2119
|
+
let deferred2_1;
|
|
2120
|
+
try {
|
|
2121
|
+
const retptr = wasm$2.__wbindgen_add_to_stack_pointer(-16);
|
|
2122
|
+
const ptr0 = passStringToWasm0(ast_json, wasm$2.__wbindgen_export, wasm$2.__wbindgen_export2);
|
|
2123
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2124
|
+
wasm$2.ast_set_offset(retptr, ptr0, len0, offset);
|
|
2125
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2126
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2127
|
+
deferred2_0 = r0;
|
|
2128
|
+
deferred2_1 = r1;
|
|
2129
|
+
return getStringFromWasm0(r0, r1);
|
|
2130
|
+
} finally {
|
|
2131
|
+
wasm$2.__wbindgen_add_to_stack_pointer(16);
|
|
2132
|
+
wasm$2.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
|
|
2136
|
+
/**
|
|
2137
|
+
* Set the ORDER BY clause on a SELECT or set-operation AST.
|
|
2138
|
+
* @param {string} ast_json
|
|
2139
|
+
* @param {string} order_by_json
|
|
2140
|
+
* @returns {string}
|
|
2141
|
+
*/
|
|
2142
|
+
function ast_set_order_by(ast_json, order_by_json) {
|
|
2143
|
+
let deferred3_0;
|
|
2144
|
+
let deferred3_1;
|
|
2145
|
+
try {
|
|
2146
|
+
const retptr = wasm$2.__wbindgen_add_to_stack_pointer(-16);
|
|
2147
|
+
const ptr0 = passStringToWasm0(ast_json, wasm$2.__wbindgen_export, wasm$2.__wbindgen_export2);
|
|
2148
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2149
|
+
const ptr1 = passStringToWasm0(order_by_json, wasm$2.__wbindgen_export, wasm$2.__wbindgen_export2);
|
|
2150
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2151
|
+
wasm$2.ast_set_order_by(retptr, ptr0, len0, ptr1, len1);
|
|
2152
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2153
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2154
|
+
deferred3_0 = r0;
|
|
2155
|
+
deferred3_1 = r1;
|
|
2156
|
+
return getStringFromWasm0(r0, r1);
|
|
2157
|
+
} finally {
|
|
2158
|
+
wasm$2.__wbindgen_add_to_stack_pointer(16);
|
|
2159
|
+
wasm$2.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2087
2163
|
/**
|
|
2088
2164
|
* Diff two SQL statements and return edit operations.
|
|
2089
2165
|
*
|
|
@@ -3271,10 +3347,6 @@ function __wbg_get_imports() {
|
|
|
3271
3347
|
const ret = getObject(arg0).call(getObject(arg1));
|
|
3272
3348
|
return addHeapObject(ret);
|
|
3273
3349
|
}, arguments); },
|
|
3274
|
-
__wbg_codePointAt_bf59dbf74d8db275: function(arg0, arg1) {
|
|
3275
|
-
const ret = getObject(arg0).codePointAt(arg1 >>> 0);
|
|
3276
|
-
return addHeapObject(ret);
|
|
3277
|
-
},
|
|
3278
3350
|
__wbg_done_57b39ecd9addfe81: function(arg0) {
|
|
3279
3351
|
const ret = getObject(arg0).done;
|
|
3280
3352
|
return ret;
|
|
@@ -3360,10 +3432,6 @@ function __wbg_get_imports() {
|
|
|
3360
3432
|
const ret = getObject(arg0).length;
|
|
3361
3433
|
return ret;
|
|
3362
3434
|
},
|
|
3363
|
-
__wbg_length_68dc7c5cf1b6d349: function(arg0) {
|
|
3364
|
-
const ret = getObject(arg0).length;
|
|
3365
|
-
return ret;
|
|
3366
|
-
},
|
|
3367
3435
|
__wbg_new_361308b2356cecd0: function() {
|
|
3368
3436
|
const ret = new Object();
|
|
3369
3437
|
return addHeapObject(ret);
|
|
@@ -3827,6 +3895,7 @@ const wasmModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty
|
|
|
3827
3895
|
ast_get_literals,
|
|
3828
3896
|
ast_get_subqueries,
|
|
3829
3897
|
ast_get_table_names,
|
|
3898
|
+
ast_get_tables,
|
|
3830
3899
|
ast_get_window_functions,
|
|
3831
3900
|
ast_node_count,
|
|
3832
3901
|
ast_qualify_columns,
|
|
@@ -3837,6 +3906,8 @@ const wasmModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty
|
|
|
3837
3906
|
ast_rename_tables_with_options,
|
|
3838
3907
|
ast_set_distinct,
|
|
3839
3908
|
ast_set_limit,
|
|
3909
|
+
ast_set_offset,
|
|
3910
|
+
ast_set_order_by,
|
|
3840
3911
|
diff_sql,
|
|
3841
3912
|
format_sql,
|
|
3842
3913
|
format_sql_value,
|
|
@@ -4026,6 +4097,69 @@ function parseAstResult(json) {
|
|
|
4026
4097
|
const result = JSON.parse(json);
|
|
4027
4098
|
return result.success ? JSON.parse(result.ast) : null;
|
|
4028
4099
|
}
|
|
4100
|
+
function isQueryWithOuterClauses(node) {
|
|
4101
|
+
return ["select", "union", "intersect", "except"].includes(getExprType(node));
|
|
4102
|
+
}
|
|
4103
|
+
function applyLimitExpr(node, limit) {
|
|
4104
|
+
const type = getExprType(node);
|
|
4105
|
+
if (!isQueryWithOuterClauses(node)) {
|
|
4106
|
+
return node;
|
|
4107
|
+
}
|
|
4108
|
+
const data = getExprData(node);
|
|
4109
|
+
if (type === "select") {
|
|
4110
|
+
return makeExpr("select", {
|
|
4111
|
+
...data,
|
|
4112
|
+
limit: { this: limit, percent: false, comments: [] }
|
|
4113
|
+
});
|
|
4114
|
+
}
|
|
4115
|
+
return makeExpr(type, {
|
|
4116
|
+
...data,
|
|
4117
|
+
limit
|
|
4118
|
+
});
|
|
4119
|
+
}
|
|
4120
|
+
function applyOffsetExpr(node, offset) {
|
|
4121
|
+
const type = getExprType(node);
|
|
4122
|
+
if (!isQueryWithOuterClauses(node)) {
|
|
4123
|
+
return node;
|
|
4124
|
+
}
|
|
4125
|
+
const data = getExprData(node);
|
|
4126
|
+
if (type === "select") {
|
|
4127
|
+
return makeExpr("select", {
|
|
4128
|
+
...data,
|
|
4129
|
+
offset: { this: offset, rows: null }
|
|
4130
|
+
});
|
|
4131
|
+
}
|
|
4132
|
+
return makeExpr(type, {
|
|
4133
|
+
...data,
|
|
4134
|
+
offset
|
|
4135
|
+
});
|
|
4136
|
+
}
|
|
4137
|
+
function applyOrderBy(node, orderBy) {
|
|
4138
|
+
const type = getExprType(node);
|
|
4139
|
+
if (!isQueryWithOuterClauses(node)) {
|
|
4140
|
+
return node;
|
|
4141
|
+
}
|
|
4142
|
+
const expressions = orderBy.map((expression) => {
|
|
4143
|
+
if (getExprType(expression) === "ordered") {
|
|
4144
|
+
return getExprData(expression);
|
|
4145
|
+
}
|
|
4146
|
+
return {
|
|
4147
|
+
this: expression,
|
|
4148
|
+
desc: false,
|
|
4149
|
+
nulls_first: null,
|
|
4150
|
+
explicit_asc: false,
|
|
4151
|
+
with_fill: null
|
|
4152
|
+
};
|
|
4153
|
+
});
|
|
4154
|
+
return makeExpr(type, {
|
|
4155
|
+
...getExprData(node),
|
|
4156
|
+
order_by: {
|
|
4157
|
+
expressions,
|
|
4158
|
+
siblings: false,
|
|
4159
|
+
comments: []
|
|
4160
|
+
}
|
|
4161
|
+
});
|
|
4162
|
+
}
|
|
4029
4163
|
function transformValue(value, config, parent) {
|
|
4030
4164
|
if (value === null || value === void 0) return value;
|
|
4031
4165
|
if (Array.isArray(value)) {
|
|
@@ -4195,25 +4329,21 @@ function setLimit(node, limit) {
|
|
|
4195
4329
|
const result = parseAstResult(ast_set_limit(exprToJson$1(node), limit));
|
|
4196
4330
|
return result ?? node;
|
|
4197
4331
|
}
|
|
4198
|
-
|
|
4199
|
-
return node;
|
|
4200
|
-
}
|
|
4201
|
-
const selectData = getExprData(node);
|
|
4202
|
-
return makeExpr("select", {
|
|
4203
|
-
...selectData,
|
|
4204
|
-
limit: { this: limit }
|
|
4205
|
-
});
|
|
4332
|
+
return applyLimitExpr(node, limit);
|
|
4206
4333
|
}
|
|
4207
4334
|
function setOffset(node, offset) {
|
|
4208
|
-
if (
|
|
4209
|
-
|
|
4335
|
+
if (typeof offset === "number") {
|
|
4336
|
+
const result = parseAstResult(ast_set_offset(exprToJson$1(node), offset));
|
|
4337
|
+
return result ?? node;
|
|
4210
4338
|
}
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4339
|
+
return applyOffsetExpr(node, offset);
|
|
4340
|
+
}
|
|
4341
|
+
function setOrderBy(node, orderBy) {
|
|
4342
|
+
const orderByExpressions = Array.isArray(orderBy) ? orderBy : [orderBy];
|
|
4343
|
+
const result = parseAstResult(
|
|
4344
|
+
ast_set_order_by(exprToJson$1(node), JSON.stringify(orderByExpressions))
|
|
4345
|
+
);
|
|
4346
|
+
return result ?? applyOrderBy(node, orderByExpressions);
|
|
4217
4347
|
}
|
|
4218
4348
|
function removeLimitOffset(node) {
|
|
4219
4349
|
if (getExprType(node) !== "select") {
|
|
@@ -4381,7 +4511,8 @@ function getColumns(node) {
|
|
|
4381
4511
|
return findByType(node, "column");
|
|
4382
4512
|
}
|
|
4383
4513
|
function getTables(node) {
|
|
4384
|
-
|
|
4514
|
+
const result = JSON.parse(ast_get_tables(exprToJson(node)));
|
|
4515
|
+
return result.success ? JSON.parse(result.ast) : [];
|
|
4385
4516
|
}
|
|
4386
4517
|
function getIdentifiers(node) {
|
|
4387
4518
|
return findByType(node, "identifier");
|
|
@@ -4615,6 +4746,7 @@ const index = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
4615
4746
|
setDistinct,
|
|
4616
4747
|
setLimit,
|
|
4617
4748
|
setOffset,
|
|
4749
|
+
setOrderBy,
|
|
4618
4750
|
some,
|
|
4619
4751
|
transform,
|
|
4620
4752
|
walk
|
package/dist/polyglot_sql.wasm
CHANGED
|
Binary file
|