-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
||运算符无法设置别名OR,不设置又提示找不到运算符 #319
Comments
系统默认内置的“or”,不需要执行addOperatorWithAlias,用小写试试 String expression = "1==1 or 2==3"; |
我明白您说的,但是业务方统一规定用大写 OR |
有服务包装层吗,对外输入用“OR",传递到QL用“or” |
是的 现在就是这么处理的,但是没看懂为什么不支持大写 |
@taokan 我仔细看了下,这确实 QL3 内部的一个 bug。 将内置的 OR 节点名字改成 OR_INNER 即可 |
确实可以,需要用的时候使用runner.addOperatorWithAlias("OR", "||", null); #324 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// 设置|| 运算别名 为OR
ExpressRunner runner = new ExpressRunner();
DefaultContext<String, Object> userExpressContext = new DefaultContext<String, Object>();
runner.addOperatorWithAlias("OR", "||", null);
String expression = "1==1 OR 2==3";
//执行表达式
Object execute = runner.execute(expression, userExpressContext, null, false, true);
错误信息
Exception in thread "main" java.lang.RuntimeException: 节点类型定义重复:OR 定义1=OR:TYPE=WORDDEF,DEFINE=|| 定义2=OR:TYPE=KEYWORD,REAL=||
at com.ql.util.express.parse.NodeTypeManager.createNodeType(NodeTypeManager.java:92)
at com.ql.util.express.parse.NodeTypeManager.addOperatorWithRealNodeType(NodeTypeManager.java:121)
at com.ql.util.express.ExpressRunner.addOperatorWithAlias(ExpressRunner.java:450)
//不设置别名
ExpressRunner runner = new ExpressRunner();
DefaultContext<String, Object> userExpressContext = new DefaultContext<String, Object>();
String expression = "1==1 OR 2==3";
//执行表达式
Object execute = runner.execute(expression, userExpressContext, null, false, true);
错误信息
Exception in thread "main" java.lang.Exception: 程序错误,不满足语法规范,没有匹配到合适的语法,最大匹配致[0:2]
at com.ql.util.express.match.QLPattern.findMatchStatement(QLPattern.java:21)
at com.ql.util.express.parse.ExpressParse.parse(ExpressParse.java:343)
at com.ql.util.express.parse.ExpressParse.parse(ExpressParse.java:310)
at com.ql.util.express.ExpressRunner.parseInstructionSet(ExpressRunner.java:656)
at com.ql.util.express.ExpressRunner.execute(ExpressRunner.java:568)
at com.ql.util.express.ExpressRunner.execute(ExpressRunner.java:538)
如果想给|| 设置别名OR该如何操作呢?
The text was updated successfully, but these errors were encountered: