mirror of
https://gitee.com/dromara/MilvusPlus.git
synced 2025-12-06 17:08:27 +08:00
fix 校验Property是否为空,解决将序列化当作字段bug
This commit is contained in:
parent
de3fb89618
commit
611b691e0f
@ -114,7 +114,9 @@ public class LambdaInsertWrapper<T> extends AbstractChainWrapper<T> implements
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
String tk = propertyCache.functionToPropertyMap.get(key);
|
||||
GsonUtil.put(jsonObject,tk,value);
|
||||
if (StringUtils.isNotEmpty(tk)) {
|
||||
GsonUtil.put(jsonObject,tk,value);
|
||||
}
|
||||
}
|
||||
if(conversionCache.isAutoID()){
|
||||
GsonUtil.put(jsonObject,pk,IdWorkerUtils.nextId());
|
||||
|
||||
@ -676,6 +676,9 @@ public class LambdaUpdateWrapper<T> extends AbstractChainWrapper<T> implements W
|
||||
public MilvusResp<UpsertResp> update(T entity) throws MilvusException {
|
||||
// 获取主键字段
|
||||
String primaryKeyField = CollectionToPrimaryCache.collectionToPrimary.get(collectionName);
|
||||
if (StringUtils.isNotEmpty(primaryKeyField)) {
|
||||
throw new MilvusException("not find primary key", 400);
|
||||
}
|
||||
// 将实体转换为属性映射
|
||||
Map<String, Object> propertiesMap = getPropertiesMap(entity);
|
||||
PropertyCache propertyCache = conversionCache.getPropertyCache();
|
||||
@ -695,8 +698,11 @@ public class LambdaUpdateWrapper<T> extends AbstractChainWrapper<T> implements W
|
||||
hasPrimaryKey = true;
|
||||
primaryKeyValue = value;
|
||||
}
|
||||
// 添加到更新对象
|
||||
GsonUtil.put(updateObject,tableNameColumn, value);
|
||||
// 校验是否为空
|
||||
if (StringUtils.isNotEmpty(tableNameColumn)) {
|
||||
// 添加到更新对象
|
||||
GsonUtil.put(updateObject,tableNameColumn, value);
|
||||
}
|
||||
}
|
||||
// 检查是否需要构建查询条件
|
||||
boolean needBuildQuery = !hasPrimaryKey;
|
||||
@ -783,7 +789,9 @@ public class LambdaUpdateWrapper<T> extends AbstractChainWrapper<T> implements W
|
||||
Object value = entry.getValue();
|
||||
// 根据PropertyCache转换属性名
|
||||
String tk = propertyCache.functionToPropertyMap.get(key);
|
||||
GsonUtil.put(jsonObject,tk, value);
|
||||
if (StringUtils.isNotEmpty(tk)) {
|
||||
GsonUtil.put(jsonObject,tk, value);
|
||||
}
|
||||
}
|
||||
// 检查是否包含主键
|
||||
if (!jsonObject.has(pk)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user