mirror of https://github.com/AMT-Cheif/drift.git
Resolve CTEs for compound selects
This commit is contained in:
parent
81315c3d69
commit
c700b5b4be
|
@ -1,3 +1,7 @@
|
|||
## 0.30.3
|
||||
|
||||
- Fix `WITH` clauses not being resolved for compound select statements.
|
||||
|
||||
## 0.30.2
|
||||
|
||||
- Fix false-positive "unknown table" errors when the same table is used in a
|
||||
|
|
|
@ -58,6 +58,7 @@ class ColumnResolver extends RecursiveVisitor<ColumnResolverContext, void> {
|
|||
@override
|
||||
void visitCompoundSelectStatement(
|
||||
CompoundSelectStatement e, ColumnResolverContext arg) {
|
||||
e.withClause?.accept(this, arg);
|
||||
e.base.accept(this, arg);
|
||||
visitList(e.additional, arg);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: sqlparser
|
||||
description: Parses sqlite statements and performs static analysis on them
|
||||
version: 0.30.2
|
||||
version: 0.30.3
|
||||
homepage: https://github.com/simolus3/drift/tree/develop/sqlparser
|
||||
repository: https://github.com/simolus3/drift
|
||||
#homepage: https://drift.simonbinder.eu/
|
||||
|
|
|
@ -218,4 +218,27 @@ WHERE EXISTS(SELECT *
|
|||
|
||||
expect(result.errors, isEmpty);
|
||||
});
|
||||
|
||||
test('regression test for #2492', () {
|
||||
// https://github.com/simolus3/drift/issues/2492
|
||||
final engine = SqlEngine()
|
||||
..registerTableFromSql(
|
||||
'CREATE TABLE items (id INT NOT NULL PRIMARY KEY)');
|
||||
|
||||
final result = engine.analyze('''
|
||||
WITH filtered_items AS (
|
||||
SELECT *
|
||||
FROM items
|
||||
-- WHERE ...
|
||||
)
|
||||
select null as category
|
||||
FROM filtered_items
|
||||
UNION ALL
|
||||
SELECT null as category
|
||||
FROM filtered_items;
|
||||
''');
|
||||
|
||||
final select = result.root as BaseSelectStatement;
|
||||
expect(select.resolvedColumns, hasLength(1));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue