fixed: UpdateChain.toSQL()

This commit is contained in:
开源海哥 2023-07-30 09:37:38 +08:00
parent 60df82a231
commit 621f151aa5
2 changed files with 13 additions and 9 deletions

View File

@ -628,9 +628,11 @@ public class TableInfo {
if (value != null) {
ColumnInfo columnInfo = columnInfoMapping.get(column);
TypeHandler typeHandler = columnInfo.buildTypeHandler();
if (typeHandler != null) {
value = new TypeHandlerObject(typeHandler, value, columnInfo.getJdbcType());
if (columnInfo != null) {
TypeHandler typeHandler = columnInfo.buildTypeHandler();
if (typeHandler != null) {
value = new TypeHandlerObject(typeHandler, value, columnInfo.getJdbcType());
}
}
}

View File

@ -25,10 +25,7 @@ import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.query.QueryWrapperAdapter;
import com.mybatisflex.core.table.TableInfo;
import com.mybatisflex.core.table.TableInfoFactory;
import com.mybatisflex.core.util.ClassUtil;
import com.mybatisflex.core.util.LambdaGetter;
import com.mybatisflex.core.util.SqlUtil;
import com.mybatisflex.core.util.UpdateEntity;
import com.mybatisflex.core.util.*;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
@ -124,6 +121,7 @@ public class UpdateChain<T> extends QueryWrapperAdapter<UpdateChain<T>> {
return SqlUtil.toBool(baseMapper.deleteByQuery(this));
}
public boolean update() {
return SqlUtil.toBool(baseMapper.updateByQuery(entity, this));
}
@ -133,8 +131,12 @@ public class UpdateChain<T> extends QueryWrapperAdapter<UpdateChain<T>> {
public String toSQL() {
TableInfo tableInfo = TableInfoFactory.ofMapperClass(baseMapper.getClass());
CPI.setFromIfNecessary(this, tableInfo.getSchema(), tableInfo.getTableName());
String sql = DialectFactory.getDialect().forUpdateEntityByQuery(tableInfo,entity,true,this);
return SqlUtil.replaceSqlParams(sql, CPI.getValueArray(this));
String sql = DialectFactory.getDialect().forUpdateEntityByQuery(tableInfo, entity, true, this);
Object[] values = tableInfo.buildUpdateSqlArgs(entity, true, true);
values = ArrayUtil.concat(values, CPI.getValueArray(this));
return SqlUtil.replaceSqlParams(sql, values);
}
}