mirror of https://github.com/AMT-Cheif/drift.git
Correctly find references to aliased columns
This commit is contained in:
parent
82f84732d0
commit
6c84013cfa
|
@ -83,8 +83,12 @@ class ColumnResolver extends RecursiveVisitor<void> {
|
|||
final column =
|
||||
ExpressionColumn(name: name, expression: resultColumn.expression);
|
||||
|
||||
availableColumns.add(column);
|
||||
usedColumns.add(column);
|
||||
|
||||
// make this column available if there is no other with the same name
|
||||
if (!availableColumns.any((c) => c.name == name)) {
|
||||
availableColumns.add(column);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,4 +58,13 @@ void main() {
|
|||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('resolves sub-queries', () {
|
||||
final engine = SqlEngine()..registerTable(demoTable);
|
||||
|
||||
final context = engine.analyze(
|
||||
'SELECT d.*, (SELECT id FROM demo WHERE id = d.id) FROM demo d;');
|
||||
|
||||
expect(context.errors, isEmpty);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue