sql-typechecker 0.0.46 → 0.0.48

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 CHANGED
@@ -243036,7 +243036,7 @@ function elabCall(g, c, e) {
243036
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
- return unifyCallGeneral(e, argTypes, [BuiltinTypes.AnyScalar], BuiltinTypes.Bigint);
243039
+ return BuiltinTypes.Bigint;
243040
243040
  }
243041
243041
  if (eqQNames(e.function, {name: "coalesce"}) || eqQNames(e.function, {name: "nullif"})) {
243042
243042
  if (e.args.length === 0) {
@@ -243399,7 +243399,7 @@ function genDeserializeSimpleT(t, literalVar) {
243399
243399
  if (inner === literalVar) {
243400
243400
  return inner;
243401
243401
  } else {
243402
- return `${literalVar} === null ? (${inner}) : null`;
243402
+ return `${literalVar} === null ? null : (${inner})`;
243403
243403
  }
243404
243404
  } else if (t.kind === "anyscalar") {
243405
243405
  return literalVar;
@@ -243423,13 +243423,13 @@ function genDeserializeSimpleT(t, literalVar) {
243423
243423
  return checkAllCasesHandled(t);
243424
243424
  }
243425
243425
  }
243426
- function genDeserialization(returnType, literalVar) {
243426
+ function genFunctionResDeserialization(returnType, literalVar) {
243427
243427
  if (returnType.kind === "void") {
243428
243428
  return literalVar;
243429
243429
  } else if (returnType.kind === "record") {
243430
243430
  return "({" + returnType.fields.map((f, i) => `${f.name?.name || "?"}: ${genDeserializeSimpleT(f.type, literalVar + "[" + i + "]")}`).join(",\n") + "})";
243431
243431
  } else {
243432
- return genDeserializeSimpleT(returnType, literalVar);
243432
+ return genDeserializeSimpleT(returnType, literalVar + "[0]");
243433
243433
  }
243434
243434
  }
243435
243435
  function functionToTypescript(f) {
@@ -243461,10 +243461,10 @@ CREATE FUNCTION ${f.name.name}(${argsForCreateFunction}) RETURNS ${f.multipleRow
243461
243461
  $$${f.code}$$ LANGUAGE ${f.language};
243462
243462
  `;
243463
243463
  const funcInvocation = `${f.name.name}(${f.inputs.map((inp, i) => "$" + (i + 1) + "::" + showTypeDroppingNullable(inp.type))})${asExpression}`;
243464
- const deserializationAndReturn = f.returns.kind === "void" ? "" : f.multipleRows === true ? `return res.rows.map(row => ${genDeserialization(f.returns, "row")});` : `
243464
+ const deserializationAndReturn = f.returns.kind === "void" ? "" : f.multipleRows === true ? `return res.rows.map(row => ${genFunctionResDeserialization(f.returns, "row")});` : `
243465
243465
  const row = res.rows[0];
243466
243466
  if (row.some(f => f !== null)){
243467
- return ${genDeserialization(f.returns, "row")}
243467
+ return ${genFunctionResDeserialization(f.returns, "row")}
243468
243468
  } else {
243469
243469
  return null;
243470
243470
  }`;
@@ -243502,7 +243502,7 @@ text: "SELECT ${genSelectColumnsFromTable(table.rel)} FROM ${showQName(table.nam
243502
243502
  values: [],
243503
243503
  rowMode: "array",
243504
243504
  });
243505
- const rows = res.rows.map(row => ${genDeserialization(table.rel, "row")});
243505
+ const rows = res.rows.map(row => ${genFunctionResDeserialization(table.rel, "row")});
243506
243506
  return rows;
243507
243507
  }`;
243508
243508
  const primaryKeySingleCol = function getPrimaryKey() {
@@ -243549,7 +243549,7 @@ values: [pk.${primaryKeySingleCol.name.name}] as any[],
243549
243549
  rowMode: "array",
243550
243550
  });
243551
243551
  if (res.rows[0]){
243552
- return ${genDeserialization(table.rel, "res.rows[0]")};
243552
+ return ${genFunctionResDeserialization(table.rel, "res.rows[0]")};
243553
243553
  } else {
243554
243554
  return null;
243555
243555
  }