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

关于 SqlServer2012Dialect 生成的分页 SQL 格式问题 #42

Closed
AifeiI opened this issue Apr 20, 2017 · 6 comments
Closed

关于 SqlServer2012Dialect 生成的分页 SQL 格式问题 #42

AifeiI opened this issue Apr 20, 2017 · 6 comments

Comments

@AifeiI
Copy link

AifeiI commented Apr 20, 2017

我遇到当使用 PageHelper.startPage(1, 10); 的方式进行分页查询时,会爆出 :

数据库是 SQL Server 2014,helperDialect 设置为 sqlserver2012

com.microsoft.sqlserver.jdbc.SQLServerException: Invalid usage of the option NEXT in the FETCH statement.

PageHelper自动生成的:

SELECT
  [num]
FROM vw_app_query_1
WHERE (num LIKE '%' + ? + '%')
ORDER BY [num] 
  FETCH NEXT 10 ROWS ONLY;

可以正确执行的:

SELECT
  [num]
FROM vw_app_query_1
WHERE (num LIKE '%' + '32' + '%')
ORDER BY [num]
  OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;

主要是缺少了 OFFSET 0 ROWS

@AifeiI
Copy link
Author

AifeiI commented Apr 20, 2017

SqlServer2012RowBoundsDialect.java 应该也有这个情况

@AifeiI
Copy link
Author

AifeiI commented Apr 20, 2017

SqlServer2012Dialect.java 中的:

...
if (page.getStartRow() > 0) {
    ...
}
...

我觉得应该调整为:

...
if (page.getStartRow() >= 0) {
    ...
}
...

SqlServer2012RowBoundsDialect.java也一样

@abel533
Copy link
Collaborator

abel533 commented Apr 21, 2017

谢谢指出这个错误,已经修复,下个版本会解决。计划在这周一发布。

@AifeiI
Copy link
Author

AifeiI commented Apr 24, 2017

今天发布?

@abel533
Copy link
Collaborator

abel533 commented Apr 25, 2017

@AifeiI 已经 发布了,5.0.1

@AifeiI
Copy link
Author

AifeiI commented Apr 26, 2017

@abel533 嗯,问题解决~谢谢

@AifeiI AifeiI closed this as completed Apr 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants