[
https://issues.redhat.com/browse/DROOLS-5652?page=com.atlassian.jira.plug...
]
Toshiya Kobayashi updated DROOLS-5652:
--------------------------------------
Description:
String relational comparison fails with executable-model
{noformat}
Person( name > "Bob" )
{noformat}
generates Predicate like this:
{code:java}
@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");
}
}
{code}
then, fails with this error:
{noformat}
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
{noformat}
FYI) It should be supported
https://docs.jboss.org/drools/release/latest/drools-docs/html_single/inde...
{noformat}
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 )
{noformat}
was:
String relational comparison fails with executable-model
{noformat}
Person( name > "Bob" )
{noformat}
generates Predicate like this:
{code:java}
@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");
}
}
{code}
then, fails with this error:
{noformat}
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
{noformat}
String relational comparison fails with executable-model
--------------------------------------------------------
Key: DROOLS-5652
URL:
https://issues.redhat.com/browse/DROOLS-5652
Project: Drools
Issue Type: Bug
Components: executable model
Affects Versions: 7.43.1.Final
Reporter: Toshiya Kobayashi
Assignee: Toshiya Kobayashi
Priority: Major
String relational comparison fails with executable-model
{noformat}
Person( name > "Bob" )
{noformat}
generates Predicate like this:
{code:java}
@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");
}
}
{code}
then, fails with this error:
{noformat}
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
{noformat}
FYI) It should be supported
https://docs.jboss.org/drools/release/latest/drools-docs/html_single/inde...
{noformat}
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 )
{noformat}
--
This message was sent by Atlassian Jira
(v7.13.8#713008)