Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-5652

String relational comparison fails with executable-model

    Details

    • Sprint:
      2020 Week 37-39 (from Sep 7)
    • Story Points:
      3
    • Steps to Reproduce:
      • See unit test PR
    • Docs QE Status:
      NEW
    • QE Status:
      NEW

      Description

      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 )
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                tkobayashi Toshiya Kobayashi
                Reporter:
                tkobayashi Toshiya Kobayashi
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: