IDEMPIERE-4177 Replace SYSDATE with getDate(). Add SYSDATE to getDate() translation for native dialect. Still needed as there are still many usage of SYSDATE in the Application Dictionary.

This commit is contained in:
hengsin 2020-03-03 16:25:54 +08:00
parent df5b0c2ea8
commit 26e764c2a2
1 changed files with 17 additions and 0 deletions

View File

@ -53,6 +53,8 @@ public class Convert_PostgreSQL extends Convert_SQL92 {
private final static Pattern likePattern = Pattern.compile("\\bLIKE\\b", REGEX_FLAGS);
private final static Pattern sysDatePattern = Pattern.compile("\\bSYSDATE\\b", REGEX_FLAGS);
/**
* Is Oracle DB
*
@ -77,6 +79,7 @@ public class Convert_PostgreSQL extends Convert_SQL92 {
protected ArrayList<String> convertStatement(String sqlStatement) {
ArrayList<String> result = new ArrayList<String>();
if (DB_PostgreSQL.isUseNativeDialect()) {
sqlStatement = convertSysDate(sqlStatement);
sqlStatement = convertSimilarTo(sqlStatement);
result.add(sqlStatement);
return result;
@ -131,6 +134,20 @@ public class Convert_PostgreSQL extends Convert_SQL92 {
return result;
} // convertStatement
private String convertSysDate(String statement) {
String retValue = statement;
String replacement = "getDate()";
try {
Matcher m = sysDatePattern.matcher(retValue);
retValue = m.replaceAll(replacement);
} catch (Exception e) {
String error = "Error expression: " + sysDatePattern.pattern() + " - " + e;
log.info(error);
m_conversionError = error;
}
return retValue;
}
private String convertSimilarTo(String statement) {
String retValue = statement;
boolean useSimilarTo = isUseSimilarTo();