fix(测试跟踪): 功能用例列表不属于不包含等条件查询SQL有误

--bug=1025019 --user=宋昌昌 【测试跟踪】github#23303,筛选自定义字段不属于条件不生效 https://www.tapd.cn/55049933/s/1358326
This commit is contained in:
song-cc-rock 2023-03-31 18:29:57 +08:00 committed by jianxing
parent 3427f73c4f
commit 12370956bd
2 changed files with 44 additions and 4 deletions

View File

@ -22,6 +22,41 @@
</if> </if>
</sql> </sql>
<sql id="includeCondition">
<choose>
<when test='${object}.operator == "like" or ${object}.operator == "not like"'>
like CONCAT('%', #{${object}.value},'%')
</when>
<when test='${object}.operator == "in" or ${object}.operator == "not in"'>
in
<foreach collection="${object}.value" item="v" separator="," open="(" close=")">
#{v}
</foreach>
</when>
<when test='${object}.operator == "between"'>
between #{${object}.value[0]} and #{${object}.value[1]}
</when>
<when test='${object}.operator == "gt"'>
&gt; #{${object}.value}
</when>
<when test='${object}.operator == "lt"'>
&lt; #{${object}.value}
</when>
<when test='${object}.operator == "ge"'>
&gt;= #{${object}.value}
</when>
<when test='${object}.operator == "le"'>
&lt;= #{${object}.value}
</when>
<when test='${object}.operator == "current user"'>
= '${@io.metersphere.commons.utils.SessionUtils@getUserId()}'
</when>
<otherwise>
= #{${object}.value}
</otherwise>
</choose>
</sql>
<sql id="condition"> <sql id="condition">
<choose> <choose>
<when test='${object}.operator == "like"'> <when test='${object}.operator == "like"'>

View File

@ -133,7 +133,12 @@
</if> </if>
<if test="${condition}.customs != null and ${condition}.customs.size() > 0"> <if test="${condition}.customs != null and ${condition}.customs.size() > 0">
<foreach collection="${condition}.customs" item="custom" separator="" open="" close=""> <foreach collection="${condition}.customs" item="custom" separator="" open="" close="">
and test_case.id in ( <if test='custom.operator == "not like" or custom.operator == "not in"'>
and test_case.id not in (
</if>
<if test='custom.operator != "not like" and custom.operator != "not in"'>
and test_case.id in (
</if>
select resource_id from custom_field_test_case where field_id = #{custom.id} select resource_id from custom_field_test_case where field_id = #{custom.id}
<choose> <choose>
<when test="custom.type == 'multipleMember' or custom.type == 'checkbox' or custom.type == 'multipleSelect'"> <when test="custom.type == 'multipleMember' or custom.type == 'checkbox' or custom.type == 'multipleSelect'">
@ -141,19 +146,19 @@
</when> </when>
<when test="custom.type == 'date' or custom.type == 'datetime'"> <when test="custom.type == 'date' or custom.type == 'datetime'">
and left(replace(unix_timestamp(trim(both '"' from `value`)), '.', ''), 13) and left(replace(unix_timestamp(trim(both '"' from `value`)), '.', ''), 13)
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition"> <include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.includeCondition">
<property name="object" value="custom"/> <property name="object" value="custom"/>
</include> </include>
</when> </when>
<when test="custom.type == 'richText' or custom.type == 'textarea'"> <when test="custom.type == 'richText' or custom.type == 'textarea'">
and text_value and text_value
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition"> <include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.includeCondition">
<property name="object" value="custom"/> <property name="object" value="custom"/>
</include> </include>
</when> </when>
<otherwise> <otherwise>
and trim(both '"' from value) and trim(both '"' from value)
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition"> <include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.includeCondition">
<property name="object" value="custom"/> <property name="object" value="custom"/>
</include> </include>
</otherwise> </otherwise>