visitColumnDefinition method

  1. @override
void visitColumnDefinition(
  1. ColumnDefinition e,
  2. TypeExpectation arg
)
override

Implementation

@override
void visitColumnDefinition(ColumnDefinition e, TypeExpectation arg) {
  // If we're analyzing a `CREATE TABLE` statement, we might know this colum's
  // type.
  final createTable = e.parent;
  if (createTable is CreateTableStatement) {
    final resolvedTable =
        session.context.rootScope.knownTables[createTable.tableName];
    final resolvedColumn = resolvedTable?.findColumn(e.columnName);

    if (resolvedColumn is ColumnWithType) {
      final type = resolvedColumn.type;

      if (type != null) {
        // Make sure we have compatible types in the constraints
        visitList(e.constraints, ExactTypeExpectation(type));
        return;
      }
    }
  }

  super.visitColumnDefinition(e, arg);
}