sql-typechecker 0.0.28 → 0.0.31
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 +23 -23
- package/out/cli.js.map +2 -2
- package/package.json +1 -1
package/out/cli.js
CHANGED
|
@@ -241713,7 +241713,7 @@ function requireBoolean(e, t) {
|
|
|
241713
241713
|
throw new TypeMismatch(e, {
|
|
241714
241714
|
expected: BuiltinTypes.Boolean,
|
|
241715
241715
|
actual: t
|
|
241716
|
-
});
|
|
241716
|
+
}, "Requiring boolean");
|
|
241717
241717
|
}
|
|
241718
241718
|
}
|
|
241719
241719
|
var BuiltinTypeConstructors = {
|
|
@@ -241784,7 +241784,7 @@ function cast(e, source, target, casttype) {
|
|
|
241784
241784
|
}
|
|
241785
241785
|
function castRecords(e, source, target, casttype) {
|
|
241786
241786
|
if (source.fields.length !== target.fields.length) {
|
|
241787
|
-
throw new TypeMismatch(e, {expected: source, actual: target});
|
|
241787
|
+
throw new TypeMismatch(e, {expected: source, actual: target}, "Amount of fields is not the same");
|
|
241788
241788
|
}
|
|
241789
241789
|
source.fields.forEach((sf, i) => {
|
|
241790
241790
|
const tf = target.fields[i];
|
|
@@ -241793,15 +241793,15 @@ function castRecords(e, source, target, casttype) {
|
|
|
241793
241793
|
}
|
|
241794
241794
|
function unifyRecords(e, source, target) {
|
|
241795
241795
|
if (source.fields.length !== target.fields.length) {
|
|
241796
|
-
throw new TypeMismatch(e, {expected: source, actual: target});
|
|
241796
|
+
throw new TypeMismatch(e, {expected: source, actual: target}, "Amount of fields is not the same");
|
|
241797
241797
|
}
|
|
241798
241798
|
const newFields = source.fields.map((sf, i) => {
|
|
241799
241799
|
const tf = target.fields[i];
|
|
241800
|
-
const t = unifySimples(tf.
|
|
241800
|
+
const t = unifySimples(tf._expr || e, sf.type, tf.type);
|
|
241801
241801
|
return {
|
|
241802
241802
|
name: sf.name || tf.name,
|
|
241803
241803
|
type: t,
|
|
241804
|
-
|
|
241804
|
+
_expr: tf._expr
|
|
241805
241805
|
};
|
|
241806
241806
|
});
|
|
241807
241807
|
return {
|
|
@@ -241846,19 +241846,19 @@ function castSimples(e, source, target, type) {
|
|
|
241846
241846
|
if (target.kind === "nullable") {
|
|
241847
241847
|
return castSimples(e, source.typevar, target.typevar, type);
|
|
241848
241848
|
} else {
|
|
241849
|
-
throw new TypeMismatch(e, {expected: source, actual: target});
|
|
241849
|
+
throw new TypeMismatch(e, {expected: source, actual: target}, "Nullability is different");
|
|
241850
241850
|
}
|
|
241851
241851
|
} else if (source.kind === "array") {
|
|
241852
241852
|
if (target.kind === "array" && source.subtype === target.subtype) {
|
|
241853
241853
|
return castSimples(e, source.typevar, target.typevar, type);
|
|
241854
241854
|
} else {
|
|
241855
|
-
throw new TypeMismatch(e, {expected: source, actual: target});
|
|
241855
|
+
throw new TypeMismatch(e, {expected: source, actual: target}, "Can't unify array with non-array");
|
|
241856
241856
|
}
|
|
241857
241857
|
} else if (source.kind === "scalar") {
|
|
241858
241858
|
if (target.kind === "scalar") {
|
|
241859
241859
|
return castScalars(e, source, target, type);
|
|
241860
241860
|
} else {
|
|
241861
|
-
throw new TypeMismatch(e, {expected: source, actual: target});
|
|
241861
|
+
throw new TypeMismatch(e, {expected: source, actual: target}, "Can't unify scalar with non-scalar");
|
|
241862
241862
|
}
|
|
241863
241863
|
} else if (source.kind === "jsonknown") {
|
|
241864
241864
|
if (target.kind === "jsonknown") {
|
|
@@ -241872,7 +241872,7 @@ function castSimples(e, source, target, type) {
|
|
|
241872
241872
|
}
|
|
241873
241873
|
return;
|
|
241874
241874
|
} else {
|
|
241875
|
-
throw new TypeMismatch(e, {expected: source, actual: target});
|
|
241875
|
+
throw new TypeMismatch(e, {expected: source, actual: target}, "Can't unify JSON with non-JSON");
|
|
241876
241876
|
}
|
|
241877
241877
|
} else {
|
|
241878
241878
|
return checkAllCasesHandled(source);
|
|
@@ -241915,7 +241915,7 @@ function unifyCallGeneral(call, argTypes, expectedArgs, returnT) {
|
|
|
241915
241915
|
function castScalars(e, source, target, type) {
|
|
241916
241916
|
const matchingCast = findMatchingCast([source.name], source, target, type);
|
|
241917
241917
|
if (matchingCast === null) {
|
|
241918
|
-
throw new TypeMismatch(e, {expected: target, actual: source});
|
|
241918
|
+
throw new TypeMismatch(e, {expected: target, actual: source}, "Couldn't find matching cast");
|
|
241919
241919
|
}
|
|
241920
241920
|
}
|
|
241921
241921
|
function findMatchingCast(visited, from, to, type) {
|
|
@@ -241977,8 +241977,7 @@ function doCreateTable(g, s) {
|
|
|
241977
241977
|
} else {
|
|
241978
241978
|
return acc.concat({
|
|
241979
241979
|
name: c.name,
|
|
241980
|
-
type: mkType(c.dataType, c.constraints || [])
|
|
241981
|
-
expr: null
|
|
241980
|
+
type: mkType(c.dataType, c.constraints || [])
|
|
241982
241981
|
});
|
|
241983
241982
|
}
|
|
241984
241983
|
}, []);
|
|
@@ -242053,7 +242052,7 @@ function elabSelect(g, c, s) {
|
|
|
242053
242052
|
const foundNullabilityInference = inferredNullability.find((inf) => eqQNames(inf.fromName, fr.name) && inf.fieldName === fi.name?.name);
|
|
242054
242053
|
if (foundNullabilityInference && isNullable(fi.type)) {
|
|
242055
242054
|
const t = foundNullabilityInference.isNull === true ? BuiltinTypes.Null : unnullify(fi.type);
|
|
242056
|
-
return {name: fi.name, type: t,
|
|
242055
|
+
return {name: fi.name, type: t, _expr: fi._expr};
|
|
242057
242056
|
} else {
|
|
242058
242057
|
return fi;
|
|
242059
242058
|
}
|
|
@@ -242083,7 +242082,7 @@ function elabSelect(g, c, s) {
|
|
|
242083
242082
|
if (c2.expr.type === "ref" && c2.expr.name === "*") {
|
|
242084
242083
|
return t.fields;
|
|
242085
242084
|
} else {
|
|
242086
|
-
return [{name: n, type: t.fields[0].type,
|
|
242085
|
+
return [{name: n, type: t.fields[0].type, _expr: c2.expr}];
|
|
242087
242086
|
}
|
|
242088
242087
|
} else {
|
|
242089
242088
|
if (c2.expr.type === "ref" && c2.expr.name === "*") {
|
|
@@ -242093,7 +242092,7 @@ function elabSelect(g, c, s) {
|
|
|
242093
242092
|
}
|
|
242094
242093
|
}
|
|
242095
242094
|
}
|
|
242096
|
-
return [{name: n, type: t,
|
|
242095
|
+
return [{name: n, type: t, _expr: c2.expr}];
|
|
242097
242096
|
});
|
|
242098
242097
|
return {
|
|
242099
242098
|
kind: "record",
|
|
@@ -242117,7 +242116,7 @@ function elabSelect(g, c, s) {
|
|
|
242117
242116
|
if (t === null) {
|
|
242118
242117
|
throw new CantReduceToSimpleT(exp, t_);
|
|
242119
242118
|
} else {
|
|
242120
|
-
return {name: null, type: t,
|
|
242119
|
+
return {name: null, type: t, _expr: exp};
|
|
242121
242120
|
}
|
|
242122
242121
|
});
|
|
242123
242122
|
return {
|
|
@@ -242145,7 +242144,7 @@ function elabSelect(g, c, s) {
|
|
|
242145
242144
|
{
|
|
242146
242145
|
name: null,
|
|
242147
242146
|
type: res,
|
|
242148
|
-
|
|
242147
|
+
_expr: s
|
|
242149
242148
|
}
|
|
242150
242149
|
]
|
|
242151
242150
|
};
|
|
@@ -242159,6 +242158,7 @@ function elabSelect(g, c, s) {
|
|
|
242159
242158
|
}
|
|
242160
242159
|
}
|
|
242161
242160
|
function elabInsert(g, c, s) {
|
|
242161
|
+
debugger;
|
|
242162
242162
|
const insertingInto = g.tables.find((t) => eqQNames(t.name, s.into)) || null;
|
|
242163
242163
|
if (!insertingInto) {
|
|
242164
242164
|
throw new UnknownIdentifier(s, s.into);
|
|
@@ -242183,7 +242183,7 @@ function elabInsert(g, c, s) {
|
|
|
242183
242183
|
}
|
|
242184
242184
|
return foundField;
|
|
242185
242185
|
}) : insertingInto.rel.fields;
|
|
242186
|
-
const insertT = elabSelect(g,
|
|
242186
|
+
const insertT = elabSelect(g, c, s.insert);
|
|
242187
242187
|
if (insertT.kind === "void") {
|
|
242188
242188
|
throw new ColumnsMismatch(s.insert, {
|
|
242189
242189
|
expected: columns.length,
|
|
@@ -242198,7 +242198,7 @@ function elabInsert(g, c, s) {
|
|
|
242198
242198
|
}
|
|
242199
242199
|
insertT.fields.forEach((insertField, i) => {
|
|
242200
242200
|
const col = columns[i];
|
|
242201
|
-
cast(s.insert, insertField.type, col.type, "assignment");
|
|
242201
|
+
cast(insertField._expr || s.insert, insertField.type, col.type, "assignment");
|
|
242202
242202
|
});
|
|
242203
242203
|
if (s.returning) {
|
|
242204
242204
|
return {
|
|
@@ -242212,7 +242212,7 @@ function elabInsert(g, c, s) {
|
|
|
242212
242212
|
return {
|
|
242213
242213
|
name: selectedCol.alias || deriveNameFromExpr(selectedCol.expr),
|
|
242214
242214
|
type: t,
|
|
242215
|
-
|
|
242215
|
+
_expr: selectedCol.expr
|
|
242216
242216
|
};
|
|
242217
242217
|
}
|
|
242218
242218
|
})
|
|
@@ -242251,7 +242251,7 @@ function elabDeleteOrUpdate(g, c, s) {
|
|
|
242251
242251
|
return {
|
|
242252
242252
|
name: selectedCol.alias || deriveNameFromExpr(selectedCol.expr),
|
|
242253
242253
|
type: t,
|
|
242254
|
-
|
|
242254
|
+
_expr: selectedCol.expr
|
|
242255
242255
|
};
|
|
242256
242256
|
}
|
|
242257
242257
|
})
|
|
@@ -242847,7 +242847,7 @@ function elabCall(g, c, e) {
|
|
|
242847
242847
|
record.fields.push({
|
|
242848
242848
|
name: {name: key.value},
|
|
242849
242849
|
type: valTSimple,
|
|
242850
|
-
|
|
242850
|
+
_expr: e.args[i]
|
|
242851
242851
|
});
|
|
242852
242852
|
}
|
|
242853
242853
|
return {kind: "jsonknown", record};
|
|
@@ -243055,7 +243055,7 @@ function elabExpr(g, c, e) {
|
|
|
243055
243055
|
throw new TypeMismatch(e.array, {
|
|
243056
243056
|
expected: arrayT,
|
|
243057
243057
|
actual: BuiltinTypeConstructors.Array(BuiltinTypes.AnyScalar)
|
|
243058
|
-
});
|
|
243058
|
+
}, "Can't get array index from non-array type");
|
|
243059
243059
|
} else {
|
|
243060
243060
|
return nullify(unnulified.typevar);
|
|
243061
243061
|
}
|