alibaba / druid

阿里云计算平台DataWorks(https://help.aliyun.com/document_detail/137663.html) 团队出品,为监控而生的数据库连接池
https://github.com/alibaba/druid/wiki
Apache License 2.0
27.97k stars 8.58k forks source link

why `replace` sql built-in function does’t work ? #5477

Closed sunxien closed 11 months ago

sunxien commented 1 year ago

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

image

lizongbo commented 11 months ago

加上支持了,等1.2.21版本出来之后验证。