mybatis-flex / mybatis-flex

mybatis-flex is an elegant Mybatis Enhancement Framework

Home Page:https://mybatis-flex.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

QueryWrapper.create()方法为什么是查询默认列

luo-zhan opened this issue · comments

image

这里buildQueryWrapper()方法select的是默认列,而QueryWrapper.select()和不调用select的时候默认都是select*的逻辑,两者逻辑不相同。

一般用QueryWrapper.create(entity)的使用场景多是后台管理的查询页面,需要返回所有字段,而这里使用了select(默认列)的逻辑,又不能修改(再次调用select(x.all_column)是无法覆盖的,sql会生成两份字段列表)

还有一种情况,当使用QueryWrapper.create(entity)的方式创建wrapper之后,想leftjoin子表做关联查询,这种情况是一定会用wrapper.select(a.all_column, b.all_column)来指定需要的字段的,这样生成的sql里也会出现两份table a的字段。

PS.这里之前pr修改过一次,不知道为什么又加回来了?
image