parseSelectedColumns function

List<SelectedColumn> parseSelectedColumns(
  1. String selectClause
)

Converts the selected columns part of a SelectStatement to a list of SelectedColumn objects.

Implementation

List<SelectedColumn> parseSelectedColumns(String selectClause) {
  final columns = selectClause.split(',').map((col) => col.trim()).toList();
  return columns.map((col) {
    if (col == '*') {
      return AllColumns();
    } else if (col.contains('.')) {
      final parts = col.split('.');
      return ColumnReference(parts[1], tableName: parts[0]);
    } else {
      return ColumnReference(col);
    }
  }).toList();
}