You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const mybatisMapper = require('mybatis-mapper');
mybatisMapper.createMapper(['./config/test.xml']);
var format = { language: 'sql' };
var param = {
item_name: 'a',
main_name: [ 'b', 'c' ],
}
var param2 = {
category: 'a',
main_name: [ 'b', 'c' ],
}
var param3 = {
cate_name: 'a',
main_na: [ 'b', 'c' ],
}
var sql1 = mybatisMapper.getStatement('test', 'test1', param, format);
var sql2 = mybatisMapper.getStatement('test', 'test2', param2, format);
var sql3 = mybatisMapper.getStatement('test', 'test3', param3, format);
console.log(sql1)
console.log('--------------------------------------')
console.log(sql2)
console.log('--------------------------------------')
console.log(sql3)
result is
and item_name = 'a'
and (
main_name like CONCAT('%', 'b', '%')
or main_name like CONCAT('%', 'c', '%')
)
--------------------------------------
and category = 'a'
and (
main_name like CONCAT('%', 'b', '%')
or main_name like CONCAT('%', 'c', '%')
)
and category = 'a'
--------------------------------------
and cate_name = 'a'
and (
main_name like CONCAT('%', 'b', '%')
or main_name like CONCAT('%', 'c', '%')
)
Parameters are missing in first and third result.
Parameter(name ends with 'name') is missing....
Only the second result is a success.
I think that "if test" has some bug.
If remove the "if test" in id=test1 (like below), return the collect result.
<sql id="test1">
and item_name = #{item_name}
<foreach collection="main_name" item="name" open="and (" close=")" index="index" separator="or">
main_name like CONCAT('%', #{name}, '%')
</foreach>
and item_name = #{item_name}
</sql>
The text was updated successfully, but these errors were encountered:
There is a problem with parameter matching with a special name and list.
I wrote it to execute a multi-query.
The same where statement was used twice.
The condition has some text and some list.
after excute foreach, some parameter(suffix is 'name') have disappeared.
result is
Parameters are missing in first and third result.
Parameter(name ends with 'name') is missing....
Only the second result is a success.
I think that "if test" has some bug.
If remove the "if test" in id=test1 (like below), return the collect result.
The text was updated successfully, but these errors were encountered: