yulichang / mybatis-plus-join

支持连表查询的mybatis-plus,mybatis-plus风格的连表操作提供wrapper.leftJoin(),wrapper.rightJoin()等操作
https://yulichang.github.io/mybatis-plus-join-doc/
Apache License 2.0
971 stars 113 forks source link

UNION ALL 导致缺少列 #94

Open wamdy opened 5 months ago

wamdy commented 5 months ago

当前使用版本(必填,否则不予处理)

1.4.7.2

该问题是如何引起的?(确定最新版也有问题再提!!!)

A->B UNION ALL A->B 导子后一个查询语句中缺少B表的字段

重现步骤(如果有就写完整)

MPJLambdaWrapper<SAD> wrapper;
    {
        wrapper = new MPJLambdaWrapper<>(SAD.class, "sad")
                .selectAll(SAD.class, "sad")
                .selectAssociation("ad", AD.class, SAD::getAD)
                .rightJoin(AD.class, "ad", AD::getSADId, SAD::getId);

    }

    MPJLambdaWrapper<SAD> wrapper1;
    {
        wrapper1 = new MPJLambdaWrapper<>(SAD.class, "sad")
                .selectAll(SAD.class, "sad")
                .selectAssociation("ad", AD.class, SAD::getAD)
                .leftJoin(AD.class, "ad", AD::getId, SAD::getADId);

    }
    wrapper1.unionAll(wrapper);

    this.selectJoinListPage(page, SAD.class, wrapper1);

报错信息

bad SQL grammar []; nested exception is java.sql.SQLException: The used SELECT statements have a different number of columns