You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "yesamer (via GitHub)" <gi...@apache.org> on 2024/03/05 11:26:28 UTC

Re: [PR] [kie-issues#969]: Negated value in accumulate function ends with Invalid expression error [incubator-kie-drools]

yesamer commented on code in PR #5762:
URL: https://github.com/apache/incubator-kie-drools/pull/5762#discussion_r1512664929


##########
drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/visitor/accumulate/AccumulateVisitor.java:
##########
@@ -406,10 +414,10 @@ private boolean parameterNeedsConvertionToMethodCallExpr(Expression accumulateFu
         return accumulateFunctionParameter.isMethodCallExpr() || accumulateFunctionParameter.isArrayAccessExpr() || accumulateFunctionParameter.isFieldAccessExpr();
     }
 
-    private Optional<NewBinding> binaryExprParameter(PatternDescr basePattern, AccumulateDescr.AccumulateFunctionCallDescr function, MethodCallExpr functionDSL, String bindingId, String accumulateFunctionParameterStr) {
+    private Optional<NewBinding> binaryOrUnaryExprParameter(PatternDescr basePattern, AccumulateDescr.AccumulateFunctionCallDescr function, MethodCallExpr functionDSL, String bindingId, String accumulateFunctionParameterStr) {

Review Comment:
   Thank you, done!



##########
drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/AccumulateTest.java:
##########
@@ -4204,4 +4206,80 @@ public void testJoinInAccumulate() {
         assertThat(results.size()).isEqualTo(2);
         assertThat(results).containsExactlyInAnyOrder(new Result(0), new Result(75));
     }
+
+    @Test
+    public void testAccumulateSumMultipleParametersExpression() {
+        String str =
+                "import " + Person.class.getCanonicalName() + ";" +
+                "import " + Result.class.getCanonicalName() + ";" +
+                "rule X when\n" +
+                "  accumulate ( $i : Integer() and $p: Person ( name.length >= $i ); \n" +
+                "                $sum : sum($p.getAge(), $p.getName())  \n" +
+                "              )                          \n" +
+                "then\n" +
+                "  insert(new Result($sum));\n" +
+                "end";
+
+        Results results = createKieBuilder(str).getResults();
+        if (testRunType.isExecutableModel()) {
+            System.out.println(results.getMessages(Message.Level.ERROR).get(0).getText());

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org