mirror of https://github.com/AMT-Cheif/drift.git
Handle table aliases in moor_generator
This commit is contained in:
parent
b30c21e577
commit
04a43b36d6
|
@ -16,11 +16,21 @@ class ReferencedTablesVisitor extends RecursiveVisitor<void, void> {
|
||||||
visitChildren(e, arg);
|
visitChildren(e, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Table /*?*/ _toTableOrNull(ResolvesToResultSet resultSet) {
|
||||||
|
var resolved = resultSet.resultSet;
|
||||||
|
|
||||||
|
while (resolved != null && resolved is TableAlias) {
|
||||||
|
resolved = (resolved as TableAlias).delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
return resolved is Table ? resolved : null;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void visitQueryable(Queryable e, void arg) {
|
void visitQueryable(Queryable e, void arg) {
|
||||||
if (e is TableReference) {
|
if (e is TableReference) {
|
||||||
final resolved = e.resolved;
|
final resolved = _toTableOrNull(e.resultSet);
|
||||||
if (resolved != null && resolved is Table) {
|
if (resolved != null) {
|
||||||
foundTables.add(resolved);
|
foundTables.add(resolved);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,8 +51,8 @@ class UpdatedTablesVisitor extends ReferencedTablesVisitor {
|
||||||
final Set<Table> writtenTables = {};
|
final Set<Table> writtenTables = {};
|
||||||
|
|
||||||
void _addIfResolved(ResolvesToResultSet r) {
|
void _addIfResolved(ResolvesToResultSet r) {
|
||||||
final resolved = r.resultSet;
|
final resolved = _toTableOrNull(r);
|
||||||
if (resolved is Table) {
|
if (resolved != null) {
|
||||||
writtenTables.add(resolved);
|
writtenTables.add(resolved);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue