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

"and exists" used in source-pattern part of accumulate statement matches multiple times in executable model.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • None
    • None
    • executable model
    • 2020 Week 52-03 (from Dec 21)
    • Hide
      1. Extract reproducer.
        $ unzip reproducer_model_compiler_16a.zip
        $ cd reproducer_model_compiler_16a
        
      2. Build and execute the rule.
        $ ./run_mvn    # mvn clean compile exec:exec -DgenerateModel=YES
            :
            :
        ***** start
        ***** Action of rule16a2 -- $list = [com.example.reproducer.Car@410ae9a3, com.example.reproducer.Car@410ae9a3, com.example.reproducer.Car@410ae9a3]
        ***** end
            :
            :
        

      Expected behavior: the size of $list is 1.

      Actual behavior: the size of $list is 3.

      Show
      Extract reproducer. $ unzip reproducer_model_compiler_16a.zip $ cd reproducer_model_compiler_16a Build and execute the rule. $ ./run_mvn # mvn clean compile exec:exec -DgenerateModel=YES : : ***** start ***** Action of rule16a2 -- $list = [com.example.reproducer.Car@410ae9a3, com.example.reproducer.Car@410ae9a3, com.example.reproducer.Car@410ae9a3] ***** end : : Expected behavior: the size of $list is 1. Actual behavior: the size of $list is 3.
    • Undefined
    • NEW
    • NEW
    • ---
    • ---

    Description

      When executing a rule like (*1) that uses and exists in source-pattern part of accumulate statement like (*1-1) in executable model, the sub-pattern given by and exists matches multiple times. For example in rule (*1), we insert 1 Car object and 3 InspectionResult objects with the same value of number property as the Car object, the source-pattern in the accumulate statement matches 3 times. In this case, it should match only once.

      (*1)

      package com.example.reproducer
      
      import java.util.List
      
      dialect "java"
      
      rule "rule16a2"
          when
              $list : List() from accumulate ( $car : Car( $number : number )
                                               and exists InspectionResult( number == $number );    // ..... (*1-1)
                                               collectList($car) )
          then
              System.out.println("***** Action of rule16a2 -- $list = " + $list);
      end
      

      Attachments

        Issue Links

          Activity

            People

              mfusco@redhat.com Mario Fusco
              mfusco@redhat.com Mario Fusco
              Daniel Rosa Daniel Rosa
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: