Skip to content

Commit

Permalink
[pick] fix: Fix bug for parse expression that include quotes (#28417)
Browse files Browse the repository at this point in the history
master pr: #28416 
issue: #28365
Fix bug for parsing error when a string enclosed in single quotes in an
expression contains multiple double quotes.
such as:
```
expr = "tag == '\"blue\"'"
```

Signed-off-by: Cai Zhang <cai.zhang@zilliz.com>
  • Loading branch information
xiaocai2333 authored Nov 23, 2023
1 parent e7eeb1e commit a14bd96
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/indexcoord/index_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (ib *indexBuilder) run() {
for _, buildID := range buildIDs {
ok := ib.process(buildID)
if !ok {
log.Ctx(ib.ctx).Info("there is no IndexNode available or etcd is not serviceable, wait a minute...")
log.Ctx(ib.ctx).Info("there is no idle indexing node, wait a minute...")
break
}
}
Expand Down
1 change: 1 addition & 0 deletions internal/parser/planparserv2/plan_parser_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1577,6 +1577,7 @@ func Test_EscapeString(t *testing.T) {
`str2 like 'abc"def-%'`,
`str4 like "abc\367-%"`,
`str4 like "中国"`,
`tag == '"blue"'`,
}
for _, expr = range exprs {
_, err = CreateSearchPlan(schema, expr, "FloatVectorField", &planpb.QueryInfo{
Expand Down
2 changes: 1 addition & 1 deletion internal/parser/planparserv2/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func convertEscapeSingle(literal string) (string, error) {
b.WriteString(literal[start : end-1])
b.WriteString(`'`)
}
start = end
start = end + 1
}
b.WriteString(literal[end+1 : len(literal)-1])
b.WriteString(`"`)
Expand Down
7 changes: 7 additions & 0 deletions internal/parser/planparserv2/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ func Test_convertEscapeSingle(t *testing.T) {
{`"\\\\'"`, `\\'`},
{`"\\\\\'"`, `\\'`},
{`'"'`, `"`},
{`'""'`, `""`},
{`'"""'`, `"""`},
{`'"\""'`, `"""`},
{`'a"b\"c\\"d'`, `a"b"c\"d`},
{`"a\"b\"c\\\"d"`, `a"b"c\"d`},
{`'A "test"'`, `A "test"`},
{`"A \"test\""`, `A "test"`},
{`'\"'`, `"`},
{`'\\"'`, `\"`},
{`'\\\"'`, `\"`},
Expand Down

0 comments on commit a14bd96

Please sign in to comment.