mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
fix: [AddField] Forbid delete dynamicfield.enable property (#44335)
Related to #44311 This PR forbids delete `dynamicfield.enable` property and returns user understandable error message to user. Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
parent
e70c2f7b3d
commit
634026a177
@ -34,6 +34,7 @@ import (
|
||||
"github.com/milvus-io/milvus/pkg/v2/log"
|
||||
"github.com/milvus-io/milvus/pkg/v2/mq/msgstream"
|
||||
"github.com/milvus-io/milvus/pkg/v2/proto/querypb"
|
||||
"github.com/milvus-io/milvus/pkg/v2/util/funcutil"
|
||||
"github.com/milvus-io/milvus/pkg/v2/util/merr"
|
||||
)
|
||||
|
||||
@ -47,6 +48,10 @@ func (a *alterCollectionTask) Prepare(ctx context.Context) error {
|
||||
return errors.New("alter collection failed, collection name does not exists")
|
||||
}
|
||||
|
||||
if funcutil.SliceContain(a.Req.GetDeleteKeys(), common.EnableDynamicSchemaKey) {
|
||||
return merr.WrapErrParameterInvalidMsg("cannot delete key %s, dynamic field schema could support set to true/false", common.EnableDynamicSchemaKey)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ import (
|
||||
mockrootcoord "github.com/milvus-io/milvus/internal/rootcoord/mocks"
|
||||
"github.com/milvus-io/milvus/pkg/v2/common"
|
||||
"github.com/milvus-io/milvus/pkg/v2/mq/msgstream"
|
||||
"github.com/milvus-io/milvus/pkg/v2/util/merr"
|
||||
)
|
||||
|
||||
func Test_alterCollectionTask_Prepare(t *testing.T) {
|
||||
@ -42,6 +43,17 @@ func Test_alterCollectionTask_Prepare(t *testing.T) {
|
||||
assert.Error(t, err)
|
||||
})
|
||||
|
||||
t.Run("banned_delete_keys", func(t *testing.T) {
|
||||
task := &alterCollectionTask{Req: &milvuspb.AlterCollectionRequest{
|
||||
Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_AlterCollection},
|
||||
CollectionName: "test_collection",
|
||||
DeleteKeys: []string{common.EnableDynamicSchemaKey},
|
||||
}}
|
||||
err := task.Prepare(context.Background())
|
||||
assert.Error(t, err)
|
||||
assert.ErrorIs(t, err, merr.ErrParameterInvalid)
|
||||
})
|
||||
|
||||
t.Run("normal case", func(t *testing.T) {
|
||||
task := &alterCollectionTask{
|
||||
Req: &milvuspb.AlterCollectionRequest{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user