alibaba / druid

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

SQLEvalVisitorUtils.evalExpr could not support not operator. V1.1.21 #3563

Open michael-oou opened 4 years ago

michael-oou commented 4 years ago

I run the method below: SQLEvalVisitorUtils.evalExpr(JdbcConstants.H2, "? = 'druid' and not (? = '5' or ? = '3')", "druid", "5","0")

it throws Exception: Exception in thread "main" com.alibaba.druid.DruidRuntimeException: eval error : ? = 'druid' AND NOT (? = '5' OR ? = '3') at com.alibaba.druid.sql.visitor.SQLEvalVisitorUtils.eval(SQLEvalVisitorUtils.java:154) at com.alibaba.druid.sql.visitor.SQLEvalVisitorUtils.eval(SQLEvalVisitorUtils.java:137) at com.alibaba.druid.sql.visitor.SQLEvalVisitorUtils.eval(SQLEvalVisitorUtils.java:119) at com.alibaba.druid.sql.visitor.SQLEvalVisitorUtils.evalExpr(SQLEvalVisitorUtils.java:110) at com.webank.ims.seckill.SqlParseDemo.main(SqlParseDemo.java:76)

Then, i use ! instead of not. it works : SQLEvalVisitorUtils.evalExpr(JdbcConstants.H2, "? = 'druid' and ! (? = '5' or ? = '3')", "druid", "5","0")

hope to fix the bug. :-)

ijarobot commented 4 years ago

good issue