mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-01 11:29:48 +08:00
If autoID enabled, check to make sure user didn't specify autoID field (#19943)
Signed-off-by: xiaofan-luan <xiaofan.luan@zilliz.com> Signed-off-by: xiaofan-luan <xiaofan.luan@zilliz.com>
This commit is contained in:
parent
1b7968557c
commit
7d2ba60412
@ -144,6 +144,10 @@ func (it *insertTask) checkPrimaryFieldData() error {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
// check primary key data not exist
|
||||
if typeutil.IsPrimaryFieldDataExist(it.GetFieldsData(), primaryFieldSchema) {
|
||||
return fmt.Errorf("can not assign primary field data when auto id enabled %v", primaryFieldSchema.Name)
|
||||
}
|
||||
// if autoID == true, currently only support autoID for int64 PrimaryField
|
||||
primaryFieldData, err = autoGenPrimaryFieldData(primaryFieldSchema, it.RowIDs)
|
||||
if err != nil {
|
||||
|
@ -556,6 +556,21 @@ func GetPrimaryFieldData(datas []*schemapb.FieldData, primaryFieldSchema *schema
|
||||
return primaryFieldData, nil
|
||||
}
|
||||
|
||||
func IsPrimaryFieldDataExist(datas []*schemapb.FieldData, primaryFieldSchema *schemapb.FieldSchema) bool {
|
||||
primaryFieldID := primaryFieldSchema.FieldID
|
||||
primaryFieldName := primaryFieldSchema.Name
|
||||
|
||||
var primaryFieldData *schemapb.FieldData
|
||||
for _, field := range datas {
|
||||
if field.FieldId == primaryFieldID || field.FieldName == primaryFieldName {
|
||||
primaryFieldData = field
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return primaryFieldData != nil
|
||||
}
|
||||
|
||||
func AppendIDs(dst *schemapb.IDs, src *schemapb.IDs, idx int) {
|
||||
switch src.IdField.(type) {
|
||||
case *schemapb.IDs_IntId:
|
||||
|
Loading…
Reference in New Issue
Block a user