use of org.apache.cayenne.dba.firebird.sqltree.FirebirdSubstringFunctionNode in project cayenne by apache.
the class FirebirdSQLTreeProcessor method onFunctionNode.
@Override
protected void onFunctionNode(Node parent, FunctionNode child, int index) {
switch(child.getFunctionName()) {
case "LENGTH":
replaceChild(parent, index, new FunctionNode("CHAR_LENGTH", child.getAlias()));
break;
case "LOCATE":
replaceChild(parent, index, new FunctionNode("POSITION", child.getAlias()));
break;
case "CONCAT":
replaceChild(parent, index, new OpExpressionNode("||"));
break;
case "SUBSTRING":
replaceChild(parent, index, new FirebirdSubstringFunctionNode(child.getAlias()));
break;
case "YEAR":
case "MONTH":
case "DAY":
case "DAY_OF_MONTH":
case "DAY_OF_WEEK":
case "DAY_OF_YEAR":
case "WEEK":
case "HOUR":
case "MINUTE":
case "SECOND":
Node functionReplacement = new FunctionNode("EXTRACT", child.getAlias(), true) {
@Override
public void appendChildrenSeparator(QuotingAppendable buffer, int childIdx) {
buffer.append(' ');
}
};
String partName = child.getFunctionName();
if ("DAY_OF_MONTH".equals(partName)) {
partName = "DAY";
} else if ("DAY_OF_WEEK".equals(partName)) {
partName = "WEEKDAY";
} else if ("DAY_OF_YEAR".equals(partName)) {
partName = "YEARDAY";
}
functionReplacement.addChild(new TextNode(partName + " FROM "));
replaceChild(parent, index, functionReplacement);
break;
}
}
Aggregations