浏览代码

调整填充处理逻辑.

聂秋秋 5 年之前
父节点
当前提交
1e912b26a5

+ 6 - 2
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisDefaultParameterHandler.java

@@ -114,14 +114,18 @@ public class MybatisDefaultParameterHandler extends DefaultParameterHandler {
             MetaObject metaObject = ms.getConfiguration().newMetaObject(parameterObject);
             if (SqlCommandType.INSERT == ms.getSqlCommandType()) {
                 // input none 且id为空  或者  无主键放入insert填充
-                if (tableInfo.isInsertFill()) {
+                // 使用insert填充
+                if (tableInfo.isWithInsertFill()) {
+                    handlerFill(ms, metaObject, tableInfo);
+                } else {
+                    // 兼容旧操作
                     String keyProperty = tableInfo.getKeyProperty();
                     //无主键的要兼容旧的骚操作,只能走完insert填充
                     if (StringUtils.isBlank(keyProperty)) {
                         handlerFill(ms, metaObject, tableInfo);
                     } else {
                         Object value = metaObject.getValue(keyProperty);
-                        if (value == null) {
+                        if (value == null && (IdType.NONE == tableInfo.getIdType() || IdType.INPUT == tableInfo.getIdType())) {
                             handlerFill(ms, metaObject, tableInfo);
                         }
                     }

+ 0 - 9
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/metadata/TableInfo.java

@@ -401,13 +401,4 @@ public class TableInfo implements Constants {
         this.withUpdateFill = fieldList.parallelStream().anyMatch(TableFieldInfo::isWithUpdateFill);
     }
 
-    /**
-     * 这个不要乱调用,后面要移出掉这个骚操作的
-     *
-     * @return 是否insert填充
-     */
-    @Deprecated
-    public boolean isInsertFill() {
-        return (IdType.NONE == this.idType || IdType.INPUT == this.idType) || this.withInsertFill || this.keyType == null;
-    }
 }