瀏覽代碼

[优化] 移除 ChainQuery 的过时的 delete 方法,补全 test

miemie 6 年之前
父節點
當前提交
aff9e98ace

+ 2 - 11
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/service/additional/query/ChainQuery.java

@@ -15,12 +15,11 @@
  */
 package com.baomidou.mybatisplus.extension.service.additional.query;
 
-import java.util.List;
-
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.additional.ChainWrapper;
 
+import java.util.List;
+
 /**
  * 具有查询方法的定义
  *
@@ -65,12 +64,4 @@ public interface ChainQuery<T> extends ChainWrapper<T> {
     default IPage<T> page(IPage<T> page) {
         return getBaseMapper().selectPage(page, getWrapper());
     }
-
-    /**
-     * use {@link IService#update()} or {@link IService#lambdaUpdate()}
-     */
-    @Deprecated
-    default int delete() {
-        return getBaseMapper().delete(getWrapper());
-    }
 }

+ 13 - 3
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/MysqlTestDataMapperTest.java

@@ -416,13 +416,23 @@ class MysqlTestDataMapperTest {
     }
 
     @Test
-    void e_4testChain() {
+    void e_4testChainQuery() {
         new LambdaQueryChainWrapper<>(mysqlMapper).select(MysqlData::getId, MysqlData::getYaHoStr)
             .list().forEach(System.out::println);
 
-        new LambdaUpdateChainWrapper<>(mysqlMapper).set(MysqlData::getYaHoStr, "123456").update();
+        new LambdaQueryChainWrapper<>(mysqlMapper).select(MysqlData::getId, MysqlData::getYaHoStr)
+            .eq(MysqlData::getId, 19).one();
+
+        new LambdaQueryChainWrapper<>(mysqlMapper).count();
 
         new LambdaQueryChainWrapper<>(mysqlMapper).select(MysqlData::getId, MysqlData::getYaHoStr)
-            .list().forEach(System.out::println);
+            .page(new Page<>(1, 2));
+    }
+
+    @Test
+    void e_5testChainUpdate() {
+        new LambdaUpdateChainWrapper<>(mysqlMapper).set(MysqlData::getYaHoStr, "123456").update();
+
+        new LambdaUpdateChainWrapper<>(mysqlMapper).eq(MysqlData::getYaHoStr, "111").remove();
     }
 }