From 611b691e0f5965e4e1f940d2f9974d4b9caa5aac Mon Sep 17 00:00:00 2001 From: cxc <320522275@qq.com> Date: Thu, 19 Dec 2024 09:42:45 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=A0=A1=E9=AA=8CProperty=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E4=B8=BA=E7=A9=BA=EF=BC=8C=E8=A7=A3=E5=86=B3=E5=B0=86?= =?UTF-8?q?=E5=BA=8F=E5=88=97=E5=8C=96=E5=BD=93=E4=BD=9C=E5=AD=97=E6=AE=B5?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plus/core/conditions/LambdaInsertWrapper.java | 4 +++- .../plus/core/conditions/LambdaUpdateWrapper.java | 14 +++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/milvus-plus-core/src/main/java/org/dromara/milvus/plus/core/conditions/LambdaInsertWrapper.java b/milvus-plus-core/src/main/java/org/dromara/milvus/plus/core/conditions/LambdaInsertWrapper.java index ad392c6..1fcc2c5 100644 --- a/milvus-plus-core/src/main/java/org/dromara/milvus/plus/core/conditions/LambdaInsertWrapper.java +++ b/milvus-plus-core/src/main/java/org/dromara/milvus/plus/core/conditions/LambdaInsertWrapper.java @@ -114,7 +114,9 @@ public class LambdaInsertWrapper extends AbstractChainWrapper 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()); diff --git a/milvus-plus-core/src/main/java/org/dromara/milvus/plus/core/conditions/LambdaUpdateWrapper.java b/milvus-plus-core/src/main/java/org/dromara/milvus/plus/core/conditions/LambdaUpdateWrapper.java index d6dea47..9d9ce56 100644 --- a/milvus-plus-core/src/main/java/org/dromara/milvus/plus/core/conditions/LambdaUpdateWrapper.java +++ b/milvus-plus-core/src/main/java/org/dromara/milvus/plus/core/conditions/LambdaUpdateWrapper.java @@ -676,6 +676,9 @@ public class LambdaUpdateWrapper extends AbstractChainWrapper implements W public MilvusResp update(T entity) throws MilvusException { // 获取主键字段 String primaryKeyField = CollectionToPrimaryCache.collectionToPrimary.get(collectionName); + if (StringUtils.isNotEmpty(primaryKeyField)) { + throw new MilvusException("not find primary key", 400); + } // 将实体转换为属性映射 Map propertiesMap = getPropertiesMap(entity); PropertyCache propertyCache = conversionCache.getPropertyCache(); @@ -695,8 +698,11 @@ public class LambdaUpdateWrapper extends AbstractChainWrapper 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 extends AbstractChainWrapper 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)) {