mirror of https://github.com/AMT-Cheif/drift.git
Refactor `TypeResolver.visitMultiColumnSetComponent`
This commit is contained in:
parent
ff11a2a757
commit
6810cfc52d
|
@ -142,15 +142,20 @@ class TypeResolver extends RecursiveVisitor<TypeExpectation, void> {
|
|||
void visitMultiColumnSetComponent(
|
||||
MultiColumnSetComponent e, TypeExpectation arg) {
|
||||
visitList(e.columns, const NoTypeExpectation());
|
||||
if (e.rowValue is Tuple) {
|
||||
final expressions = (e.rowValue as Tuple).expressions;
|
||||
for (final (idx, expression) in expressions.indexed) {
|
||||
_lazyCopy(expression, e.columns.elementAtOrNull(idx));
|
||||
}
|
||||
} else if (e.rowValue is SubQuery) {
|
||||
// TODO: handle subquery case
|
||||
|
||||
final targets = e.resolvedTargetColumns ?? const [];
|
||||
for (final column in targets) {
|
||||
_handleColumn(column, e);
|
||||
}
|
||||
visit(e.rowValue, const NoTypeExpectation());
|
||||
|
||||
final expectations = targets.map((r) {
|
||||
if (r != null && session.graph.knowsType(r)) {
|
||||
return ExactTypeExpectation(session.typeOf(r)!);
|
||||
}
|
||||
return const NoTypeExpectation();
|
||||
}).toList();
|
||||
|
||||
visit(e.rowValue, SelectTypeExpectation(expectations));
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -112,6 +112,11 @@ class MultiColumnSetComponent extends SetComponent {
|
|||
// Will be either Tuple or SubQuery
|
||||
Expression rowValue;
|
||||
|
||||
List<Column?>? get resolvedTargetColumns {
|
||||
if (columns.isEmpty) return null;
|
||||
return columns.map((c) => c.resolvedColumn).toList();
|
||||
}
|
||||
|
||||
MultiColumnSetComponent({required this.columns, required this.rowValue});
|
||||
|
||||
@override
|
||||
|
|
Loading…
Reference in New Issue