sql-typechecker 0.0.37 → 0.0.43
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 +6 -3
- package/out/cli.js.map +2 -2
- package/package.json +1 -1
package/out/cli.js
CHANGED
|
@@ -243033,7 +243033,7 @@ function elabCall(g, c, e) {
|
|
|
243033
243033
|
]);
|
|
243034
243034
|
}
|
|
243035
243035
|
if (eqQNames(e.function, {name: "max"}) || eqQNames(e.function, {name: "min"})) {
|
|
243036
|
-
return unifyOverloadedCall(e, argTypes, allNumericBuiltinTypes.map((t) => ({expectedArgs: [t], returnT: t})));
|
|
243036
|
+
return unifyOverloadedCall(e, argTypes, allNumericBuiltinTypes.concat([BuiltinTypes.Date, BuiltinTypes.Time, BuiltinTypes.Timestamp]).map((t) => ({expectedArgs: [t], returnT: t})));
|
|
243037
243037
|
}
|
|
243038
243038
|
if (eqQNames(e.function, {name: "count"})) {
|
|
243039
243039
|
return unifyCallGeneral(e, argTypes, [BuiltinTypes.AnyScalar], BuiltinTypes.Bigint);
|
|
@@ -243490,12 +243490,15 @@ import type { Pool } from "pg";
|
|
|
243490
243490
|
import { Instant, LocalDate, LocalTime, LocalDateTime} from "@js-joda/core";
|
|
243491
243491
|
`;
|
|
243492
243492
|
}
|
|
243493
|
+
function genSelectColumnsFromTable(t) {
|
|
243494
|
+
return t.fields.map((f) => f.name?.name || "?").join(", ");
|
|
243495
|
+
}
|
|
243493
243496
|
function genCrudOperations(table) {
|
|
243494
243497
|
const selectAll = `
|
|
243495
243498
|
export async function getAll(pool: Pool): Promise<${showTypeAsTypescriptType(table.rel)}[]>{
|
|
243496
243499
|
|
|
243497
243500
|
const res = await pool.query({
|
|
243498
|
-
text: "SELECT
|
|
243501
|
+
text: "SELECT ${genSelectColumnsFromTable(table.rel)} FROM ${showQName(table.name)}",
|
|
243499
243502
|
values: [],
|
|
243500
243503
|
rowMode: "array",
|
|
243501
243504
|
});
|
|
@@ -243541,7 +243544,7 @@ export async function insert(pool: Pool, row: {${inputRow}}): Promise<{${primary
|
|
|
243541
243544
|
export async function getOne(pool: Pool, pk: {${primaryKeySingleCol.name.name}: ${showTypeAsTypescriptType(primaryKeySingleCol.type)}}): Promise<${showTypeAsTypescriptType(table.rel)} | null>{
|
|
243542
243545
|
|
|
243543
243546
|
const res = await pool.query({
|
|
243544
|
-
text: "SELECT
|
|
243547
|
+
text: "SELECT ${genSelectColumnsFromTable(table.rel)} FROM ${showQName(table.name)} WHERE ${primaryKeySingleCol.name.name} = $1",
|
|
243545
243548
|
values: [pk.${primaryKeySingleCol.name.name}] as any[],
|
|
243546
243549
|
rowMode: "array",
|
|
243547
243550
|
});
|