mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Merge pull request #3263 from xijiu/master
bug fix 解决PagerUtils修改offset的bug,当offset需要修改为0时,取值不正确
This commit is contained in:
@@ -400,7 +400,7 @@ public class PagerUtils {
|
||||
private static boolean limitMySqlQueryBlock(SQLSelectQueryBlock queryBlock, String dbType, int offset, int count, boolean check) {
|
||||
SQLLimit limit = queryBlock.getLimit();
|
||||
if (limit != null) {
|
||||
if (offset > 0) {
|
||||
if (offset >= 0) {
|
||||
limit.setOffset(new SQLIntegerExpr(offset));
|
||||
}
|
||||
|
||||
|
||||
@@ -41,4 +41,12 @@ public class PagerUtilsTest_Limit_mysql_0 extends TestCase {
|
||||
"\nORDER BY id, name" + //
|
||||
"\nLIMIT 20, 10", result);
|
||||
}
|
||||
|
||||
public void test_mysql_4() throws Exception {
|
||||
String sql = "select id, name, salary from t limit 100 offset 5";
|
||||
String result = PagerUtils.limit(sql, JdbcConstants.MYSQL, 0, 20);
|
||||
Assert.assertEquals("SELECT id, name, salary" + //
|
||||
"\nFROM t" + //
|
||||
"\nLIMIT 0, 20", result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user