mirror of https://github.com/AMT-Cheif/drift.git
Resolve type of EXISTS expressions in types2 (#874)
This commit is contained in:
parent
a4df55029c
commit
89e019f756
|
@ -217,6 +217,12 @@ class TypeResolver extends RecursiveVisitor<TypeExpectation, void> {
|
|||
visit(e.inner, _expectString);
|
||||
}
|
||||
|
||||
@override
|
||||
void visitExists(ExistsExpression e, TypeExpectation arg) {
|
||||
session._checkAndResolve(e, const ResolvedType.bool(), arg);
|
||||
visit(e.select, const NoTypeExpectation());
|
||||
}
|
||||
|
||||
@override
|
||||
void visitUnaryExpression(UnaryExpression e, TypeExpectation arg) {
|
||||
final operatorType = e.operator.type;
|
||||
|
|
|
@ -192,6 +192,11 @@ void main() {
|
|||
expect(type, const ResolvedType(type: BasicType.int));
|
||||
});
|
||||
|
||||
test('infers type of EXISTS expressions', () {
|
||||
final type = _resolveResultColumn('SELECT EXISTS(SELECT * FROM demo);');
|
||||
expect(type, const ResolvedType.bool());
|
||||
});
|
||||
|
||||
test('resolves subqueries', () {
|
||||
final type = _resolveResultColumn('SELECT (SELECT COUNT(*) FROM demo);');
|
||||
expect(type, const ResolvedType(type: BasicType.int));
|
||||
|
|
Loading…
Reference in New Issue