}
}
protected boolean toStringSelectStatement(AbstractSelectStatementStateObject stateObject) {
AbstractSelectStatement expression = stateObject.getExpression();
boolean spaceAdded = false;
// SELECT clause
stateObject.getSelectClause().accept(this);
// If no select items were parsed but they got added later, make sure a space is added
if (shouldOutput(expression) ||
expression.hasSpaceAfterSelect() ||
// TODO
(/*!expression.getSelectClause().hasSelectExpression() &&*/
stateObject.getSelectClause().hasSelectItem())) {
writer.append(SPACE);
}
// FROM clause
stateObject.getFromClause().accept(this);
// If no WHERE clause was parsed but was added later, make sure a space is added
if (exactMatch && (expression != null) && expression.hasSpaceAfterFrom() ||
stateObject.hasWhereClause()) {
writer.append(SPACE);
spaceAdded = true;
}
// WHERE clause
if (stateObject.hasWhereClause()) {
stateObject.getWhereClause().accept(this);
spaceAdded = false;
}
// If no GROUP BY clause was parsed but was added later, make sure a space is added
if (exactMatch && (expression != null) && expression.hasSpaceAfterWhere() ||
stateObject.hasGroupByClause()) {
if (!spaceAdded) {
writer.append(SPACE);
spaceAdded = true;
}
}
// GROUP BY clause
if (stateObject.hasGroupByClause()) {
stateObject.getGroupByClause().accept(this);
spaceAdded = false;
}
// If no HAVING clause was parsed but was added later, make sure a space is added
if (exactMatch && (expression != null) && expression.hasSpaceAfterGroupBy() ||
stateObject.hasHavingClause()) {
if (!spaceAdded) {
writer.append(SPACE);
spaceAdded = true;