fix(用例管理): 用例自定义字段多条件查询结果有误

--bug=1046674 --user=陈建星 【用例评审】评审详情-高级筛选-自动定义字段整数类型+输入框类型筛选失败 https://www.tapd.cn/55049933/s/1580542
This commit is contained in:
AgAngle 2024-09-19 11:05:24 +08:00 committed by jianxing
parent 6ddada0d3b
commit 5699075845
1 changed files with 38 additions and 40 deletions

View File

@ -72,14 +72,42 @@
<if test="${combineSearch}.customFiledNoneConditions.size() > 0"> <if test="${combineSearch}.customFiledNoneConditions.size() > 0">
<foreach collection="${combineSearch}.customFiledNoneConditions" item="condition"> <foreach collection="${combineSearch}.customFiledNoneConditions" item="condition">
${mainIdColumn} not in ( <trim prefix="(" suffix=")">
select ${associationIdColumn} from ${associationTable} where ${mainIdColumn} not in (
field_id = #{condition.name} and select ${associationIdColumn} from ${associationTable} where
`value` is not null and `value` != '' field_id = #{condition.name} and
<if test="condition.customFieldType != null and condition.isMultipleCustomField()"> `value` is not null and `value` != ''
and `value` != '[]' <if test="condition.customFieldType != null and condition.isMultipleCustomField()">
</if> and `value` != '[]'
) or </if>
) or
${mainIdColumn} in (
select ${associationIdColumn} from ${associationTable} where
field_id = #{condition.name} and
<choose>
<when test="condition.customFieldType != null and condition.isMultipleCustomField()">
<include refid="io.metersphere.system.mapper.BaseMapper.arrayValueCondition">
<property name="condition" value="condition"/>
<property name="column" value="value"/>
</include>
</when>
<otherwise>
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="value"/>
</include>
</otherwise>
</choose>
)
</trim>
<include refid="io.metersphere.system.mapper.BaseMapper.queryType">
<property name="searchMode" value="${combineSearch}.searchMode"/>
</include>
</foreach>
</if>
<if test="${combineSearch}.customFiledConditions.size() > 0">
<foreach collection="${combineSearch}.customFiledConditions" item="condition">
${mainIdColumn} in ( ${mainIdColumn} in (
select ${associationIdColumn} from ${associationTable} where select ${associationIdColumn} from ${associationTable} where
field_id = #{condition.name} and field_id = #{condition.name} and
@ -103,36 +131,6 @@
</include> </include>
</foreach> </foreach>
</if> </if>
<if test="${combineSearch}.customFiledConditions.size() > 0">
${mainIdColumn} in (
select ${associationIdColumn} from ${associationTable} where
<trim suffixOverrides="AND|OR">
<foreach collection="${combineSearch}.customFiledConditions" item="condition">
<trim prefix="(" suffix=")">
field_id = #{condition.name} and
<choose>
<when test="condition.customFieldType != null and condition.isMultipleCustomField()">
<include refid="io.metersphere.system.mapper.BaseMapper.arrayValueCondition">
<property name="condition" value="condition"/>
<property name="column" value="value"/>
</include>
</when>
<otherwise>
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="value"/>
</include>
</otherwise>
</choose>
</trim>
<include refid="io.metersphere.system.mapper.BaseMapper.queryType">
<property name="searchMode" value="${combineSearch}.searchMode"/>
</include>
</foreach>
</trim>
)
</if>
</sql> </sql>
<sql id="arrayValueCondition"> <sql id="arrayValueCondition">
@ -151,13 +149,13 @@
<when test="${condition}.operator == 'NOT_CONTAINS'"> <when test="${condition}.operator == 'NOT_CONTAINS'">
${column} is null or ${column} = '[]' or ${column} is null or ${column} = '[]' or
<foreach collection="${condition}.value" item="tag" separator="and" open="(" close=")"> <foreach collection="${condition}.value" item="tag" separator="and" open="(" close=")">
!JSON_CONTAINS(${column}, JSON_ARRAY(#{tag})) not JSON_CONTAINS(${column}, JSON_ARRAY(#{tag}))
</foreach> </foreach>
</when> </when>
<when test="${condition}.operator == 'NOT_IN'"> <when test="${condition}.operator == 'NOT_IN'">
${column} is null or ${column} = '[]' or ${column} is null or ${column} = '[]' or
<foreach collection="${condition}.value" item="tag" separator="and" open="(" close=")"> <foreach collection="${condition}.value" item="tag" separator="and" open="(" close=")">
!JSON_CONTAINS(${column}, JSON_ARRAY(#{tag})) not JSON_CONTAINS(${column}, JSON_ARRAY(#{tag}))
</foreach> </foreach>
</when> </when>
<when test="${condition}.operator == 'COUNT_GT'"> <when test="${condition}.operator == 'COUNT_GT'">