Skip to content

Commit f1dc755

Browse files
committed
fix for issue 704, add unit test
1 parent 09c8304 commit f1dc755

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

parser_test.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,4 +963,35 @@ func TestParserChoose_issue639(t *testing.T) {
963963
</mapper>`,
964964
"SELECT `name`,`category`,`price` FROM `fruits` WHERE `name`=? AND `category`=? AND `price`=? AND `name`=1;",
965965
)
966-
}
966+
}
967+
968+
func TestParserTrimSuffix_issue704(t *testing.T) {
969+
testParser(t, `
970+
<mapper namespace="Test">
971+
<insert id="insertSelective" parameterType="com.paylabs.merchant.pojo.Agent">
972+
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
973+
SELECT LAST_INSERT_ID()
974+
</selectKey>
975+
insert into agent
976+
<trim prefix="(" suffix=")" suffixOverrides=",">
977+
<if test="agentNo != null">
978+
agent_no,
979+
</if>
980+
<if test="agentName != null">
981+
agent_name,
982+
</if>
983+
</trim>
984+
985+
<trim prefix="values (" suffix=")" suffixOverrides=",">
986+
<if test="agentNo != null">
987+
#{agentNo,jdbcType=VARCHAR},
988+
</if>
989+
<if test="agentName != null">
990+
#{agentName,jdbcType=VARCHAR},
991+
</if>
992+
</trim>
993+
</insert>
994+
</mapper>
995+
`, "INSERT INTO `agent` (`agent_no`,`agent_name`) VALUES (?,?);",
996+
)
997+
}

0 commit comments

Comments
 (0)