sqle icon indicating copy to clipboard operation
sqle copied to clipboard

解析Mybatis xml文件互斥if标签有问题

Open stronglxp opened this issue 5 months ago • 2 comments

版本信息(Version)

问题描述(Describe)

含有互斥if时,解析有问题. 原内容如下:

<select id="queryWoBillInfoByBillId" resultType="java.util.Map">
        select
        spb.deal_code as "account",
        swb.contact_phone as "contactPhone",
        (select bpb2 .city_code from baf.baf_pub_bureau bpb2 where bpb2.bureau_id=spb.nativenet_id) as "cityId",
        (select bpb.business_name from baf.baf_pub_business bpb where bpb.business_id = spb.specialty_id) as "proType",
        swb.sub_name as "userName",
        swb.inst_address as "address"
        from
        <if test="isHis == 0">
            pub.svr_pub_bill spb,
            wo.svr_wo_bill swb
        </if>
        <if test="isHis == 1">
            pub.svr_pub_bill_his spb,
            wo.svr_wo_bill_his swb
        </if>
        where
        spb.bill_id = swb.bill_id
        and spb.bill_id = #{billId}
    </select>

解析出来的sql如下

select
        spb.deal_code as "account",
        swb.contact_phone as "contactPhone",
        (select bpb2 .city_code from baf.baf_pub_bureau bpb2 where bpb2.bureau_id=spb.nativenet_id) as "cityId",
        (select bpb.business_name from baf.baf_pub_business bpb where bpb.business_id = spb.specialty_id) as "proType",
        swb.sub_name as "userName",
        swb.inst_address as "address"
        from
        
            pub.svr_pub_bill spb,
            wo.svr_wo_bill swb
        
            pub.svr_pub_bill_his spb,
            wo.svr_wo_bill_his swb
        
        where
        spb.bill_id = swb.bill_id
        and spb.bill_id = ?

截图或日志(Log)

如何复现(To Reproduce)

问题原因

解决方案

变更影响面

受影响的模块或功能

外部引用的潜在问题或风险

版本兼容性

测试建议

stronglxp avatar May 13 '25 03:05 stronglxp