sql-typechecker 0.0.27 → 0.0.28

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,8 @@ 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: null
241980
241982
  });
241981
241983
  }
241982
241984
  }, []);
@@ -242051,7 +242053,7 @@ function elabSelect(g, c, s) {
242051
242053
  const foundNullabilityInference = inferredNullability.find((inf) => eqQNames(inf.fromName, fr.name) && inf.fieldName === fi.name?.name);
242052
242054
  if (foundNullabilityInference && isNullable(fi.type)) {
242053
242055
  const t = foundNullabilityInference.isNull === true ? BuiltinTypes.Null : unnullify(fi.type);
242054
- return {name: fi.name, type: t};
242056
+ return {name: fi.name, type: t, expr: fi.expr};
242055
242057
  } else {
242056
242058
  return fi;
242057
242059
  }
@@ -242081,7 +242083,7 @@ function elabSelect(g, c, s) {
242081
242083
  if (c2.expr.type === "ref" && c2.expr.name === "*") {
242082
242084
  return t.fields;
242083
242085
  } else {
242084
- return [{name: n, type: t.fields[0].type}];
242086
+ return [{name: n, type: t.fields[0].type, expr: c2.expr}];
242085
242087
  }
242086
242088
  } else {
242087
242089
  if (c2.expr.type === "ref" && c2.expr.name === "*") {
@@ -242091,7 +242093,7 @@ function elabSelect(g, c, s) {
242091
242093
  }
242092
242094
  }
242093
242095
  }
242094
- return [{name: n, type: t}];
242096
+ return [{name: n, type: t, expr: c2.expr}];
242095
242097
  });
242096
242098
  return {
242097
242099
  kind: "record",
@@ -242115,7 +242117,7 @@ function elabSelect(g, c, s) {
242115
242117
  if (t === null) {
242116
242118
  throw new CantReduceToSimpleT(exp, t_);
242117
242119
  } else {
242118
- return {name: null, type: t};
242120
+ return {name: null, type: t, expr: exp};
242119
242121
  }
242120
242122
  });
242121
242123
  return {
@@ -242142,7 +242144,8 @@ function elabSelect(g, c, s) {
242142
242144
  fields: [
242143
242145
  {
242144
242146
  name: null,
242145
- type: res
242147
+ type: res,
242148
+ expr: s
242146
242149
  }
242147
242150
  ]
242148
242151
  };
@@ -242208,7 +242211,8 @@ function elabInsert(g, c, s) {
242208
242211
  } else {
242209
242212
  return {
242210
242213
  name: selectedCol.alias || deriveNameFromExpr(selectedCol.expr),
242211
- type: t
242214
+ type: t,
242215
+ expr: selectedCol.expr
242212
242216
  };
242213
242217
  }
242214
242218
  })
@@ -242246,7 +242250,8 @@ function elabDeleteOrUpdate(g, c, s) {
242246
242250
  } else {
242247
242251
  return {
242248
242252
  name: selectedCol.alias || deriveNameFromExpr(selectedCol.expr),
242249
- type: t
242253
+ type: t,
242254
+ expr: selectedCol.expr
242250
242255
  };
242251
242256
  }
242252
242257
  })
@@ -242839,7 +242844,11 @@ function elabCall(g, c, e) {
242839
242844
  if (valTSimple === null) {
242840
242845
  throw new CantReduceToSimpleT(e.args[i], argTypes[i]);
242841
242846
  }
242842
- record.fields.push({name: {name: key.value}, type: valTSimple});
242847
+ record.fields.push({
242848
+ name: {name: key.value},
242849
+ type: valTSimple,
242850
+ expr: e.args[i]
242851
+ });
242843
242852
  }
242844
242853
  return {kind: "jsonknown", record};
242845
242854
  } else {
@@ -243176,7 +243185,7 @@ function nullifyRecord(s) {
243176
243185
  return {
243177
243186
  kind: "record",
243178
243187
  fields: s.fields.map((c) => ({
243179
- name: c.name,
243188
+ ...c,
243180
243189
  type: nullify(c.type)
243181
243190
  }))
243182
243191
  };
@@ -243556,11 +243565,12 @@ async function go() {
243556
243565
  if (err instanceof ErrorWithLocation && err.l !== void 0) {
243557
243566
  const found = findCode(st.code || "", err.l);
243558
243567
  if (found) {
243568
+ const prefix = found.lineNumber.toString() + " ";
243559
243569
  console.error("");
243560
243570
  console.error(`Typechecking error`);
243561
243571
  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]));
243572
+ console.error(prefix + found.line);
243573
+ console.error(import_lodash2.repeat(" ", found.range[0] + prefix.length) + import_lodash2.repeat("^", found.range[1] - found.range[0]));
243564
243574
  }
243565
243575
  }
243566
243576
  console.error(err instanceof Error ? err.message : JSON.stringify(err));