use of com.developmentontheedge.sql.model.AstNullPredicate in project be5 by DevelopmentOnTheEdge.
the class MySqlTransformer method transformDecode.
@Override
protected void transformDecode(AstFunNode node) {
AstCase astCase = new AstCase();
for (int i = 1; i < node.jjtGetNumChildren() - 1; i++) {
SimpleNode cond;
if (node.child(i) instanceof AstSpecialConstant) {
cond = new AstNullPredicate(0);
cond.addChild(node.child(0));
} else {
cond = DefaultParserContext.FUNC_EQ.node(node.child(0), node.child(i));
}
astCase.addChild(new AstWhen(cond, node.child(++i)));
if (i == node.jjtGetNumChildren() - 2) {
astCase.addChild(new AstCaseElse(node.child(++i)));
}
}
node.replaceWith(astCase);
}
use of com.developmentontheedge.sql.model.AstNullPredicate in project be5 by DevelopmentOnTheEdge.
the class PostgreSqlTransformer method transformDecode.
@Override
protected void transformDecode(AstFunNode node) {
AstCase astCase = new AstCase();
for (int i = 1; i < node.jjtGetNumChildren() - 1; i++) {
SimpleNode cond;
if (node.child(i) instanceof AstSpecialConstant) {
cond = new AstNullPredicate(0);
cond.addChild(node.child(0));
} else {
cond = DefaultParserContext.FUNC_EQ.node(node.child(0), node.child(i));
}
astCase.addChild(new AstWhen(cond, node.child(++i)));
if (i == node.jjtGetNumChildren() - 2) {
astCase.addChild(new AstCaseElse(node.child(++i)));
}
}
node.replaceWith(astCase);
}
use of com.developmentontheedge.sql.model.AstNullPredicate in project be5 by DevelopmentOnTheEdge.
the class SqlServerTransformer method transformDecode.
@Override
protected void transformDecode(AstFunNode node) {
AstCase astCase = new AstCase();
for (int i = 1; i < node.jjtGetNumChildren() - 1; i++) {
SimpleNode cond;
if (node.child(i) instanceof AstSpecialConstant) {
cond = new AstNullPredicate(0);
cond.addChild(node.child(0));
} else {
cond = DefaultParserContext.FUNC_EQ.node(node.child(0), node.child(i));
}
astCase.addChild(new AstWhen(cond, node.child(++i)));
if (i == node.jjtGetNumChildren() - 2) {
astCase.addChild(new AstCaseElse(node.child(++i)));
}
}
node.replaceWith(astCase);
}
Aggregations