@polyglot-sql/sdk 0.3.9 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/polyglot.esm.js +1388 -1350
- package/dist/index.cjs +101 -34
- package/dist/index.d.cts +40 -9
- package/dist/index.d.ts +40 -9
- package/dist/index.js +112 -32
- package/dist/polyglot_sql_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -144,31 +144,34 @@ class WasmCaseBuilder {
|
|
|
144
144
|
return this;
|
|
145
145
|
}
|
|
146
146
|
/**
|
|
147
|
-
* Generate SQL string
|
|
147
|
+
* Generate SQL string for the given dialect.
|
|
148
|
+
* @param {string} dialect
|
|
148
149
|
* @returns {string}
|
|
149
150
|
*/
|
|
150
|
-
to_sql() {
|
|
151
|
-
let
|
|
152
|
-
let
|
|
151
|
+
to_sql(dialect) {
|
|
152
|
+
let deferred3_0;
|
|
153
|
+
let deferred3_1;
|
|
153
154
|
try {
|
|
154
155
|
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
155
|
-
wasm$3.
|
|
156
|
+
const ptr0 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
157
|
+
const len0 = WASM_VECTOR_LEN;
|
|
158
|
+
wasm$3.wasmcasebuilder_to_sql(retptr, this.__wbg_ptr, ptr0, len0);
|
|
156
159
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
157
160
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
158
161
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
159
162
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
160
|
-
var
|
|
161
|
-
var
|
|
163
|
+
var ptr2 = r0;
|
|
164
|
+
var len2 = r1;
|
|
162
165
|
if (r3) {
|
|
163
|
-
|
|
166
|
+
ptr2 = 0; len2 = 0;
|
|
164
167
|
throw takeObject(r2);
|
|
165
168
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return getStringFromWasm0(
|
|
169
|
+
deferred3_0 = ptr2;
|
|
170
|
+
deferred3_1 = len2;
|
|
171
|
+
return getStringFromWasm0(ptr2, len2);
|
|
169
172
|
} finally {
|
|
170
173
|
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
171
|
-
wasm$3.__wbindgen_export4(
|
|
174
|
+
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
172
175
|
}
|
|
173
176
|
}
|
|
174
177
|
/**
|
|
@@ -557,31 +560,34 @@ class WasmExpr {
|
|
|
557
560
|
}
|
|
558
561
|
}
|
|
559
562
|
/**
|
|
560
|
-
* Generate SQL string
|
|
563
|
+
* Generate SQL string for the given dialect.
|
|
564
|
+
* @param {string} dialect
|
|
561
565
|
* @returns {string}
|
|
562
566
|
*/
|
|
563
|
-
to_sql() {
|
|
564
|
-
let
|
|
565
|
-
let
|
|
567
|
+
to_sql(dialect) {
|
|
568
|
+
let deferred3_0;
|
|
569
|
+
let deferred3_1;
|
|
566
570
|
try {
|
|
567
571
|
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
568
|
-
wasm$3.
|
|
572
|
+
const ptr0 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
573
|
+
const len0 = WASM_VECTOR_LEN;
|
|
574
|
+
wasm$3.wasmexpr_to_sql(retptr, this.__wbg_ptr, ptr0, len0);
|
|
569
575
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
570
576
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
571
577
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
572
578
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
573
|
-
var
|
|
574
|
-
var
|
|
579
|
+
var ptr2 = r0;
|
|
580
|
+
var len2 = r1;
|
|
575
581
|
if (r3) {
|
|
576
|
-
|
|
582
|
+
ptr2 = 0; len2 = 0;
|
|
577
583
|
throw takeObject(r2);
|
|
578
584
|
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
return getStringFromWasm0(
|
|
585
|
+
deferred3_0 = ptr2;
|
|
586
|
+
deferred3_1 = len2;
|
|
587
|
+
return getStringFromWasm0(ptr2, len2);
|
|
582
588
|
} finally {
|
|
583
589
|
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
584
|
-
wasm$3.__wbindgen_export4(
|
|
590
|
+
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
585
591
|
}
|
|
586
592
|
}
|
|
587
593
|
/**
|
|
@@ -1894,6 +1900,33 @@ function ast_qualify_columns$1(ast_json, table_name) {
|
|
|
1894
1900
|
}
|
|
1895
1901
|
}
|
|
1896
1902
|
|
|
1903
|
+
/**
|
|
1904
|
+
* Qualify table references in an AST.
|
|
1905
|
+
* @param {string} ast_json
|
|
1906
|
+
* @param {string} options_json
|
|
1907
|
+
* @returns {string}
|
|
1908
|
+
*/
|
|
1909
|
+
function ast_qualify_tables$1(ast_json, options_json) {
|
|
1910
|
+
let deferred3_0;
|
|
1911
|
+
let deferred3_1;
|
|
1912
|
+
try {
|
|
1913
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
1914
|
+
const ptr0 = passStringToWasm0(ast_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
1915
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1916
|
+
const ptr1 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
1917
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1918
|
+
wasm$3.ast_qualify_tables(retptr, ptr0, len0, ptr1, len1);
|
|
1919
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1920
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1921
|
+
deferred3_0 = r0;
|
|
1922
|
+
deferred3_1 = r1;
|
|
1923
|
+
return getStringFromWasm0(r0, r1);
|
|
1924
|
+
} finally {
|
|
1925
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
1926
|
+
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1897
1930
|
/**
|
|
1898
1931
|
* Remove the WHERE clause from a SELECT AST.
|
|
1899
1932
|
* @param {string} ast_json
|
|
@@ -1972,6 +2005,36 @@ function ast_rename_tables$1(ast_json, mapping_json) {
|
|
|
1972
2005
|
}
|
|
1973
2006
|
}
|
|
1974
2007
|
|
|
2008
|
+
/**
|
|
2009
|
+
* Rename tables in an AST with table-renaming options.
|
|
2010
|
+
* @param {string} ast_json
|
|
2011
|
+
* @param {string} mapping_json
|
|
2012
|
+
* @param {string} options_json
|
|
2013
|
+
* @returns {string}
|
|
2014
|
+
*/
|
|
2015
|
+
function ast_rename_tables_with_options$1(ast_json, mapping_json, options_json) {
|
|
2016
|
+
let deferred4_0;
|
|
2017
|
+
let deferred4_1;
|
|
2018
|
+
try {
|
|
2019
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
2020
|
+
const ptr0 = passStringToWasm0(ast_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2021
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2022
|
+
const ptr1 = passStringToWasm0(mapping_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2023
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2024
|
+
const ptr2 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2025
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2026
|
+
wasm$3.ast_rename_tables_with_options(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
2027
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2028
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2029
|
+
deferred4_0 = r0;
|
|
2030
|
+
deferred4_1 = r1;
|
|
2031
|
+
return getStringFromWasm0(r0, r1);
|
|
2032
|
+
} finally {
|
|
2033
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
2034
|
+
wasm$3.__wbindgen_export4(deferred4_0, deferred4_1, 1);
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
|
|
1975
2038
|
/**
|
|
1976
2039
|
* Set DISTINCT on a SELECT AST.
|
|
1977
2040
|
* @param {string} ast_json
|
|
@@ -3495,9 +3558,11 @@ const ast_get_table_names = __vite__wasmModule.ast_get_table_names;
|
|
|
3495
3558
|
const ast_get_window_functions = __vite__wasmModule.ast_get_window_functions;
|
|
3496
3559
|
const ast_node_count = __vite__wasmModule.ast_node_count;
|
|
3497
3560
|
const ast_qualify_columns = __vite__wasmModule.ast_qualify_columns;
|
|
3561
|
+
const ast_qualify_tables = __vite__wasmModule.ast_qualify_tables;
|
|
3498
3562
|
const ast_remove_where = __vite__wasmModule.ast_remove_where;
|
|
3499
3563
|
const ast_rename_columns = __vite__wasmModule.ast_rename_columns;
|
|
3500
3564
|
const ast_rename_tables = __vite__wasmModule.ast_rename_tables;
|
|
3565
|
+
const ast_rename_tables_with_options = __vite__wasmModule.ast_rename_tables_with_options;
|
|
3501
3566
|
const ast_set_distinct = __vite__wasmModule.ast_set_distinct;
|
|
3502
3567
|
const ast_set_limit = __vite__wasmModule.ast_set_limit;
|
|
3503
3568
|
const diff_sql = __vite__wasmModule.diff_sql;
|
|
@@ -3684,9 +3749,11 @@ const wasm$2 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
3684
3749
|
ast_get_window_functions,
|
|
3685
3750
|
ast_node_count,
|
|
3686
3751
|
ast_qualify_columns,
|
|
3752
|
+
ast_qualify_tables,
|
|
3687
3753
|
ast_remove_where,
|
|
3688
3754
|
ast_rename_columns,
|
|
3689
3755
|
ast_rename_tables,
|
|
3756
|
+
ast_rename_tables_with_options,
|
|
3690
3757
|
ast_set_distinct,
|
|
3691
3758
|
ast_set_limit,
|
|
3692
3759
|
diff_sql,
|
|
@@ -3869,9 +3936,11 @@ const wasmModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty
|
|
|
3869
3936
|
ast_get_window_functions: ast_get_window_functions$1,
|
|
3870
3937
|
ast_node_count: ast_node_count$1,
|
|
3871
3938
|
ast_qualify_columns: ast_qualify_columns$1,
|
|
3939
|
+
ast_qualify_tables: ast_qualify_tables$1,
|
|
3872
3940
|
ast_remove_where: ast_remove_where$1,
|
|
3873
3941
|
ast_rename_columns: ast_rename_columns$1,
|
|
3874
3942
|
ast_rename_tables: ast_rename_tables$1,
|
|
3943
|
+
ast_rename_tables_with_options: ast_rename_tables_with_options$1,
|
|
3875
3944
|
ast_set_distinct: ast_set_distinct$1,
|
|
3876
3945
|
ast_set_limit: ast_set_limit$1,
|
|
3877
3946
|
diff_sql: diff_sql$1,
|
|
@@ -4163,9 +4232,13 @@ function renameColumns(node, mapping) {
|
|
|
4163
4232
|
);
|
|
4164
4233
|
return result ?? node;
|
|
4165
4234
|
}
|
|
4166
|
-
function renameTables(node, mapping) {
|
|
4235
|
+
function renameTables(node, mapping, options) {
|
|
4167
4236
|
const result = parseAstResult(
|
|
4168
|
-
|
|
4237
|
+
options ? ast_rename_tables_with_options$1(
|
|
4238
|
+
exprToJson$1(node),
|
|
4239
|
+
JSON.stringify(mapping),
|
|
4240
|
+
JSON.stringify(options)
|
|
4241
|
+
) : ast_rename_tables$1(exprToJson$1(node), JSON.stringify(mapping))
|
|
4169
4242
|
);
|
|
4170
4243
|
return result ?? node;
|
|
4171
4244
|
}
|
|
@@ -4175,6 +4248,12 @@ function qualifyColumns(node, tableName) {
|
|
|
4175
4248
|
);
|
|
4176
4249
|
return result ?? node;
|
|
4177
4250
|
}
|
|
4251
|
+
function qualifyTables(node, options = {}) {
|
|
4252
|
+
const result = parseAstResult(
|
|
4253
|
+
ast_qualify_tables$1(exprToJson$1(node), JSON.stringify(options))
|
|
4254
|
+
);
|
|
4255
|
+
return result ?? node;
|
|
4256
|
+
}
|
|
4178
4257
|
function addWhere(node, condition, operator = "and") {
|
|
4179
4258
|
const result = parseAstResult(
|
|
4180
4259
|
ast_add_where$1(exprToJson$1(node), exprToJson$1(condition), operator === "or")
|
|
@@ -4618,6 +4697,7 @@ const index$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
4618
4697
|
makeExpr,
|
|
4619
4698
|
nodeCount,
|
|
4620
4699
|
qualifyColumns,
|
|
4700
|
+
qualifyTables,
|
|
4621
4701
|
remove,
|
|
4622
4702
|
removeLimitOffset,
|
|
4623
4703
|
removeSelectColumns,
|
|
@@ -4757,9 +4837,9 @@ class Expr {
|
|
|
4757
4837
|
return new Expr(this._w.desc());
|
|
4758
4838
|
}
|
|
4759
4839
|
// -- Output --
|
|
4760
|
-
/** Generate SQL string
|
|
4761
|
-
toSql() {
|
|
4762
|
-
return this._w.to_sql();
|
|
4840
|
+
/** Generate SQL string. Defaults to generic dialect. */
|
|
4841
|
+
toSql(dialect = "generic") {
|
|
4842
|
+
return this._w.to_sql(dialect);
|
|
4763
4843
|
}
|
|
4764
4844
|
/** Return the expression AST as a plain JS object. */
|
|
4765
4845
|
toJSON() {
|
|
@@ -5295,9 +5375,9 @@ class CaseBuilder {
|
|
|
5295
5375
|
build() {
|
|
5296
5376
|
return new Expr(this._w.build_expr());
|
|
5297
5377
|
}
|
|
5298
|
-
/** Generate SQL string
|
|
5299
|
-
toSql() {
|
|
5300
|
-
return this._w.to_sql();
|
|
5378
|
+
/** Generate SQL string. Defaults to generic dialect. */
|
|
5379
|
+
toSql(dialect = "generic") {
|
|
5380
|
+
return this._w.to_sql(dialect);
|
|
5301
5381
|
}
|
|
5302
5382
|
}
|
|
5303
5383
|
function caseWhen() {
|
|
Binary file
|