Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

子查询 selectSub 支持动态表名吗 #115

Closed
yixingang0525 opened this issue Mar 6, 2024 · 1 comment
Closed

子查询 selectSub 支持动态表名吗 #115

yixingang0525 opened this issue Mar 6, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@yixingang0525
Copy link

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

1.4.10

实际sql如下: 其中user_tag_151 为动态表名
SELECT
tag.*,
(SELECT COUNT(1) FROM user_tag_151 t1 WHERE t1.tag_id = tag.tag_id) AS tag_count
FROM tag;

代码写法:
MPJLambdaWrapper tagMPJLambdaWrapperX = new MPJLambdaWrapper()
.selectAll(TagDO.class)
.selectSub(UserTagDO.class, w -> w.selectCount(UserTagDO::getTagId, TagRespDTO::getTagMarkCount)
.setTableName(name -> name + "_151" ), UserTagDO::getTagId)

控制台打印sql中,子查询中的表并未拼接 '_151' 异常提示表不存在

但是使用leftJoin 动态设置表名却是可以的
MPJLambdaWrapper userDOMPJLambdaWrapper = new MPJLambdaWrapper()
.selectAll(TagDO.class)
.selectCount(UserTagDO::getTagId,TagRespDTO::getTagMarkCount)
.leftJoin(UserTagDO.class, on -> on
.eq(UserTagDO::getTagId, TagDO::getTagId)
.setTableName(name -> name + "_151"))
.groupBy(TagDO::getTagId);

子查询 selectSub 是还不支持动态表名吗?

@yulichang yulichang added the enhancement New feature or request label Mar 6, 2024
@yulichang
Copy link
Owner

下个版本加上

yulichang added a commit that referenced this issue Apr 10, 2024
yulichang added a commit that referenced this issue Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants