From b62748a1a640e64de217e3bb127aec1e44c8395f Mon Sep 17 00:00:00 2001 From: SimFG Date: Wed, 24 Jan 2024 11:27:06 +0800 Subject: [PATCH] fix: wrong format expr for the delete rest api (#30217) /kind improvement issue: #30092 Signed-off-by: SimFG --- internal/distributed/proxy/httpserver/utils.go | 2 +- internal/distributed/proxy/httpserver/utils_test.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/distributed/proxy/httpserver/utils.go b/internal/distributed/proxy/httpserver/utils.go index 2384ff2cee..8a8a330f4e 100644 --- a/internal/distributed/proxy/httpserver/utils.go +++ b/internal/distributed/proxy/httpserver/utils.go @@ -102,7 +102,7 @@ func convertRange(field *schemapb.FieldSchema, result gjson.Result) (string, err if err != nil { return "", err } - dataArray = append(dataArray, value) + dataArray = append(dataArray, fmt.Sprintf(`"%s"`, value)) } resultStr = joinArray(dataArray) } diff --git a/internal/distributed/proxy/httpserver/utils_test.go b/internal/distributed/proxy/httpserver/utils_test.go index 187e269b76..3333db1109 100644 --- a/internal/distributed/proxy/httpserver/utils_test.go +++ b/internal/distributed/proxy/httpserver/utils_test.go @@ -340,10 +340,11 @@ func TestPrimaryField(t *testing.T) { idStr = gjson.Get(jsonStr, "id") rangeStr, err = convertRange(&primaryField, idStr) assert.Equal(t, nil, err) - assert.Equal(t, "1,2,3", rangeStr) - filter, err = checkGetPrimaryKey(coll, idStr) + assert.Equal(t, `"1","2","3"`, rangeStr) + coll2 := generateCollectionSchema(schemapb.DataType_VarChar, false) + filter, err = checkGetPrimaryKey(coll2, idStr) assert.Equal(t, nil, err) - assert.Equal(t, "book_id in [1,2,3]", filter) + assert.Equal(t, `book_id in ["1","2","3"]`, filter) } func TestInsertWithDynamicFields(t *testing.T) {