Skip to content

Commit

Permalink
Fix QueryByPKs composes wrong expr when pk data has spaces
Browse files Browse the repository at this point in the history
Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia committed Nov 8, 2023
1 parent 79dc722 commit 95990bf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 2 additions & 2 deletions client/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ func PKs2Expr(backName string, ids entity.Column) string {
case entity.FieldTypeInt64:
expr = fmt.Sprintf("%s in %s", pkName, strings.Join(strings.Fields(fmt.Sprint(ids.FieldData().GetScalars().GetLongData().GetData())), ","))
case entity.FieldTypeVarChar:
data := ids.FieldData().GetScalars().GetData().(*schemapb.ScalarField_StringData).StringData.Data
data := ids.FieldData().GetScalars().GetData().(*schemapb.ScalarField_StringData).StringData.GetData()
for i := range data {
data[i] = fmt.Sprintf("\"%s\"", data[i])
}
expr = fmt.Sprintf("%s in %s", pkName, strings.Join(strings.Fields(fmt.Sprint(data)), ","))
expr = fmt.Sprintf("%s in [%s]", pkName, strings.Join(data, ","))
}
return expr
}
Expand Down
1 change: 0 additions & 1 deletion test/testcases/upsert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ func TestUpsertAutoID(t *testing.T) {
}

func TestUpsertVarcharPk(t *testing.T) {
t.Skip("https://github.com/milvus-io/milvus-sdk-go/issues/612")
/*
test upsert varchar pks
upsert after query
Expand Down

0 comments on commit 95990bf

Please sign in to comment.