use of com.developmentontheedge.sql.model.AstColumnList in project be5 by DevelopmentOnTheEdge.
the class SqlServerTransformer method transformLeastGreatest.
@Override
protected void transformLeastGreatest(AstFunNode node) {
String name = node.getFunction().getName();
AstIdentifierConstant v = new AstIdentifierConstant("V");
Function func;
if ("LEAST".equals(name))
func = parserContext.getFunction("min");
else
func = parserContext.getFunction("max");
AstValues values = new AstValues(0);
for (SimpleNode child : node.children()) values.addChild(new AstParenthesis(child));
AstTableRef tableRef = new AstTableRef(new AstParenthesis(values), new AstIdentifierConstant(name), new AstColumnList(v));
node.replaceWith(new AstParenthesis(new AstSelect(new AstSelectList(func.node(v)), new AstFrom(tableRef))));
}
Aggregations