fix: Fix bug for parsing expression that include quotes (#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>
pull/28364/head
cai.zhang 2023-11-23 17:18:32 +08:00 committed by GitHub
parent de13865769
commit 31f442915b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 2 deletions

View File

@ -191,7 +191,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
}
}

View File

@ -934,6 +934,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{

View File

@ -503,7 +503,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(`"`)

View File

@ -187,6 +187,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"`},
{`'\"'`, `"`},
{`'\\"'`, `\"`},
{`'\\\"'`, `\"`},