未验证 提交 dc02c5b0 编写于 作者: C cai.zhang 提交者: GitHub

Fix bug for supporting single quotes (#24464)

Signed-off-by: Ncai.zhang <cai.zhang@zilliz.com>
上级 0fe83426
......@@ -951,10 +951,11 @@ func (v *ParserVisitor) getColumnInfoFromJSONIdentifier(identifier string) (*pla
if path == "" {
return nil, fmt.Errorf("invalid identifier: %s", identifier)
}
if strings.HasPrefix(path, "\"") && strings.HasSuffix(path, "\"") {
if (strings.HasPrefix(path, "\"") && strings.HasSuffix(path, "\"")) ||
(strings.HasPrefix(path, "'") && strings.HasSuffix(path, "'")) {
path = path[1 : len(path)-1]
} else if _, err := strconv.ParseInt(path, 10, 64); err != nil {
return nil, fmt.Errorf("json key must be enclosed in double quotes: \"%s\"", path)
return nil, fmt.Errorf("json key must be enclosed in double quotes or single quotes: \"%s\"", path)
}
nestedPath = append(nestedPath, path)
}
......
......@@ -892,6 +892,33 @@ func Test_JSONExpr(t *testing.T) {
RoundDecimal: 0,
})
assert.NoError(t, err)
expr = `A['B'] == "abc\"bbb\"cc"`
_, err = CreateSearchPlan(schema, expr, "FloatVectorField", &planpb.QueryInfo{
Topk: 0,
MetricType: "",
SearchParams: "",
RoundDecimal: 0,
})
assert.NoError(t, err)
expr = `A['B'] == 'abc"cba'`
_, err = CreateSearchPlan(schema, expr, "FloatVectorField", &planpb.QueryInfo{
Topk: 0,
MetricType: "",
SearchParams: "",
RoundDecimal: 0,
})
assert.NoError(t, err)
expr = `A['B'] == 'abc\"cba'`
_, err = CreateSearchPlan(schema, expr, "FloatVectorField", &planpb.QueryInfo{
Topk: 0,
MetricType: "",
SearchParams: "",
RoundDecimal: 0,
})
assert.NoError(t, err)
}
func Test_InvalidExprOnJSONField(t *testing.T) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册