sql-typechecker 0.0.43 → 0.0.45
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/out/cli.js +10 -12
- package/out/cli.js.map +3 -3
- package/package.json +2 -2
package/out/cli.js
CHANGED
|
@@ -6387,7 +6387,7 @@ var require_nearley = __commonJS((exports2, module2) => {
|
|
|
6387
6387
|
});
|
|
6388
6388
|
});
|
|
6389
6389
|
|
|
6390
|
-
// node_modules/pgsql-ast-parser/lib/index.js
|
|
6390
|
+
// node_modules/trader-pgsql-ast-parser/lib/index.js
|
|
6391
6391
|
var require_lib = __commonJS((exports2) => {
|
|
6392
6392
|
(function(e, a) {
|
|
6393
6393
|
for (var i in a)
|
|
@@ -235932,13 +235932,13 @@ ${text}`;
|
|
|
235932
235932
|
var fs = __toModule(require("fs/promises"));
|
|
235933
235933
|
var import_lodash2 = __toModule(require_lodash());
|
|
235934
235934
|
var path = __toModule(require("path"));
|
|
235935
|
-
var
|
|
235935
|
+
var import_trader_pgsql_ast_parser2 = __toModule(require_lib());
|
|
235936
235936
|
var prettier = __toModule(require_prettier());
|
|
235937
235937
|
|
|
235938
235938
|
// src/typecheck.ts
|
|
235939
235939
|
var import_assert = __toModule(require("assert"));
|
|
235940
235940
|
var import_lodash = __toModule(require_lodash());
|
|
235941
|
-
var
|
|
235941
|
+
var import_trader_pgsql_ast_parser = __toModule(require_lib());
|
|
235942
235942
|
|
|
235943
235943
|
// src/normalize.ts
|
|
235944
235944
|
function normalizeTypeName(s) {
|
|
@@ -242341,7 +242341,7 @@ function doCreateFunction(g, c, s) {
|
|
|
242341
242341
|
froms: c.froms,
|
|
242342
242342
|
decls: c.decls.concat(inputs)
|
|
242343
242343
|
};
|
|
242344
|
-
const body =
|
|
242344
|
+
const body = import_trader_pgsql_ast_parser.parse(s.code, {locationTracking: true});
|
|
242345
242345
|
if (body.length === 0) {
|
|
242346
242346
|
return {
|
|
242347
242347
|
name,
|
|
@@ -242545,7 +242545,7 @@ var KindMismatch = class extends ErrorWithLocation {
|
|
|
242545
242545
|
constructor(e, type, errormsg) {
|
|
242546
242546
|
super(e._location, `
|
|
242547
242547
|
KindMismatch:
|
|
242548
|
-
${
|
|
242548
|
+
${import_trader_pgsql_ast_parser.toSql.expr(e)}
|
|
242549
242549
|
|
|
242550
242550
|
${errormsg}}
|
|
242551
242551
|
|
|
@@ -242558,7 +242558,7 @@ var DuplicateFieldNames = class extends ErrorWithLocation {
|
|
|
242558
242558
|
constructor(e, name) {
|
|
242559
242559
|
super(e._location, `Duplicate column names: expression:
|
|
242560
242560
|
|
|
242561
|
-
${
|
|
242561
|
+
${import_trader_pgsql_ast_parser.toSql.expr(e)}
|
|
242562
242562
|
|
|
242563
242563
|
has field name
|
|
242564
242564
|
|
|
@@ -242573,7 +242573,7 @@ var TypeMismatch = class extends ErrorWithLocation {
|
|
|
242573
242573
|
constructor(e, ts, mess) {
|
|
242574
242574
|
super(e._location, `
|
|
242575
242575
|
TypeMismatch:
|
|
242576
|
-
${
|
|
242576
|
+
${import_trader_pgsql_ast_parser.toSql.expr(e)}
|
|
242577
242577
|
|
|
242578
242578
|
${mess ? mess : ""}
|
|
242579
242579
|
|
|
@@ -242598,7 +242598,7 @@ to
|
|
|
242598
242598
|
${JSON.stringify(ts.to)}}
|
|
242599
242599
|
|
|
242600
242600
|
in expr:
|
|
242601
|
-
${
|
|
242601
|
+
${import_trader_pgsql_ast_parser.toSql.expr(e)}
|
|
242602
242602
|
`);
|
|
242603
242603
|
this.from = ts.from;
|
|
242604
242604
|
this.to = ts.to;
|
|
@@ -243427,9 +243427,7 @@ function genDeserialization(returnType, literalVar) {
|
|
|
243427
243427
|
} else if (returnType.kind === "record") {
|
|
243428
243428
|
return "({" + returnType.fields.map((f, i) => `${f.name?.name || "?"}: ${genDeserializeSimpleT(f.type, literalVar + "[" + i + "]")}`).join(",\n") + "})";
|
|
243429
243429
|
} else {
|
|
243430
|
-
|
|
243431
|
-
return ${genDeserializeSimpleT(returnType, "cells[0]")};
|
|
243432
|
-
}`;
|
|
243430
|
+
return genDeserializeSimpleT(returnType, literalVar);
|
|
243433
243431
|
}
|
|
243434
243432
|
}
|
|
243435
243433
|
function functionToTypescript(f) {
|
|
@@ -243628,7 +243626,7 @@ async function go() {
|
|
|
243628
243626
|
for (let sqlFile of allSqlFiles) {
|
|
243629
243627
|
console.log(`Processing file ${sqlFile}`);
|
|
243630
243628
|
const fileContents = await fs.readFile(sqlFile, "utf-8");
|
|
243631
|
-
const statements =
|
|
243629
|
+
const statements = import_trader_pgsql_ast_parser2.parse(fileContents, {
|
|
243632
243630
|
locationTracking: true
|
|
243633
243631
|
});
|
|
243634
243632
|
allStatements.push({fileName: sqlFile, statements});
|