Pārlūkot izejas kodu

fixed property bug

hubin 4 gadi atpakaļ
vecāks
revīzija
e4886c5cca

+ 6 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/metadata/TableFieldInfo.java

@@ -207,9 +207,11 @@ public class TableFieldInfo implements Constants {
         JdbcType jdbcType = tableField.jdbcType();
         final Class<? extends TypeHandler> typeHandler = tableField.typeHandler();
         final String numericScale = tableField.numericScale();
+        boolean needAs = false;
         String el = this.property;
         if (StringUtils.isNotBlank(tableField.property())) {
             el = tableField.property();
+            needAs = true;
         }
         if (JdbcType.UNDEFINED != jdbcType) {
             this.jdbcType = jdbcType;
@@ -262,7 +264,10 @@ public class TableFieldInfo implements Constants {
 
         this.column = column;
         this.sqlSelect = column;
-        if (tableInfo.getResultMap() == null && !tableInfo.isAutoInitResultMap() &&
+        if (needAs) {
+            // 存在指定转换属性
+            this.sqlSelect += String.format("%s\"%s\"", AS, tableField.property());
+        } else if (tableInfo.getResultMap() == null && !tableInfo.isAutoInitResultMap() &&
             TableInfoHelper.checkRelated(tableInfo.isUnderCamel(), this.property, this.column)) {
             /* 未设置 resultMap 也未开启自动构建 resultMap, 字段规则又不符合 mybatis 的自动封装规则 */
             String propertyFormat = dbConfig.getPropertyFormat();