Remove max length check when autoid==true set by varchar primary field (#25728)

Signed-off-by: lixinguo <xinguo.li@zilliz.com>
Co-authored-by: lixinguo <xinguo.li@zilliz.com>
pull/25824/head
smellthemoon 2023-07-21 11:30:59 +08:00 committed by GitHub
parent 7bf39aed08
commit a2f001e132
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 1 deletions

View File

@ -261,7 +261,11 @@ func (v *validateUtil) checkVarCharFieldData(field *schemapb.FieldData, fieldSch
return merr.WrapErrParameterInvalid("need string array", "got nil", msg)
}
if v.checkMaxLen {
// fieldSchema autoID is true means that field is pk and primaryData is auto generated
// no need to do max length check
// ignore the parameter of MaxLength
// related https://github.com/milvus-io/milvus/issues/25580
if v.checkMaxLen && !fieldSchema.AutoID {
maxLength, err := parameterutil.GetMaxLength(fieldSchema)
if err != nil {
return err

View File

@ -143,6 +143,37 @@ func Test_validateUtil_checkVarCharFieldData(t *testing.T) {
err := v.checkVarCharFieldData(f, fs)
assert.NoError(t, err)
})
t.Run("when autoID is true, no need to do max length check", func(t *testing.T) {
f := &schemapb.FieldData{
Field: &schemapb.FieldData_Scalars{
Scalars: &schemapb.ScalarField{
Data: &schemapb.ScalarField_StringData{
StringData: &schemapb.StringArray{
Data: []string{"111", "222"},
},
},
},
},
}
fs := &schemapb.FieldSchema{
DataType: schemapb.DataType_VarChar,
IsPrimaryKey: true,
AutoID: true,
TypeParams: []*commonpb.KeyValuePair{
{
Key: common.MaxLengthKey,
Value: "2",
},
},
}
v := newValidateUtil(withMaxLenCheck())
err := v.checkVarCharFieldData(f, fs)
assert.NoError(t, err)
})
}
func Test_validateUtil_checkBinaryVectorFieldData(t *testing.T) {