Prechádzať zdrojové kódy

升级jsqlparser至5.1

nieqiurong 5 mesiacov pred
rodič
commit
194637b223

+ 1 - 1
mybatis-plus-jsqlparser-support/mybatis-plus-jsqlparser/build.gradle

@@ -3,7 +3,7 @@ compileJava {
 }
 
 dependencies {
-    api "com.github.jsqlparser:jsqlparser:5.0"
+    api "com.github.jsqlparser:jsqlparser:5.1"
     api project(":mybatis-plus-jsqlparser-support:mybatis-plus-jsqlparser-common")
     implementation "${lib."slf4j-api"}"
     implementation "de.ruedigermoeller:fst:3.0.3"

+ 2 - 2
mybatis-plus-jsqlparser-support/mybatis-plus-jsqlparser/src/main/java/com/baomidou/mybatisplus/extension/plugins/inner/DataPermissionInterceptor.java

@@ -96,9 +96,9 @@ public class DataPermissionInterceptor extends BaseMultiTableInnerInterceptor im
             // 参照 com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor.processSelect 做的修改
             final String whereSegment = (String) obj;
             processSelectBody(select, whereSegment);
-            List<WithItem> withItemsList = select.getWithItemsList();
+            List<WithItem<?>> withItemsList = select.getWithItemsList();
             if (!CollectionUtils.isEmpty(withItemsList)) {
-                withItemsList.forEach(withItem -> processSelectBody(withItem, whereSegment));
+                withItemsList.forEach(withItem -> processSelectBody(withItem.getSelect(), whereSegment));
             }
         } else {
             // 兼容原来的旧版 DataPermissionHandler 场景

+ 1 - 4
mybatis-plus-jsqlparser-support/mybatis-plus-jsqlparser/src/main/java/com/baomidou/mybatisplus/extension/plugins/inner/PaginationInnerInterceptor.java

@@ -391,10 +391,7 @@ public class PaginationInnerInterceptor implements InnerInterceptor {
                 List<OrderByElement> orderByElementsReturn = addOrderByElements(orderList, orderByElements);
                 setOperationList.setOrderByElements(orderByElementsReturn);
                 return setOperationList.toString();
-            } else if (selectBody instanceof WithItem) {
-                // todo: don't known how to resole
-                return originalSql;
-            } else {
+            }  else {
                 return originalSql;
             }
         } catch (JSQLParserException e) {

+ 2 - 2
mybatis-plus-jsqlparser-support/mybatis-plus-jsqlparser/src/main/java/com/baomidou/mybatisplus/extension/plugins/inner/TenantLineInnerInterceptor.java

@@ -84,9 +84,9 @@ public class TenantLineInnerInterceptor extends BaseMultiTableInnerInterceptor i
     protected void processSelect(Select select, int index, String sql, Object obj) {
         final String whereSegment = (String) obj;
         processSelectBody(select, whereSegment);
-        List<WithItem> withItemsList = select.getWithItemsList();
+        List<WithItem<?>> withItemsList = select.getWithItemsList();
         if (!CollectionUtils.isEmpty(withItemsList)) {
-            withItemsList.forEach(withItem -> processSelectBody(withItem, whereSegment));
+            withItemsList.forEach(withItem -> processSelectBody(withItem.getSelect(), whereSegment));
         }
     }
 

+ 2 - 2
mybatis-plus-jsqlparser-support/mybatis-plus-jsqlparser/src/test/java/com/baomidou/mybatisplus/test/extension/plugins/inner/MultiDataPermissionInterceptorTest.java

@@ -127,8 +127,8 @@ public class MultiDataPermissionInterceptorTest {
 
     @Test
     void test7() {
-        assertSql(TEST_7, "SELECT c.doc AS title, sum(c.total_paid_amount) AS total_paid_amount, sum(c.balance_amount) AS balance_amount FROM (SELECT `a`.`id`, `a`.`doc`, `b`.`month`, `b`.`total_paid_amount`, `b`.`balance_amount`, row_number() OVER (PARTITION BY `a`.`id` ORDER BY `b`.`month` DESC) AS `row_index` FROM `fund` `a` LEFT JOIN `fund_month` `b` ON `a`.`id` = `b`.`fund_id` AND `b`.`submit` = TRUE) c WHERE c.row_index = 1 GROUP BY title LIMIT 20",
-            "SELECT c.doc AS title, sum(c.total_paid_amount) AS total_paid_amount, sum(c.balance_amount) AS balance_amount FROM (SELECT `a`.`id`, `a`.`doc`, `b`.`month`, `b`.`total_paid_amount`, `b`.`balance_amount`, row_number() OVER (PARTITION BY `a`.`id` ORDER BY `b`.`month` DESC) AS `row_index` FROM `fund` `a` LEFT JOIN `fund_month` `b` ON `a`.`id` = `b`.`fund_id` AND `b`.`submit` = TRUE AND b.fund_id = 2 AND b.month <= '2022-05' WHERE a.id = 1 AND a.year = 2022 AND a.create_user_id = 1111) c WHERE c.row_index = 1 GROUP BY title LIMIT 20");
+        assertSql(TEST_7, "SELECT c.doc AS title, sum(c.total_paid_amount) AS total_paid_amount, sum(c.balance_amount) AS balance_amount FROM (SELECT `a`.`id`, `a`.`doc`, `b`.`month`, `b`.`total_paid_amount`, `b`.`balance_amount`, row_number() OVER (PARTITION BY `a`.`id` ORDER BY `b`.`month` DESC) AS `row_index` FROM `fund` `a` LEFT JOIN `fund_month` `b` ON `a`.`id` = `b`.`fund_id` AND `b`.`submit` = true) c WHERE c.row_index = 1 GROUP BY title LIMIT 20",
+            "SELECT c.doc AS title, sum(c.total_paid_amount) AS total_paid_amount, sum(c.balance_amount) AS balance_amount FROM (SELECT `a`.`id`, `a`.`doc`, `b`.`month`, `b`.`total_paid_amount`, `b`.`balance_amount`, row_number() OVER (PARTITION BY `a`.`id` ORDER BY `b`.`month` DESC) AS `row_index` FROM `fund` `a` LEFT JOIN `fund_month` `b` ON `a`.`id` = `b`.`fund_id` AND `b`.`submit` = true AND b.fund_id = 2 AND b.month <= '2022-05' WHERE a.id = 1 AND a.year = 2022 AND a.create_user_id = 1111) c WHERE c.row_index = 1 GROUP BY title LIMIT 20");
     }
 
     @Test