mybatis-plus icon indicating copy to clipboard operation
mybatis-plus copied to clipboard

对 #5745 的优化导致分页查询中如包含distinct跟orderby会导致sqlserver语法错误

Open GitHub-Link opened this issue 10 months ago • 3 comments

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

3.5.6

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

问题对该issues的fix引起 https://github.com/baomidou/mybatis-plus/issues/5745 此段代码挪到上面导致在判断有distinct 的时候直接返回了,没有执行消除order by的处理,继而导致sqlserver语法错误

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

如有sql语句 select distinct id from table order by id 在分页的时候,会在加上count转换为 select count(1) from (select distinct id from table order by id) a;

报错信息

The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP, OFFSET or FOR XML is also specified.

GitHub-Link avatar Apr 26 '24 13:04 GitHub-Link

用 3.5.7-SNAPSHOT 试试

nieqiurong avatar Apr 26 '24 15:04 nieqiurong

用 3.5.7-SNAPSHOT 试试

谢谢

GitHub-Link avatar Apr 28 '24 03:04 GitHub-Link