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