Variables defined in iteration staying in scope for rest of query

13 views
Skip to first unread message

dq

unread,
Nov 7, 2012, 12:50:14 PM11/7/12
to mybati...@googlegroups.com
I think this is a bug, but I want to get opinions on this.  It appears variables defined by item="" in an iteration are staying in scope for the rest of the query evaluation.
For example:
If I call a select passing in a param map of "bunchIDs" -> a List of Integers, let's say {1,2}, then this XML:

  <if test="bunchIDs != null" >
     <foreach item="bunchID" collection="bunchIDs" open="AND nd.bunch_id in (" close=")" separator=",">
       #{bunchID}
     </foreach>
  </if>
  <if test="bunchID != null" >
     AND nd.bunch_id = #{bunchID}
  </if>

will produce the where clause

AND nd.bunch_id in (1,2) AND nd.bunch_id=2

I don't think bunchID should be defined anymore when it runs the evaluation <if test="bunchID != null" > happens.
Reply all
Reply to author
Forward
0 new messages