From 90d1dbf4fc1b8a12d7af7fb385eeac4c965be0d1 Mon Sep 17 00:00:00 2001 From: groot Date: Mon, 8 Dec 2025 16:25:08 +0800 Subject: [PATCH] Allow to insert pk even when auto-id is true, milvus v2.6.3 supports (#1710) Signed-off-by: yhmo --- .../src/main/java/io/milvus/v2/utils/DataUtils.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sdk-core/src/main/java/io/milvus/v2/utils/DataUtils.java b/sdk-core/src/main/java/io/milvus/v2/utils/DataUtils.java index cef748306..44dd80e92 100644 --- a/sdk-core/src/main/java/io/milvus/v2/utils/DataUtils.java +++ b/sdk-core/src/main/java/io/milvus/v2/utils/DataUtils.java @@ -273,10 +273,12 @@ private void processNormalFieldValues(JsonObject row, CreateCollectionReq.FieldS } // from v2.4.10, milvus allows upsert for auto-id pk, no need to check for upsert action - if (field.getAutoID() == Boolean.TRUE && insertBuilder != null) { - String msg = String.format("The primary key: %s is auto generated, no need to input.", fieldName); - throw new MilvusClientException(ErrorCode.INVALID_PARAMS, msg); - } + // from v2.6.3, user can insert pk value even when auto-id is true if the collection + // has "allow_insert_auto_id" property, no need to check for insert/upsert action. +// if (field.getAutoID() == Boolean.TRUE && insertBuilder != null) { +// String msg = String.format("The primary key: %s is auto generated, no need to input.", fieldName); +// throw new MilvusClientException(ErrorCode.INVALID_PARAMS, msg); +// } // store the value into InsertDataInfo Object fieldValue = DataUtils.checkFieldValue(field, fieldData);