-
Notifications
You must be signed in to change notification settings - Fork 312
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
pagehelper-spring-boot-starter1.2.11 sqlserver分页,查询总数的时候,连接查询加入with(nolock)之后,sql解析不对 on条件丢失 #76
Comments
按com.github.pagehelper.PageInterceptor#count |
pagehelper分页插件配置如下: |
forum_post_info a with(nolcok) forum_carcase_tags as b whth(nolock) 看出原因了吗? 排除上述两个书写错误后,生成的分页SQL如下: SELECT COUNT(0)
FROM forum_post_info a WITH (NOLOCK)
LEFT JOIN forum_carcase_tags b WITH (NOLOCK) ON a.id = b.carcase_id
WHERE b.tag_id = 127
-------------------
SELECT TOP 10 *
FROM (
SELECT ROW_NUMBER() OVER (ORDER BY RAND()) AS PAGE_ROW_NUMBER, *
FROM (
SELECT *
FROM forum_post_info a WITH (NOLOCK)
LEFT JOIN forum_carcase_tags b WITH (NOLOCK) ON a.id = b.carcase_id
WHERE b.tag_id = 127
) PAGE_TABLE_ALIAS
) PAGE_TABLE_ALIAS
WHERE PAGE_ROW_NUMBER > 1
ORDER BY PAGE_ROW_NUMBER |
找到你失败的原因了。。 默认的 ReplaceSql 支持不了,应该选择 regex 方式,参考: pagehelper/Mybatis-PageHelper@1801260 pagehelper/Mybatis-PageHelper@780357a 明天发布 5.1.10 版本,仅仅修改一个默认值。 |
感谢您百忙之中帮忙看问题,谢谢!经验证regex 方式可以正常分页。再次感谢! |
奉上咖啡一杯 |
#66
实际sql:SELECT *
FROM
forum_post_info a with(nolcok)
LEFT JOIN forum_carcase_tags as b whth(nolock) on a.id = b.carcase_id where b.tag_id = 127
pagehelper生成的count语句:
SELECT count(0)
FROM
forum_post_info a with(nolcok)
LEFT JOIN forum_carcase_tags as b whth(nolock) where b.tag_id = 127
插件生成的count语句,on条件丢失。
pagehelper-spring-boot-starter 升到了1.2.11 还是有这个问题。net.sf.jsqlparser.parser.CCJSqlParserUtil#parse(java.lang.String) 入参的sql有on条件,但是转换之后on条件丢失了。
The text was updated successfully, but these errors were encountered: