sql-typechecker 0.0.25 → 0.0.26
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 +17 -2
- package/out/cli.js.map +2 -2
- package/package.json +1 -1
package/out/cli.js
CHANGED
|
@@ -243302,7 +243302,7 @@ return ${genDeserializeSimpleT(returnType, "cells[0]")};
|
|
|
243302
243302
|
}
|
|
243303
243303
|
}
|
|
243304
243304
|
function functionToTypescript(f) {
|
|
243305
|
-
const returnTypeAsString = f.returns.kind === "void" ? "void" : showTypeAsTypescriptType(f.returns) + (f.multipleRows ? "[]" : " |
|
|
243305
|
+
const returnTypeAsString = f.returns.kind === "void" ? "void" : showTypeAsTypescriptType(f.returns) + (f.multipleRows ? "[]" : " | null");
|
|
243306
243306
|
const argsType = "{" + f.inputs.map((k) => {
|
|
243307
243307
|
const paramTypeAsString = showTypeAsTypescriptType(k.type);
|
|
243308
243308
|
return k.name.name + ": " + paramTypeAsString;
|
|
@@ -243335,7 +243335,7 @@ const row = res.rows[0];
|
|
|
243335
243335
|
if (row.some(f => f !== null)){
|
|
243336
243336
|
return ${genDeserialization(f.returns, "row")}
|
|
243337
243337
|
} else {
|
|
243338
|
-
return
|
|
243338
|
+
return null;
|
|
243339
243339
|
}`;
|
|
243340
243340
|
return `
|
|
243341
243341
|
export async function ${f.name.name}(pool: Pool, args: ${argsType})
|
|
@@ -243405,6 +243405,20 @@ export async function insert(pool: Pool, row: {${inputRow}}): Promise<{${primary
|
|
|
243405
243405
|
} else {
|
|
243406
243406
|
return null;
|
|
243407
243407
|
}
|
|
243408
|
+
}`;
|
|
243409
|
+
const selectOne = `
|
|
243410
|
+
export async function getOne(pool: Pool, pk: {${primaryKeySingleCol.name.name}: ${showTypeAsTypescriptType(primaryKeySingleCol.type)}}): Promise<${showTypeAsTypescriptType(table.rel)} | null>{
|
|
243411
|
+
|
|
243412
|
+
const res = await pool.query({
|
|
243413
|
+
text: "SELECT * FROM ${showQName(table.name)} WHERE ${primaryKeySingleCol.name.name} = $1",
|
|
243414
|
+
values: [pk.${primaryKeySingleCol.name.name}] as any[],
|
|
243415
|
+
rowMode: "array",
|
|
243416
|
+
});
|
|
243417
|
+
if (res.rows[0]){
|
|
243418
|
+
return ${genDeserialization(table.rel, "res.rows[0]")};
|
|
243419
|
+
} else {
|
|
243420
|
+
return null;
|
|
243421
|
+
}
|
|
243408
243422
|
}`;
|
|
243409
243423
|
const inputRowForUpdate = relWithoutPrim.map((f) => `
|
|
243410
243424
|
${f.name?.name}?: ${showTypeAsTypescriptType(f.type)}`).join(",");
|
|
@@ -243433,6 +243447,7 @@ return null;
|
|
|
243433
243447
|
}`;
|
|
243434
243448
|
return `
|
|
243435
243449
|
${selectAll}
|
|
243450
|
+
${selectOne}
|
|
243436
243451
|
${insert}
|
|
243437
243452
|
${update}
|
|
243438
243453
|
${del}
|