Skip to content
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

表达式计算不支持单字符类型比较 #20

Closed
ccqy66 opened this issue May 9, 2018 · 1 comment
Closed

表达式计算不支持单字符类型比较 #20

ccqy66 opened this issue May 9, 2018 · 1 comment

Comments

@ccqy66
Copy link

ccqy66 commented May 9, 2018

例如,如下测试:

@Test
public void testCharcharComapre() throws Exception {
	ExpressRunner runner = new ExpressRunner();
	String express = "'a'=='a' && '9.2'>='9.2' && '2018-05-09 17:47:31'>='2018-05-09 17:47:30'";
	Boolean r = (Boolean) runner.execute(express, null, null, true, false);
	assert r == true;
}

执行报以下错误:

java.lang.Exception: run QlExpress Exception at line 1 :

	at com.ql.util.express.instruction.detail.InstructionOperator.execute(InstructionOperator.java:48)
	at com.ql.util.express.InstructionSet.executeInnerOrigiInstruction(InstructionSet.java:204)
	at com.ql.util.express.InstructionSet.excute(InstructionSet.java:170)
	at com.ql.util.express.InstructionSetRunner.execute(InstructionSetRunner.java:59)
	at com.ql.util.express.InstructionSetRunner.execute(InstructionSetRunner.java:46)
	at com.ql.util.express.InstructionSetRunner.executeOuter(InstructionSetRunner.java:18)
	at com.ql.util.express.ExpressRunner.execute(ExpressRunner.java:570)
	at com.ql.util.express.ExpressRunner.execute(ExpressRunner.java:538)
	at com.ql.util.express.example.OperatorTest.testCharcharComapre(OperatorTest.java:93)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
	at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
	at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
	at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
	at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
	at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
	at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
	at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
	at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
	at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:130)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.Exception: aa不能执行compare 操作
	at com.ql.util.express.Operator.compareData(Operator.java:66)
	at com.ql.util.express.instruction.op.OperatorEqualsLessMore.executeInner(OperatorEqualsLessMore.java:50)
	at com.ql.util.express.instruction.op.OperatorEqualsLessMore.executeInner(OperatorEqualsLessMore.java:25)
	at com.ql.util.express.instruction.op.OperatorEqualsLessMore.executeInner(OperatorEqualsLessMore.java:21)
	at com.ql.util.express.Operator.executeInner(Operator.java:20)
	at com.ql.util.express.instruction.op.OperatorBase.execute(OperatorBase.java:67)
	at com.ql.util.express.instruction.detail.InstructionOperator.execute(InstructionOperator.java:44)
	... 29 more
@baoxingjie
Copy link
Contributor

多谢发现问题,目前已经解决问题,请查看单元测试 https://github.com/alibaba/QLExpress/blob/master/src/test/java/com/ql/util/express/bugfix/CompareObjectTest.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants