part of '../ast.dart'; class SelectStatement extends Statement with ResultSet { final bool distinct; final List columns; final List from; final Expression where; final GroupBy groupBy; final OrderBy orderBy; final Limit limit; /// The resolved list of columns returned by this select statements. Not /// available from the parse tree, will be set later by the analyzer. @override List resolvedColumns; SelectStatement( {this.distinct = false, this.columns, this.from, this.where, this.groupBy, this.orderBy, this.limit}); @override T accept(AstVisitor visitor) { return visitor.visitSelectStatement(this); } @override Iterable get childNodes { return [ if (where != null) where, ...columns, if (from != null) ...from, if (limit != null) limit, if (orderBy != null) orderBy, ]; } @override bool contentEquals(SelectStatement other) { return other.distinct == distinct; } } abstract class ResultColumn extends AstNode { @override T accept(AstVisitor visitor) => visitor.visitResultColumn(this); } /// A result column that either yields all columns or all columns from a table /// by using "*" or "table.*". class StarResultColumn extends ResultColumn { final String tableName; StarResultColumn(this.tableName); @override Iterable get childNodes => const []; @override bool contentEquals(StarResultColumn other) { return other.tableName == tableName; } } class ExpressionResultColumn extends ResultColumn implements Renamable, Referencable { final Expression expression; @override final String as; ExpressionResultColumn({@required this.expression, this.as}); @override Iterable get childNodes => [expression]; @override bool contentEquals(ExpressionResultColumn other) { return other.as == as; } } class GroupBy extends AstNode { /// The list of expressions that form the partition final List by; final Expression having; GroupBy({@required this.by, this.having}); @override T accept(AstVisitor visitor) => visitor.visitGroupBy(this); @override Iterable get childNodes => [...by, if (having != null) having]; @override bool contentEquals(GroupBy other) { return true; // Defined via child nodes } }