mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
fixed: UpdateChain.toSQL()
This commit is contained in:
parent
60df82a231
commit
621f151aa5
@ -628,11 +628,13 @@ public class TableInfo {
|
|||||||
|
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
ColumnInfo columnInfo = columnInfoMapping.get(column);
|
ColumnInfo columnInfo = columnInfoMapping.get(column);
|
||||||
|
if (columnInfo != null) {
|
||||||
TypeHandler typeHandler = columnInfo.buildTypeHandler();
|
TypeHandler typeHandler = columnInfo.buildTypeHandler();
|
||||||
if (typeHandler != null) {
|
if (typeHandler != null) {
|
||||||
value = new TypeHandlerObject(typeHandler, value, columnInfo.getJdbcType());
|
value = new TypeHandlerObject(typeHandler, value, columnInfo.getJdbcType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ModifyAttrsRecord 忽略 ignoreNulls 的设置,
|
// ModifyAttrsRecord 忽略 ignoreNulls 的设置,
|
||||||
// 当使用 ModifyAttrsRecord 时,可以理解为要对字段进行 null 值进行更新,否则没必要使用 ModifyAttrsRecord
|
// 当使用 ModifyAttrsRecord 时,可以理解为要对字段进行 null 值进行更新,否则没必要使用 ModifyAttrsRecord
|
||||||
|
|||||||
@ -25,10 +25,7 @@ import com.mybatisflex.core.query.QueryColumn;
|
|||||||
import com.mybatisflex.core.query.QueryWrapperAdapter;
|
import com.mybatisflex.core.query.QueryWrapperAdapter;
|
||||||
import com.mybatisflex.core.table.TableInfo;
|
import com.mybatisflex.core.table.TableInfo;
|
||||||
import com.mybatisflex.core.table.TableInfoFactory;
|
import com.mybatisflex.core.table.TableInfoFactory;
|
||||||
import com.mybatisflex.core.util.ClassUtil;
|
import com.mybatisflex.core.util.*;
|
||||||
import com.mybatisflex.core.util.LambdaGetter;
|
|
||||||
import com.mybatisflex.core.util.SqlUtil;
|
|
||||||
import com.mybatisflex.core.util.UpdateEntity;
|
|
||||||
|
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
@ -124,6 +121,7 @@ public class UpdateChain<T> extends QueryWrapperAdapter<UpdateChain<T>> {
|
|||||||
return SqlUtil.toBool(baseMapper.deleteByQuery(this));
|
return SqlUtil.toBool(baseMapper.deleteByQuery(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean update() {
|
public boolean update() {
|
||||||
return SqlUtil.toBool(baseMapper.updateByQuery(entity, this));
|
return SqlUtil.toBool(baseMapper.updateByQuery(entity, this));
|
||||||
}
|
}
|
||||||
@ -134,7 +132,11 @@ public class UpdateChain<T> extends QueryWrapperAdapter<UpdateChain<T>> {
|
|||||||
TableInfo tableInfo = TableInfoFactory.ofMapperClass(baseMapper.getClass());
|
TableInfo tableInfo = TableInfoFactory.ofMapperClass(baseMapper.getClass());
|
||||||
CPI.setFromIfNecessary(this, tableInfo.getSchema(), tableInfo.getTableName());
|
CPI.setFromIfNecessary(this, tableInfo.getSchema(), tableInfo.getTableName());
|
||||||
String sql = DialectFactory.getDialect().forUpdateEntityByQuery(tableInfo, entity, true, this);
|
String sql = DialectFactory.getDialect().forUpdateEntityByQuery(tableInfo, entity, true, this);
|
||||||
return SqlUtil.replaceSqlParams(sql, CPI.getValueArray(this));
|
|
||||||
|
Object[] values = tableInfo.buildUpdateSqlArgs(entity, true, true);
|
||||||
|
values = ArrayUtil.concat(values, CPI.getValueArray(this));
|
||||||
|
|
||||||
|
return SqlUtil.replaceSqlParams(sql, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user