-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Description
The <foreach> tag changed behavior between version 3.2.7 and 3.2.8. Having a <select> like below in a mapper file:
<select id="getReports" parameterType="list" resultMap="reportResultMap">
select * from REPORTS where reportId IN
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item.id}
</foreach>
</select>the IN-clause is rendered invalid with version 3.2.8 but works just fine with 3.2.7.
It seems quite likely that the changed behavior is caused by the fix for #195 which issued the if-statement
if (!iterable.iterator().hasNext()) {
return true;
}to be added to ForEachSqlNode.apply() in commit abf2ef3616 at row 55.
3.2.7
The IN clause is properly closed with an empty collection:
select * from REPORTS where REPORTID IN ( ) which is valid SQL.
3.2.8
The open and close attributes are not applied thus the SQL is not valid since there are no opening and ending parenthesis following the IN:
### Error querying database. Cause: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "SELECT * FROM REPORTS WHERE REPORTID IN [*]"; expected "("; SQL statement:
Metadata
Metadata
Assignees
Labels
No labels