-
Bug
-
Resolution: Done
-
Major
-
7.43.1.Final
-
None
-
2020 Week 37-39 (from Sep 7)
-
3
-
- See unit test PR
-
Undefined
-
NEW
-
NEW
-
---
-
---
String relational comparison fails with executable-model
Person( name > "Bob" )
generates Predicate like this:
@org.drools.compiler.kie.builder.MaterializedLambda() public enum LambdaPredicate23581163B2FDAA9B650DDB3B8C587DE2 implements org.drools.model.functions.Predicate1<org.drools.modelcompiler.domain.Person> { ... @Override() public boolean test(org.drools.modelcompiler.domain.Person _this) throws java.lang.Exception { return org.drools.modelcompiler.util.EvaluationUtil.greaterThanStringsAsNumbers(_this.getName(), "Bob"); } }
then, fails with this error:
java.lang.RuntimeException: java.lang.NumberFormatException: Character J is neither a decimal digit number, decimal point, nor "e" notation exponential mark. at org.drools.modelcompiler.constraints.ConstraintEvaluator.evaluate(ConstraintEvaluator.java:95) at org.drools.modelcompiler.constraints.LambdaConstraint.isAllowed(LambdaConstraint.java:133) at org.drools.core.reteoo.AlphaNode.assertObject(AlphaNode.java:136) ... Caused by: java.lang.NumberFormatException: Character J is neither a decimal digit number, decimal point, nor "e" notation exponential mark. at java.base/java.math.BigDecimal.<init>(BigDecimal.java:518) at java.base/java.math.BigDecimal.<init>(BigDecimal.java:401) at java.base/java.math.BigDecimal.<init>(BigDecimal.java:834) at org.drools.modelcompiler.util.EvaluationUtil.greaterThanStringsAsNumbers(EvaluationUtil.java:113) at defaultpkg.P23.LambdaPredicate23581163B2FDAA9B650DDB3B8C587DE2.test(LambdaPredicate23581163B2FDAA9B650DDB3B8C587DE2.java:17) at defaultpkg.P23.LambdaPredicate23581163B2FDAA9B650DDB3B8C587DE2.test(LambdaPredicate23581163B2FDAA9B650DDB3B8C587DE2.java:8) at org.drools.model.functions.Predicate1$Impl.test(Predicate1.java:39) at org.drools.modelcompiler.constraints.ConstraintEvaluator.evaluate(ConstraintEvaluator.java:92) ... 48 more
FYI) It should be supported
https://docs.jboss.org/drools/release/latest/drools-docs/html_single/index.html#drl-operators-ref_drl-rules
4.1.8.6. Supported operators in DRL pattern constraints <, <=, >, >= Use these operators on properties with natural ordering. For example, for Date fields, the < operator means before, and for String fields, the operator means alphabetically before. These properties apply only to comparable properties. Example constraints with before operator Person( birthDate < $otherBirthDate ) Person( firstName < $otherFirstName )