sql-typechecker 0.0.14 → 0.0.17
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 +18 -13
- package/out/cli.js.map +2 -2
- package/package.json +3 -3
package/out/cli.js
CHANGED
|
@@ -243175,7 +243175,17 @@ function showTypeAsTypescriptType(t) {
|
|
|
243175
243175
|
} else if (t.kind === "nullable") {
|
|
243176
243176
|
return showTypeAsTypescriptType(t.typevar) + " | null";
|
|
243177
243177
|
} else if (t.kind === "scalar") {
|
|
243178
|
-
if ([
|
|
243178
|
+
if ([
|
|
243179
|
+
"numeric",
|
|
243180
|
+
"bigint",
|
|
243181
|
+
"smallint",
|
|
243182
|
+
"integer",
|
|
243183
|
+
"real",
|
|
243184
|
+
"double",
|
|
243185
|
+
"float8",
|
|
243186
|
+
"float4",
|
|
243187
|
+
"float2"
|
|
243188
|
+
].includes(t.name.name)) {
|
|
243179
243189
|
return "number";
|
|
243180
243190
|
} else if (["text", "name", "char", "character", "varchar", "nvarchar"].includes(t.name.name)) {
|
|
243181
243191
|
return "string";
|
|
@@ -243269,6 +243279,10 @@ CREATE FUNCTION ${f.name.name}(${argsForCreateFunction}) RETURNS ${f.multipleRow
|
|
|
243269
243279
|
$$${f.code}$$ LANGUAGE ${f.language};
|
|
243270
243280
|
`;
|
|
243271
243281
|
const funcInvocation = `${f.name.name}(${f.inputs.map((inp, i) => "$" + (i + 1) + "::" + showTypeDroppingNullable(inp.type))})${asExpression}`;
|
|
243282
|
+
const deserializationAndReturn = f.returns.kind === "void" ? "" : `
|
|
243283
|
+
const rows = res.rows.map(row => ${genDeserialization(f.returns, "row")});
|
|
243284
|
+
return rows${f.multipleRows ? "" : "[0]"};
|
|
243285
|
+
`;
|
|
243272
243286
|
return `
|
|
243273
243287
|
export async function ${f.name.name}(pool: Pool, args: ${argsType})
|
|
243274
243288
|
: Promise<${returnTypeAsString}>{
|
|
@@ -243278,8 +243292,7 @@ export async function ${f.name.name}(pool: Pool, args: ${argsType})
|
|
|
243278
243292
|
values: [${argsAsList}],
|
|
243279
243293
|
rowMode: "array",
|
|
243280
243294
|
});
|
|
243281
|
-
|
|
243282
|
-
return rows${f.multipleRows ? "" : "[0]"};
|
|
243295
|
+
${deserializationAndReturn}
|
|
243283
243296
|
}
|
|
243284
243297
|
`;
|
|
243285
243298
|
}
|
|
@@ -243432,13 +243445,7 @@ async function go() {
|
|
|
243432
243445
|
}
|
|
243433
243446
|
await fs.appendFile(domainFile, `
|
|
243434
243447
|
`, "utf-8");
|
|
243435
|
-
const tablesIndexFile = path.format({
|
|
243436
|
-
dir: outDir,
|
|
243437
|
-
name: "tables",
|
|
243438
|
-
ext: ".ts"
|
|
243439
|
-
});
|
|
243440
243448
|
await fs.mkdir(path.join(outDir, "tables"), {recursive: true});
|
|
243441
|
-
await prepOutFile(tablesIndexFile);
|
|
243442
243449
|
for (let table of g.tables) {
|
|
243443
243450
|
const tableOutFile = path.format({
|
|
243444
243451
|
dir: path.join(outDir, "tables"),
|
|
@@ -243449,8 +243456,6 @@ async function go() {
|
|
|
243449
243456
|
const text = genCrudOperations(table);
|
|
243450
243457
|
await fs.appendFile(tableOutFile, mkImportDomainsStatement(g.domains, tableOutFile, domainFile), "utf8");
|
|
243451
243458
|
await fs.appendFile(tableOutFile, prettier.format(text, {parser: "typescript"}), "utf-8");
|
|
243452
|
-
await fs.appendFile(tablesIndexFile, `export * as ${table.name.name} from "./tables/${table.name.name}";
|
|
243453
|
-
`);
|
|
243454
243459
|
}
|
|
243455
243460
|
for (let f of allStatements) {
|
|
243456
243461
|
const createFunctionStatements = f.statements.filter(isCreateFunctionStatement);
|
|
@@ -243473,7 +243478,7 @@ async function go() {
|
|
|
243473
243478
|
} catch (err) {
|
|
243474
243479
|
if (err instanceof ErrorWithLocation && err.l !== void 0) {
|
|
243475
243480
|
debugger;
|
|
243476
|
-
const found = findCode(st.code, err.l);
|
|
243481
|
+
const found = findCode(st.code || "", err.l);
|
|
243477
243482
|
if (found) {
|
|
243478
243483
|
console.error("");
|
|
243479
243484
|
console.error(`Found error at line ${found.lineNumber}`);
|
|
@@ -243529,7 +243534,7 @@ function findInArgs(opts) {
|
|
|
243529
243534
|
function mkImportDomainsStatement(domains, thisFile, domainFile) {
|
|
243530
243535
|
const p = path.relative(path.dirname(thisFile), path.dirname(domainFile));
|
|
243531
243536
|
const formatted = path.format({
|
|
243532
|
-
dir: p,
|
|
243537
|
+
dir: p || ".",
|
|
243533
243538
|
name: "domains",
|
|
243534
243539
|
ext: ""
|
|
243535
243540
|
});
|