sql-typechecker 0.0.54 → 0.0.55

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
@@ -235922,7 +235922,10 @@ function normalizeTypeName(s) {
235922
235922
  if (s === "bool") {
235923
235923
  return "boolean";
235924
235924
  }
235925
- if (s === "float") {
235925
+ if (s === "float4") {
235926
+ return "real";
235927
+ }
235928
+ if (s === "float" || s === "float8") {
235926
235929
  return "double";
235927
235930
  }
235928
235931
  if (s === "double precision") {
@@ -242067,8 +242070,21 @@ function doCreateTable(g, s) {
242067
242070
  })
242068
242071
  };
242069
242072
  }
242070
- function doCreateView(_g, s) {
242071
- return _g;
242073
+ function doCreateView(g, s) {
242074
+ const sel = elabSelect(g, {
242075
+ froms: [],
242076
+ decls: []
242077
+ }, Array.isArray(s.query) ? s.query[0] : s.query);
242078
+ if (sel.kind === "void") {
242079
+ throw new ErrorWithLocation(s._location, "View returns void");
242080
+ }
242081
+ return {
242082
+ ...g,
242083
+ views: g.views.concat({
242084
+ name: s.name,
242085
+ rel: sel
242086
+ })
242087
+ };
242072
242088
  }
242073
242089
  function doAlterTable(_g, s) {
242074
242090
  return notImplementedYet(s);
@@ -242460,7 +242476,8 @@ ${JSON.stringify(node)} @ ${node._location}` : "";
242460
242476
  var UnknownField = class extends ErrorWithLocation {
242461
242477
  constructor(e, s, n) {
242462
242478
  super(e._location, `UnknownField ${n.name}.
242463
- Keys present: ${s.fields.map((f) => f.name?.name || "").join(", ")}`);
242479
+ Keys present:
242480
+ ${s.fields.map((f) => (f.name?.name || "") + ": " + showType(f.type)).join("\n")}`);
242464
242481
  }
242465
242482
  };
242466
242483
  var UnknownIdentifier = class extends ErrorWithLocation {
@@ -242919,7 +242936,11 @@ function elabCall(g, c, e) {
242919
242936
  }
242920
242937
  if (eqQNames(e.function, {name: "array_agg"})) {
242921
242938
  if (e.args.length === 1) {
242922
- return {kind: "array", subtype: "array", typevar: argTypes[0]};
242939
+ const subt = argTypes[0];
242940
+ if (subt.kind === "record") {
242941
+ throw new ErrorWithLocation(e.args[0]._location, "Can't have record type inside array");
242942
+ }
242943
+ return BuiltinTypeConstructors.Nullable(BuiltinTypeConstructors.Array(subt));
242923
242944
  } else {
242924
242945
  throw new InvalidArguments(e, e.function, argTypes);
242925
242946
  }
@@ -243349,8 +243370,8 @@ function unnullify(s) {
243349
243370
  return s;
243350
243371
  }
243351
243372
  }
243352
- function checkAllCasesHandled(_) {
243353
- throw new Error("Oops didn't expect that");
243373
+ function checkAllCasesHandled(r) {
243374
+ throw new Error(`Oops didn't expect that, ${JSON.stringify(r)}`);
243354
243375
  }
243355
243376
  function showQName(n) {
243356
243377
  return n.schema ? n.schema + "." + n.name : n.name;
@@ -243420,7 +243441,7 @@ function showTypeAsTypescriptType(t) {
243420
243441
  }
243421
243442
  function genDeserializeSimpleT(t, literalVar) {
243422
243443
  if (t.kind === "array") {
243423
- return `${literalVar} === null ? [] : (Array.isArray(${literalVar}) ? ${literalVar} : parseArray(${literalVar})).map((el: any) => ${genDeserializeSimpleT(t.typevar, "el")})`;
243444
+ return `parseArray(${literalVar}, (el: any) => ${genDeserializeSimpleT(t.typevar, "el")})`;
243424
243445
  } else if (t.kind === "nullable") {
243425
243446
  const inner = genDeserializeSimpleT(t.typevar, literalVar);
243426
243447
  if (inner === literalVar) {
@@ -243736,6 +243757,9 @@ async function go() {
243736
243757
  const functionsOutFile = await prepOutFile(outFileName);
243737
243758
  await fs.appendFile(outFileName, mkImportDomainsStatement(g.domains, outFileName, typesFile), "utf8");
243738
243759
  for (let st of createFunctionStatements) {
243760
+ if (st.language?.name.toLowerCase() !== "sql") {
243761
+ continue;
243762
+ }
243739
243763
  try {
243740
243764
  const res = doCreateFunction(g, {decls: [], froms: []}, st);
243741
243765
  const writing = prettier.format(functionToTypescript(res), {