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

OOPath Rule requires a variable binding

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not a Bug
    • Major
    • None
    • 8.37.0.Final
    • core engine
    • None
    • 2023 Week 18-20 (from May 1)
    • Hide

      Clone into https://github.com/code4dc/kogito-examples/tree/oopath-var-binding-required/kogito-springboot-examples/ruleunit-springboot-example

      and run `mvn clean install`.

      If you add a binding to line 23 of RuleUnitQuery.drl the error goes away.

      Show
      Clone into https://github.com/code4dc/kogito-examples/tree/oopath-var-binding-required/kogito-springboot-examples/ruleunit-springboot-example and run `mvn clean install`. If you add a binding to line 23 of RuleUnitQuery.drl the error goes away.
    • Workaround Exists
    • Hide

      Add a superfluous binding to avoid error.

      Show
      Add a superfluous binding to avoid error.
    • NEW
    • NEW
    • ---
    • ---

    Description

      When using OOPath notation for rules some lines in the LHS require a variable binding even if the variable is not needed.

      The following rule will throw an error

      rule SmallDepositApprove when
          $l: /loanApplications[ applicant.age >= 20, deposit < 1000, amount <= 2000 ]
          /objects/objectB [value == "TEST"]
      then
          modify($l) { setApproved(true) };
      end
      

      The error:

      Exception in thread "main" org.drools.model.codegen.project.RuleCodegenError: Errors were generated during the code-generation process:
      InvalidExpressionErrorResult: Unable to parse left part of expression: $l: /objects/objectB[ value == "TEST" ]
              at org.drools.model.codegen.project.DroolsModelBuilder.build(DroolsModelBuilder.java:129)
              at org.kie.kogito.codegen.rules.RuleCodegen.internalGenerate(RuleCodegen.java:113)
      

      Attachments

        Activity

          People

            mfusco@redhat.com Mario Fusco
            code4dc@gmail.com Eugene Shvartsman (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: