Closed sunxien closed 11 months ago
<dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.2.20</version> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.20</version>
</dependency>
{ String sql = "upper('abc')"; Object val = SQLEvalVisitorUtils.evalExpr(DbType.mysql, sql); System.out.println(sql + ": " + val); } { String sql = "concat('abc','b')"; Object val = SQLEvalVisitorUtils.evalExpr(DbType.mysql, sql); System.out.println(sql + ": " + val); } { // SQL: select replace('abc','b','B') from dual; // FIXME: Found a bug when eval replace function like below: String sql = "replace('abc','b','B')"; Object val = SQLEvalVisitorUtils.evalExpr(DbType.mysql, sql); System.out.println(sql + ": " + val); }
{
String sql = "upper('abc')";
Object val = SQLEvalVisitorUtils.evalExpr(DbType.mysql, sql);
System.out.println(sql + ": " + val);
}
String sql = "concat('abc','b')";
// SQL: select replace('abc','b','B') from dual;
// FIXME: Found a bug when eval replace function like below:
String sql = "replace('abc','b','B')";
加上支持了,等1.2.21版本出来之后验证。
Dependency in pom.xml
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.20</version>
</dependency>
Java example code
{
String sql = "upper('abc')";
Object val = SQLEvalVisitorUtils.evalExpr(DbType.mysql, sql);
System.out.println(sql + ": " + val);
}
{
String sql = "concat('abc','b')";
Object val = SQLEvalVisitorUtils.evalExpr(DbType.mysql, sql);
System.out.println(sql + ": " + val);
}
{
// SQL: select replace('abc','b','B') from dual;
// FIXME: Found a bug when eval replace function like below:
String sql = "replace('abc','b','B')";
Object val = SQLEvalVisitorUtils.evalExpr(DbType.mysql, sql);
System.out.println(sql + ": " + val);
}
Run example code