Fix not resolved columns bug

This commit is contained in:
Daniel Brauner 2022-01-23 17:53:16 +01:00
parent a9fd12e565
commit 7129468928
2 changed files with 21 additions and 0 deletions

View File

@ -47,6 +47,8 @@ class TypeResolver extends RecursiveVisitor<TypeExpectation, void> {
currentColumnIndex++;
} else if (child is StarResultColumn) {
currentColumnIndex += child.scope.availableColumns.length;
} else if (child is NestedQueryColumn) {
visit(child.select, arg);
}
} else {
visit(child, arg);

View File

@ -112,6 +112,25 @@ void main() {
);
});
test('resolves columns in nested queries', () {
final engine = SqlEngine(EngineOptions(useMoorExtensions: true))
..registerTable(demoTable);
final context =
engine.analyze('SELECT content, LIST(SELECT id FROM demo) FROM demo');
expect(context.errors, isEmpty);
final select = context.root as SelectStatement;
final nestedQuery = select.columns[1] as NestedQueryColumn;
expect(nestedQuery.select.columns, hasLength(1));
expect(
context.typeOf(nestedQuery.select.resolvedColumns!.single).type!.type,
BasicType.int,
);
});
group('reports correct column name for rowid aliases', () {
final engine = SqlEngine()
..registerTable(demoTable)