Ver Fonte

移除掉wrapper的orderby的sql过滤功能
清理部分已标记一年以上过时的代码

miemie há 2 anos atrás
pai
commit
d86989828d
15 ficheiros alterados com 15 adições e 403 exclusões
  1. 0 7
      mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/DbType.java
  2. 6 16
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/AbstractWrapper.java
  3. 0 6
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/query/QueryWrapper.java
  4. 0 5
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/UpdateWrapper.java
  5. 0 52
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/parser/ISqlParser.java
  6. 0 69
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/parser/SqlInfo.java
  7. 0 19
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/parser/package-info.java
  8. 2 9
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/pagination/DialectFactory.java
  9. 0 34
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/pagination/dialects/SinoDBDialect.java
  10. 0 133
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/pagination/optimize/JsqlParserCountOptimize.java
  11. 0 19
      mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/pagination/optimize/package-info.java
  12. 6 6
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/PageTest.java
  13. 0 20
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/H2UserMapperTest.java
  14. 0 7
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/H2UserTest.java
  15. 1 1
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/phoenix/PhoenixTest.java

+ 0 - 7
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/DbType.java

@@ -136,7 +136,6 @@ public enum DbType {
      * Firebird
      */
     FIREBIRD("Firebird", "Firebird 数据库"),
-
     /**
      * HighGo
      */
@@ -145,7 +144,6 @@ public enum DbType {
      * CUBRID
      */
     CUBRID("cubrid", "CUBRID数据库"),
-
     /**
      * GOLDILOCKS
      */
@@ -174,12 +172,10 @@ public enum DbType {
      * redshift
      */
     REDSHIFT("redshift", "亚马逊redshift数据库"),
-
     /**
      * openGauss
      */
     OPENGAUSS("openGauss", "华为 opengauss 数据库"),
-
     /**
      * TDengine
      */
@@ -188,17 +184,14 @@ public enum DbType {
      * Informix
      */
     INFORMIX("informix", "Informix数据库"),
-
     /**
      * uxdb
      */
     UXDB("uxdb", "优炫数据库"),
-
     /**
      * lealone
      */
     LEALONE("lealone", "Lealone数据库"),
-
     /**
      * UNKNOWN DB
      */

+ 6 - 16
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/AbstractWrapper.java

@@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.conditions.interfaces.Compare;
 import com.baomidou.mybatisplus.core.conditions.interfaces.Func;
 import com.baomidou.mybatisplus.core.conditions.interfaces.Join;
 import com.baomidou.mybatisplus.core.conditions.interfaces.Nested;
+import com.baomidou.mybatisplus.core.conditions.segments.ColumnSegment;
 import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments;
 import com.baomidou.mybatisplus.core.enums.SqlKeyword;
 import com.baomidou.mybatisplus.core.enums.SqlLike;
@@ -27,7 +28,6 @@ import com.baomidou.mybatisplus.core.toolkit.*;
 import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils;
 import com.baomidou.mybatisplus.core.toolkit.sql.SqlUtils;
 import com.baomidou.mybatisplus.core.toolkit.sql.StringEscape;
-import com.baomidou.mybatisplus.core.conditions.segments.ColumnSegment;
 
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -44,7 +44,7 @@ import static java.util.stream.Collectors.joining;
  * @author hubin miemie HCL
  * @since 2017-05-26
  */
-@SuppressWarnings({"unchecked"})
+@SuppressWarnings({"unchecked", "serial"})
 public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T, R, Children>> extends Wrapper<T>
     implements Compare<Children, R>, Nested<Children, Children>, Join<Children>, Func<Children, R> {
 
@@ -358,10 +358,10 @@ public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T,
     public Children orderBy(boolean condition, boolean isAsc, R column, R... columns) {
         return maybeDo(condition, () -> {
             final SqlKeyword mode = isAsc ? ASC : DESC;
-            appendSqlSegments(ORDER_BY, columnToSqlSegment(columnSqlInjectFilter(column)), mode);
+            appendSqlSegments(ORDER_BY, columnToSqlSegment(column), mode);
             if (ArrayUtils.isNotEmpty(columns)) {
                 Arrays.stream(columns).forEach(c -> appendSqlSegments(ORDER_BY,
-                    columnToSqlSegment(columnSqlInjectFilter(c)), mode));
+                    columnToSqlSegment(c), mode));
             }
         });
     }
@@ -378,24 +378,14 @@ public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T,
 
     @Override
     public Children orderBy(boolean condition, boolean isAsc, R column) {
-        return maybeDo(condition, () -> appendSqlSegments(ORDER_BY, columnToSqlSegment(columnSqlInjectFilter(column)),
+        return maybeDo(condition, () -> appendSqlSegments(ORDER_BY, columnToSqlSegment(column),
             isAsc ? ASC : DESC));
     }
 
     @Override
     public Children orderBy(boolean condition, boolean isAsc, List<R> columns) {
         return maybeDo(condition, () -> columns.forEach(c -> appendSqlSegments(ORDER_BY,
-            columnToSqlSegment(columnSqlInjectFilter(c)), isAsc ? ASC : DESC)));
-    }
-
-    /**
-     * 字段 SQL 注入过滤处理,子类重写实现过滤逻辑
-     *
-     * @param column 字段内容
-     * @return
-     */
-    protected R columnSqlInjectFilter(R column) {
-        return column;
+            columnToSqlSegment(c), isAsc ? ASC : DESC)));
     }
 
     @Override

+ 0 - 6
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/query/QueryWrapper.java

@@ -22,7 +22,6 @@ import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
 import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringPool;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 
 import java.util.List;
 import java.util.Map;
@@ -98,11 +97,6 @@ public class QueryWrapper<T> extends AbstractWrapper<T, String, QueryWrapper<T>>
         return sqlSelect.getStringValue();
     }
 
-    @Override
-    protected String columnSqlInjectFilter(String column) {
-        return StringUtils.sqlInjectionReplaceBlank(column);
-    }
-
     /**
      * 返回一个支持 lambda 函数写法的 wrapper
      */

+ 0 - 5
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/UpdateWrapper.java

@@ -91,11 +91,6 @@ public class UpdateWrapper<T> extends AbstractWrapper<T, String, UpdateWrapper<T
         return typedThis;
     }
 
-    @Override
-    protected String columnSqlInjectFilter(String column) {
-        return StringUtils.sqlInjectionReplaceBlank(column);
-    }
-
     /**
      * 返回一个支持 lambda 函数写法的 wrapper
      */

+ 0 - 52
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/parser/ISqlParser.java

@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.baomidou.mybatisplus.core.parser;
-
-import org.apache.ibatis.reflection.MetaObject;
-
-/**
- * SQL 解析接口
- *
- * @author hubin
- * @since 2017-09-01
- * @deprecated 2022-05-31
- */
-@Deprecated
-public interface ISqlParser {
-
-    /**
-     * 解析 SQL 方法
-     *
-     * @param metaObject 元对象
-     * @param sql        SQL 语句
-     * @return SQL 信息
-     */
-    SqlInfo parser(MetaObject metaObject, String sql);
-
-    /**
-     * <p>
-     * 是否执行 SQL 解析 parser 方法
-     * </p>
-     *
-     * @param metaObject 元对象
-     * @param sql        SQL 语句
-     * @return SQL 信息
-     */
-    default boolean doFilter(final MetaObject metaObject, final String sql) {
-        // 默认 true 执行 SQL 解析, 可重写实现控制逻辑
-        return true;
-    }
-}

+ 0 - 69
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/parser/SqlInfo.java

@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.baomidou.mybatisplus.core.parser;
-
-import lombok.Data;
-import lombok.experimental.Accessors;
-
-/**
- * Sql Info
- *
- * @author hubin
- * @since 2017-06-20
- */
-@Data
-@Accessors(chain = true)
-public class SqlInfo {
-
-    /**
-     * SQL 内容
-     */
-    private String sql;
-    /**
-     * 是否排序
-     */
-    private boolean orderBy;
-
-    /**
-     * 使用工厂快速构建 SQLInfo,默认支持排序
-     *
-     * @param sql SQL 语句
-     * @return 返回新的 SQL 信息
-     * @see #of(String, boolean)
-     */
-    public static SqlInfo of(String sql) {
-        return of(sql, true);
-    }
-
-    /**
-     * 使用工厂快速构建 SQLInfo
-     *
-     * @param sql  sql 语句
-     * @param sort 是否排序
-     * @return 返回新的 SQLInfo
-     */
-    public static SqlInfo of(String sql, boolean sort) {
-        SqlInfo info = new SqlInfo();
-        info.setSql(sql);
-        info.setOrderBy(sort);
-        return info;
-    }
-
-    public static SqlInfo newInstance() {
-        return new SqlInfo().setOrderBy(true);
-    }
-
-}

+ 0 - 19
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/parser/package-info.java

@@ -1,19 +0,0 @@
-/*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * SQL 解析相关类
- */
-package com.baomidou.mybatisplus.core.parser;

+ 2 - 9
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/pagination/DialectFactory.java

@@ -85,22 +85,15 @@ public class DialectFactory {
                 dialect = new SQLServer2005Dialect();
             } else if (dbType == DbType.SYBASE) {
                 dialect = new SybaseDialect();
-            } else if (dbType == DbType.GBASEDBT) {
-                dialect = new GBasedbtDialect();
-            } else if (dbType == DbType.GBASE_INFORMIX) {
-                dialect = new GBaseInfromixDialect();
             } else if (dbType == DbType.XCloud) {
                 dialect = new XCloudDialect();
-            } else if (dbType == DbType.FIREBIRD) {
-                dialect = new FirebirdDialect();
             } else if (dbType == DbType.GBASE_8S
                 || dbType == DbType.GBASEDBT
-                || dbType == DbType.GBASE_INFORMIX) {
+                || dbType == DbType.GBASE_INFORMIX
+                || dbType == DbType.SINODB) {
                 dialect = new GBase8sDialect();
             } else if (dbType == DbType.INFORMIX) {
                 dialect = new InformixDialect();
-            } else if (dbType == DbType.SINODB) {
-                dialect = new SinoDBDialect();
             }
             DIALECT_ENUM_MAP.put(dbType, dialect);
         }

+ 0 - 34
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/pagination/dialects/SinoDBDialect.java

@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.baomidou.mybatisplus.extension.plugins.pagination.dialects;
-
-import com.baomidou.mybatisplus.extension.plugins.pagination.DialectModel;
-
-/**
- * 星瑞格数据库分页语句组装实现
- *
- * @author wujl
- * @since 2023-05-23
- */
-public class SinoDBDialect implements IDialect {
-
-    @Override
-    public DialectModel buildPaginationSql(String originalSql, long offset, long limit) {
-        StringBuilder sql = new StringBuilder(originalSql)
-            .insert(6, " SKIP " + offset + " FIRST " + limit);
-        return new DialectModel(sql.toString());
-    }
-}

+ 0 - 133
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/pagination/optimize/JsqlParserCountOptimize.java

@@ -1,133 +0,0 @@
-/*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.baomidou.mybatisplus.extension.plugins.pagination.optimize;
-
-import com.baomidou.mybatisplus.core.parser.ISqlParser;
-import com.baomidou.mybatisplus.core.parser.SqlInfo;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.baomidou.mybatisplus.core.toolkit.StringPool;
-import com.baomidou.mybatisplus.extension.toolkit.SqlParserUtils;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import net.sf.jsqlparser.expression.Alias;
-import net.sf.jsqlparser.expression.Expression;
-import net.sf.jsqlparser.expression.Function;
-import net.sf.jsqlparser.expression.LongValue;
-import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
-import net.sf.jsqlparser.parser.CCJSqlParserUtil;
-import net.sf.jsqlparser.schema.Table;
-import net.sf.jsqlparser.statement.select.*;
-import org.apache.ibatis.logging.Log;
-import org.apache.ibatis.logging.LogFactory;
-import org.apache.ibatis.reflection.MetaObject;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-
-/**
- * JsqlParser Count Optimize
- *
- * @author hubin
- * @since 2017-06-20
- * @deprecated 2022-05-31
- */
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-@Deprecated
-public class JsqlParserCountOptimize implements ISqlParser {
-    private static final List<SelectItem> COUNT_SELECT_ITEM = Collections.singletonList(defaultCountSelectItem());
-    private final Log logger = LogFactory.getLog(JsqlParserCountOptimize.class);
-
-    private boolean optimizeJoin = false;
-
-    /**
-     * 获取jsqlparser中count的SelectItem
-     */
-    private static SelectItem defaultCountSelectItem() {
-        Function function = new Function();
-        ExpressionList expressionList = new ExpressionList(Collections.singletonList(new LongValue(1)));
-        function.setName("COUNT");
-        function.setParameters(expressionList);
-        return new SelectExpressionItem(function);
-    }
-
-    @Override
-    public SqlInfo parser(MetaObject metaObject, String sql) {
-        if (logger.isDebugEnabled()) {
-            logger.debug("JsqlParserCountOptimize sql=" + sql);
-        }
-        SqlInfo sqlInfo = SqlInfo.newInstance();
-        try {
-            Select selectStatement = (Select) CCJSqlParserUtil.parse(sql);
-            PlainSelect plainSelect = (PlainSelect) selectStatement.getSelectBody();
-            Distinct distinct = plainSelect.getDistinct();
-            GroupByElement groupBy = plainSelect.getGroupBy();
-            List<OrderByElement> orderBy = plainSelect.getOrderByElements();
-
-            // 添加包含groupBy 不去除orderBy
-            if (null == groupBy && CollectionUtils.isNotEmpty(orderBy)) {
-                plainSelect.setOrderByElements(null);
-                sqlInfo.setOrderBy(false);
-            }
-            //#95 Github, selectItems contains #{} ${}, which will be translated to ?, and it may be in a function: power(#{myInt},2)
-            for (SelectItem item : plainSelect.getSelectItems()) {
-                if (item.toString().contains(StringPool.QUESTION_MARK)) {
-                    return sqlInfo.setSql(SqlParserUtils.getOriginalCountSql(selectStatement.toString()));
-                }
-            }
-            // 包含 distinct、groupBy不优化
-            if (distinct != null || null != groupBy) {
-                return sqlInfo.setSql(SqlParserUtils.getOriginalCountSql(selectStatement.toString()));
-            }
-            // 包含 join 连表,进行判断是否移除 join 连表
-            List<Join> joins = plainSelect.getJoins();
-            if (optimizeJoin && CollectionUtils.isNotEmpty(joins)) {
-                boolean canRemoveJoin = true;
-                String whereS = Optional.ofNullable(plainSelect.getWhere()).map(Expression::toString).orElse(StringPool.EMPTY);
-                // 不区分大小写
-                whereS = whereS.toLowerCase();
-                for (Join join : joins) {
-                    if (!join.isLeft()) {
-                        canRemoveJoin = false;
-                        break;
-                    }
-                    Table table = (Table) join.getRightItem();
-                    String str = Optional.ofNullable(table.getAlias()).map(Alias::getName).orElse(table.getName()) + StringPool.DOT;
-                    // 不区分大小写
-                    str = str.toLowerCase();
-                    String onExpressionS = join.getOnExpression().toString();
-                    /* 如果 join 里包含 ?(代表有入参) 或者 where 条件里包含使用 join 的表的字段作条件,就不移除 join */
-                    if (onExpressionS.contains(StringPool.QUESTION_MARK) || whereS.contains(str)) {
-                        canRemoveJoin = false;
-                        break;
-                    }
-                }
-                if (canRemoveJoin) {
-                    plainSelect.setJoins(null);
-                }
-            }
-            // 优化 SQL
-            plainSelect.setSelectItems(COUNT_SELECT_ITEM);
-            return sqlInfo.setSql(selectStatement.toString());
-        } catch (Throwable e) {
-            // 无法优化使用原 SQL
-            return sqlInfo.setSql(SqlParserUtils.getOriginalCountSql(sql));
-        }
-    }
-}

+ 0 - 19
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/pagination/optimize/package-info.java

@@ -1,19 +0,0 @@
-/*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * COUNT SQL 优化相关类
- */
-package com.baomidou.mybatisplus.extension.plugins.pagination.optimize;

+ 6 - 6
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/PageTest.java

@@ -27,23 +27,23 @@ class PageTest {
         Assertions.assertEquals(page1.getTotal(), page2.getTotal());
         Assertions.assertEquals(page1.getSize(), page2.getSize());
         Assertions.assertEquals(page1.optimizeCountSql(), page2.optimizeCountSql());
-        Assertions.assertEquals(page1.isSearchCount(), page2.isSearchCount());
-        Assertions.assertEquals(page1.getOrders().size(), page2.getOrders().size());
+        Assertions.assertEquals(page1.searchCount(), page2.searchCount());
+        Assertions.assertEquals(page1.orders().size(), page2.orders().size());
 
         Page page3 = new Page();
-        BeanUtils.copyProperties(page1,page3);
+        BeanUtils.copyProperties(page1, page3);
         Assertions.assertEquals(page1.getCurrent(), page3.getCurrent());
         Assertions.assertEquals(page1.getTotal(), page3.getTotal());
         Assertions.assertEquals(page1.getSize(), page3.getSize());
         Assertions.assertEquals(page1.optimizeCountSql(), page3.optimizeCountSql());
-        Assertions.assertEquals(page1.isSearchCount(), page3.isSearchCount());
-        Assertions.assertEquals(page1.getOrders().size(), page3.getOrders().size());
+        Assertions.assertEquals(page1.searchCount(), page3.searchCount());
+        Assertions.assertEquals(page1.orders().size(), page3.orders().size());
 
         Page page4 = new Page();
         BeanCopier.create(page1.getClass(), page4.getClass(), false).copy(page1, page4, null);
         //链式的set方法会导致属性BeanCopier的拷贝方法失败  https://github.com/cglib/cglib/issues/108.
         Assertions.assertTrue(page4.optimizeCountSql());
-        Assertions.assertTrue(page4.isSearchCount());
+        Assertions.assertTrue(page4.searchCount());
         Assertions.assertEquals(1, page4.getCurrent());
         Assertions.assertEquals(1, page4.orders().size());
         Assertions.assertEquals(10, page4.getSize());

+ 0 - 20
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/H2UserMapperTest.java

@@ -214,24 +214,4 @@ class H2UserMapperTest extends BaseTest {
         Long count = userMapper.selectCountLong();
         System.out.println(count);
     }
-
-    @Test
-    void testSelectOne() {
-        // 新增两条数据,测试selectOne方法
-        H2User h2User = new H2User();
-        h2User.setTestId(1L);
-        h2User.setName("测试1");
-
-        H2User h2User2 = new H2User();
-        h2User2.setTestId(2L);
-        h2User2.setName("测试1");
-
-        userMapper.insert(h2User);
-        userMapper.insert(h2User2);
-
-        LambdaQueryWrapper<H2User> wrapper = new LambdaQueryWrapper<>();
-//        H2User user = userMapper.selectOne(wrapper.eq(H2User::getName, "测试1"), false);
-        H2User user = userMapper.selectOne(wrapper.eq(H2User::getName, "测试1"), true);
-        log(user.toString());
-    }
 }

+ 0 - 7
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/H2UserTest.java

@@ -657,8 +657,6 @@ class H2UserTest extends BaseTest {
     @Test
     @Order(27)
     void testServiceGetOneOpt() {
-        H2User user = new H2User(1L, "David");
-        userService.save(user);
         userService.getOneOpt(Wrappers.<H2User>lambdaQuery().eq(H2User::getName, "David"))
             .ifPresent(u -> log(u.toString()));
     }
@@ -666,11 +664,6 @@ class H2UserTest extends BaseTest {
     @Test
     @Order(28)
     void testServiceGetOneOptThrowEx() {
-        H2User user1 = new H2User(1L, "test1");
-        H2User user2 = new H2User(2L, "test1");
-        List<H2User> h2Users = Arrays.asList(user1, user2);
-        userService.saveBatch(h2Users);
-
         userService.getOneOpt(new LambdaQueryWrapper<H2User>().eq(H2User::getName, "test1"), false)
             .ifPresent(u -> log(u.toString()));
 

+ 1 - 1
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/phoenix/PhoenixTest.java

@@ -25,7 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
  * Created date: 2019/12/21 16:35
  */
 @DirtiesContext
-@TestMethodOrder(MethodOrderer.Alphanumeric.class)
+@TestMethodOrder(MethodOrderer.MethodName.class)
 @ExtendWith(SpringExtension.class)
 @ContextConfiguration(locations = {"classpath:phoenix/spring-test-phoenix.xml"})
 public class PhoenixTest {