Mule
  1. Mule
  2. MULE-3496

Expressions in JDBC Queries are not evaluated

    Details

    • Type: Patch submission Patch submission
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Incomplete
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.0.x Backlog
    • Component/s: Transport: JDBC
    • Labels:
      None
    • Includes test case?:
      no
    • User impact:
      High
    • Configuration:
      Hide
      <?xml version="1.0" encoding="UTF-8"?>
      <mule xmlns="http://www.mulesource.org/schema/mule/core/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      	xmlns:spring="http://www.springframework.org/schema/beans" xmlns:vm="http://www.mulesource.org/schema/mule/vm/2.0"
      	xmlns:stdio="http://www.mulesource.org/schema/mule/stdio/2.0"
      	xmlns:jdbc="http://www.mulesource.org/schema/mule/jdbc/2.0"
      	xsi:schemaLocation="
                     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                     http://www.mulesource.org/schema/mule/core/2.0 http://www.mulesource.org/schema/mule/core/2.0/mule.xsd
                     http://www.mulesource.org/schema/mule/jdbc/2.0 http://www.mulesource.org/schema/mule/jdbc/2.0/mule-jdbc.xsd
                     http://www.mulesource.org/schema/mule/vm/2.0 http://www.mulesource.org/schema/mule/vm/2.0/mule-vm.xsd
                     http://www.mulesource.org/schema/mule/stdio/2.0 http://www.mulesource.org/schema/mule/stdio/2.0/mule-stdio.xsd
                     ">
      
      	<description>This is a template.</description>
      
      	<spring:beans>
      		<spring:import resource="spring-applicationContext.xml" />
      	</spring:beans>
      
      	<vm:connector name="vmConnector" queueEvents="false" />
      	<jdbc:connector name="jdbcConnector" dataSource-ref="driverManagedDataSource">
      		<jdbc:query key="getFoo1" value="SELECT * from foo WHERE age=23 AND status=${header:status}"/>
      	</jdbc:connector>
      
      	<model name="testModel">
      		<service name="testService">
      			<inbound>
      				<vm:inbound-endpoint path="in" connector-ref="vmConnector" />
      			</inbound>
      			<component class="components.JdbcComponent"></component>
      			<outbound>
      				<outbound-pass-through-router>
      					<stdio:outbound-endpoint system="OUT" />
      				</outbound-pass-through-router>
      			</outbound>
      		</service>
      	</model>
      </mule>
      
      Show
      <?xml version= "1.0" encoding= "UTF-8" ?> <mule xmlns= "http://www.mulesource.org/schema/mule/core/2.0" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:spring = "http://www.springframework.org/schema/beans" xmlns:vm = "http://www.mulesource.org/schema/mule/vm/2.0" xmlns:stdio = "http://www.mulesource.org/schema/mule/stdio/2.0" xmlns:jdbc = "http://www.mulesource.org/schema/mule/jdbc/2.0" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.mulesource.org/schema/mule/core/2.0 http://www.mulesource.org/schema/mule/core/2.0/mule.xsd http://www.mulesource.org/schema/mule/jdbc/2.0 http://www.mulesource.org/schema/mule/jdbc/2.0/mule-jdbc.xsd http://www.mulesource.org/schema/mule/vm/2.0 http://www.mulesource.org/schema/mule/vm/2.0/mule-vm.xsd http://www.mulesource.org/schema/mule/stdio/2.0 http://www.mulesource.org/schema/mule/stdio/2.0/mule-stdio.xsd "> <description> This is a template. </description> <spring:beans> <spring:import resource= "spring-applicationContext.xml" /> </spring:beans> <vm:connector name= "vmConnector" queueEvents= "false" /> <jdbc:connector name= "jdbcConnector" dataSource-ref= "driverManagedDataSource" > <jdbc:query key= "getFoo1" value= "SELECT * from foo WHERE age=23 AND status=${header:status}" /> </jdbc:connector> <model name= "testModel" > <service name= "testService" > <inbound> <vm:inbound-endpoint path= "in" connector-ref= "vmConnector" /> </inbound> <component class= "components.JdbcComponent" > </component> <outbound> <outbound-pass-through-router> <stdio:outbound-endpoint system= "OUT" /> </outbound-pass-through-router> </outbound> </service> </model> </mule>
    • Similar Issues:
      MULE-4441Add aJSON Expression Evaluator
      MULE-5494JDBC Query reported as invalid when attempting to save stored procedure result in a variable
      MULE-3970Add a String Expression evaluator
      MULE-6186Invalid expression evaluators are not detected in DefaultExpressionManager
      MULE-3381map-property expression evaluator is missing from the schema
      MULE-6827JDBC transport complains about invalid expression template #[payload]
      MULE-6570Add function to MEL for querying JSON payloads
      MULE-4377add registry evaluator to expression-filter
      MULE-3275Review Routers for usage of Expression evaluators
      MULE-5997Inconsistent definition of some expression evaluators

      Description

      I have a component which reads from a JDBC query, by passing in a message with headers (i.e. in the example below, "status"):

      public Object onCall(MuleEventContext eventContext) throws Exception {
      	EndpointURI uri = new MuleEndpointURI("jdbc://getFoo1");
      	MuleMessage response = eventContext.sendEvent(eventContext.getMessage(), uri);
      	Object result = response.getPayload();
      
      	return result;
      }
      

      It's not evaluated, see patch.

      1. JdbcConnector.java
        11 kB
        Yuen-Chi Lian
      2. JdbcConnector.class
        10 kB
        Yuen-Chi Lian
      3. DIFF
        0.7 kB
        Yuen-Chi Lian

        Activity

        Hide
        Daniel Feist added a comment -

        I don't see the header "status" in the snippet above.

        Show
        Daniel Feist added a comment - I don't see the header "status" in the snippet above.
        Hide
        Yuen-Chi Lian added a comment -

        Do you see it in the XML config I attached? See case history, Andrew made some changes to it:

        ...
        <jdbc:query key="getFoo1" value="SELECT * from foo WHERE age=23 AND status=${header:status}"/>
        </jdbc:connector> 
        

        yc

        Show
        Yuen-Chi Lian added a comment - Do you see it in the XML config I attached? See case history, Andrew made some changes to it: ... <jdbc:query key= "getFoo1" value= "SELECT * from foo WHERE age=23 AND status=${header:status}" /> </jdbc:connector> yc
        Hide
        Yuen-Chi Lian added a comment -

        Oh,

        I get what you mean. This is what I did:

        MuleClient client = new MuleClient();
        Map map = new HashMap();
        map.put("status", "0");
        
        client.send("vm://in", "foooo", map);
        

        Hope that makes sense to you. Also, please see the validation of ExpressionEvaluatorManager.

        yc

        Show
        Yuen-Chi Lian added a comment - Oh, I get what you mean. This is what I did: MuleClient client = new MuleClient(); Map map = new HashMap(); map.put( "status" , "0" ); client.send( "vm: //in" , "foooo" , map); Hope that makes sense to you. Also, please see the validation of ExpressionEvaluatorManager. yc
        Hide
        Yuen-Chi Lian added a comment -

        I looked into it again, well, you shall close this issue as invalid as I found this line in ExpressionEvaluatorManager:

        if(expression.startsWith(expressionPrefix))
        {
          expression = expression.substring(2, expression.length()-1);
        }
        

        There an "IF"!

        - yc

        Show
        Yuen-Chi Lian added a comment - I looked into it again, well, you shall close this issue as invalid as I found this line in ExpressionEvaluatorManager: if (expression.startsWith(expressionPrefix)) { expression = expression.substring(2, expression.length()-1); } There an "IF"! - yc
        Hide
        Dirk Olmes added a comment -

        Closing as per Yuen-Chi Lian's request

        Show
        Dirk Olmes added a comment - Closing as per Yuen-Chi Lian's request

          People

          • Assignee:
            Unassigned
            Reporter:
            Yuen-Chi Lian
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development