mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 03:48:37 +08:00
Fix bug for supporting single quotes (#24464)
Signed-off-by: cai.zhang <cai.zhang@zilliz.com>
This commit is contained in:
parent
0fe8342648
commit
dc02c5b064
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user