mirror of https://github.com/milvus-io/milvus.git
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
parent
7bf39aed08
commit
a2f001e132
|
@ -261,7 +261,11 @@ func (v *validateUtil) checkVarCharFieldData(field *schemapb.FieldData, fieldSch
|
||||||
return merr.WrapErrParameterInvalid("need string array", "got nil", msg)
|
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)
|
maxLength, err := parameterutil.GetMaxLength(fieldSchema)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -143,6 +143,37 @@ func Test_validateUtil_checkVarCharFieldData(t *testing.T) {
|
||||||
err := v.checkVarCharFieldData(f, fs)
|
err := v.checkVarCharFieldData(f, fs)
|
||||||
assert.NoError(t, err)
|
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) {
|
func Test_validateUtil_checkBinaryVectorFieldData(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue