From 5a672522710f5759f5058ac58f19020686fea0cb Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Wed, 14 Jun 2023 10:15:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=B8=8D=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E5=A4=8D=E7=94=A8=E7=9A=84=E4=B8=8D=E8=BF=9B=E8=A1=8C=E6=8F=90?= =?UTF-8?q?=E5=8F=96=E5=B8=B8=E9=87=8F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/mybatisflex/core/constant/SqlConsts.java | 3 --- .../com/mybatisflex/core/dialect/LimitOffsetProcessor.java | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/constant/SqlConsts.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/constant/SqlConsts.java index 4bcef22d..414b2564 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/constant/SqlConsts.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/constant/SqlConsts.java @@ -90,9 +90,6 @@ public final class SqlConsts { public static final String START_AT = " START AT "; public static final String ROWS_ONLY = " ROWS ONLY"; public static final String ROWS_FETCH_NEXT = " ROWS FETCH NEXT "; - public static final String WHERE_RN = ") WHERE RN >"; - public static final String WHERE_ROWNUM = ") TEMP_DATAS WHERE ROWNUM <="; - public static final String ROWNUM_RN_FROM = "SELECT * FROM (SELECT TEMP_DATAS.*, ROWNUM RN FROM ("; // === 联表查询关键字 === diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/dialect/LimitOffsetProcessor.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/dialect/LimitOffsetProcessor.java index 35323a6f..c931c01c 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/dialect/LimitOffsetProcessor.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/dialect/LimitOffsetProcessor.java @@ -129,9 +129,9 @@ public interface LimitOffsetProcessor { if (limitOffset == null) { limitOffset = 0; } - StringBuilder newSql = new StringBuilder(ROWNUM_RN_FROM); + StringBuilder newSql = new StringBuilder("SELECT * FROM (SELECT TEMP_DATAS.*, ROWNUM RN FROM ("); newSql.append(sql); - newSql.append(WHERE_ROWNUM).append(limitOffset + limitRows).append(WHERE_RN).append(limitOffset); + newSql.append(") TEMP_DATAS WHERE ROWNUM <= ").append(limitOffset + limitRows).append(" ) WHERE RN > ").append(limitOffset); return newSql; } return sql;