sql-typechecker 0.0.26 → 0.0.29

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
@@ -241797,10 +241797,11 @@ function unifyRecords(e, source, target) {
241797
241797
  }
241798
241798
  const newFields = source.fields.map((sf, i) => {
241799
241799
  const tf = target.fields[i];
241800
- const t = unifySimples(e, sf.type, tf.type);
241800
+ const t = unifySimples(tf.expr || e, sf.type, tf.type);
241801
241801
  return {
241802
241802
  name: sf.name || tf.name,
241803
- type: t
241803
+ type: t,
241804
+ expr: tf.expr
241804
241805
  };
241805
241806
  });
241806
241807
  return {
@@ -241976,7 +241977,11 @@ function doCreateTable(g, s) {
241976
241977
  } else {
241977
241978
  return acc.concat({
241978
241979
  name: c.name,
241979
- type: mkType(c.dataType, c.constraints || [])
241980
+ type: mkType(c.dataType, c.constraints || []),
241981
+ expr: {
241982
+ type: "null",
241983
+ _location: c._location
241984
+ }
241980
241985
  });
241981
241986
  }
241982
241987
  }, []);
@@ -242051,7 +242056,7 @@ function elabSelect(g, c, s) {
242051
242056
  const foundNullabilityInference = inferredNullability.find((inf) => eqQNames(inf.fromName, fr.name) && inf.fieldName === fi.name?.name);
242052
242057
  if (foundNullabilityInference && isNullable(fi.type)) {
242053
242058
  const t = foundNullabilityInference.isNull === true ? BuiltinTypes.Null : unnullify(fi.type);
242054
- return {name: fi.name, type: t};
242059
+ return {name: fi.name, type: t, expr: fi.expr};
242055
242060
  } else {
242056
242061
  return fi;
242057
242062
  }
@@ -242081,7 +242086,7 @@ function elabSelect(g, c, s) {
242081
242086
  if (c2.expr.type === "ref" && c2.expr.name === "*") {
242082
242087
  return t.fields;
242083
242088
  } else {
242084
- return [{name: n, type: t.fields[0].type}];
242089
+ return [{name: n, type: t.fields[0].type, expr: c2.expr}];
242085
242090
  }
242086
242091
  } else {
242087
242092
  if (c2.expr.type === "ref" && c2.expr.name === "*") {
@@ -242091,7 +242096,7 @@ function elabSelect(g, c, s) {
242091
242096
  }
242092
242097
  }
242093
242098
  }
242094
- return [{name: n, type: t}];
242099
+ return [{name: n, type: t, expr: c2.expr}];
242095
242100
  });
242096
242101
  return {
242097
242102
  kind: "record",
@@ -242115,7 +242120,7 @@ function elabSelect(g, c, s) {
242115
242120
  if (t === null) {
242116
242121
  throw new CantReduceToSimpleT(exp, t_);
242117
242122
  } else {
242118
- return {name: null, type: t};
242123
+ return {name: null, type: t, expr: exp};
242119
242124
  }
242120
242125
  });
242121
242126
  return {
@@ -242142,7 +242147,8 @@ function elabSelect(g, c, s) {
242142
242147
  fields: [
242143
242148
  {
242144
242149
  name: null,
242145
- type: res
242150
+ type: res,
242151
+ expr: s
242146
242152
  }
242147
242153
  ]
242148
242154
  };
@@ -242195,7 +242201,7 @@ function elabInsert(g, c, s) {
242195
242201
  }
242196
242202
  insertT.fields.forEach((insertField, i) => {
242197
242203
  const col = columns[i];
242198
- cast(s.insert, insertField.type, col.type, "assignment");
242204
+ cast(insertField.expr || s.insert, insertField.type, col.type, "assignment");
242199
242205
  });
242200
242206
  if (s.returning) {
242201
242207
  return {
@@ -242208,7 +242214,8 @@ function elabInsert(g, c, s) {
242208
242214
  } else {
242209
242215
  return {
242210
242216
  name: selectedCol.alias || deriveNameFromExpr(selectedCol.expr),
242211
- type: t
242217
+ type: t,
242218
+ expr: selectedCol.expr
242212
242219
  };
242213
242220
  }
242214
242221
  })
@@ -242246,7 +242253,8 @@ function elabDeleteOrUpdate(g, c, s) {
242246
242253
  } else {
242247
242254
  return {
242248
242255
  name: selectedCol.alias || deriveNameFromExpr(selectedCol.expr),
242249
- type: t
242256
+ type: t,
242257
+ expr: selectedCol.expr
242250
242258
  };
242251
242259
  }
242252
242260
  })
@@ -242839,7 +242847,11 @@ function elabCall(g, c, e) {
242839
242847
  if (valTSimple === null) {
242840
242848
  throw new CantReduceToSimpleT(e.args[i], argTypes[i]);
242841
242849
  }
242842
- record.fields.push({name: {name: key.value}, type: valTSimple});
242850
+ record.fields.push({
242851
+ name: {name: key.value},
242852
+ type: valTSimple,
242853
+ expr: e.args[i]
242854
+ });
242843
242855
  }
242844
242856
  return {kind: "jsonknown", record};
242845
242857
  } else {
@@ -242905,7 +242917,7 @@ function elabCall(g, c, e) {
242905
242917
  return unifyOverloadedCall(e, argTypes, allNumericBuiltinTypes.map((t) => ({expectedArgs: [t], returnT: t})));
242906
242918
  }
242907
242919
  if (eqQNames(e.function, {name: "count"})) {
242908
- return unifyCallGeneral(e, argTypes, [BuiltinTypes.AnyScalar], BuiltinTypes.Boolean);
242920
+ return unifyCallGeneral(e, argTypes, [BuiltinTypes.AnyScalar], BuiltinTypes.Bigint);
242909
242921
  }
242910
242922
  if (eqQNames(e.function, {name: "coalesce"}) || eqQNames(e.function, {name: "nullif"})) {
242911
242923
  if (e.args.length === 0) {
@@ -243176,7 +243188,7 @@ function nullifyRecord(s) {
243176
243188
  return {
243177
243189
  kind: "record",
243178
243190
  fields: s.fields.map((c) => ({
243179
- name: c.name,
243191
+ ...c,
243180
243192
  type: nullify(c.type)
243181
243193
  }))
243182
243194
  };
@@ -243556,11 +243568,12 @@ async function go() {
243556
243568
  if (err instanceof ErrorWithLocation && err.l !== void 0) {
243557
243569
  const found = findCode(st.code || "", err.l);
243558
243570
  if (found) {
243571
+ const prefix = found.lineNumber.toString() + " ";
243559
243572
  console.error("");
243560
243573
  console.error(`Typechecking error`);
243561
243574
  console.error("");
243562
- console.error(found.line);
243563
- console.error(import_lodash2.repeat(" ", found.range[0]) + import_lodash2.repeat("^", found.range[1] - found.range[0]));
243575
+ console.error(prefix + found.line);
243576
+ console.error(import_lodash2.repeat(" ", found.range[0] + prefix.length) + import_lodash2.repeat("^", found.range[1] - found.range[0]));
243564
243577
  }
243565
243578
  }
243566
243579
  console.error(err instanceof Error ? err.message : JSON.stringify(err));