davsclaus commented on code in PR #26560:
URL: https://github.com/apache/camel/pull/26560#discussion_r4039626829


##########
components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/ParserTest.java:
##########
@@ -112,6 +112,29 @@ public void nestedSimpleExpression() {
         assertEquals(3, ((InParameter) 
template.getParameterList().get(1)).getValueExtractor().eval(exchange, null));
     }
 
+    @Test
+    public void simpleFunctionWithParentheses() {
+        Exchange exchange = createExchangeWithBody(42);
+        exchange.getIn().setHeader("bar", 3);
+        Template template = parser.parseTemplate(
+                "ADDNUMBERS2(INTEGER ${val(1)},VARCHAR ${bodyAs(String)},INOUT 
INTEGER ${val(7)} inout1,OUT INTEGER out1)");
+
+        assertEquals(4, template.getParameterList().size());
+        assertEquals("1", ((InParameter) 
template.getParameterList().get(0)).getValueExtractor().eval(exchange, null));
+        assertEquals("42", ((InParameter) 
template.getParameterList().get(1)).getValueExtractor().eval(exchange, null));
+        assertEquals("7", ((InOutParameter) 
template.getParameterList().get(2)).getValueExtractor().eval(exchange, null));
+        assertEquals("out1", ((OutParameter) 
template.getParameterList().get(3)).getOutValueMapKey());
+    }
+
+    @Test
+    public void simpleFunctionAsLastParameter() {
+        // the closing parenthesis of the function must not be confused with 
the end of the procedure
+        Exchange exchange = createExchangeWithBody(1);
+        Template template = parser.parseTemplate("ADDNUMBERS2(INTEGER 
${val(1)} )");
+        assertEquals(1, template.getParameterList().size());
+        assertEquals("1", ((InParameter) 
template.getParameterList().get(0)).getValueExtractor().eval(exchange, null));
+    }
+
     @Test

Review Comment:
   Added `multiArgFunctionShouldFail` in 64d783733aeb: `ADDNUMBERS2(VARCHAR 
${replace(a,b)})` is asserted to throw `ParseRuntimeException`, pinning the 
documented limitation.
   
   _Claude Code on behalf of davsclaus_



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to