mirror of https://github.com/milvus-io/milvus.git
Add error return with invalid bool expr (#12168)
Signed-off-by: fishpenguin <kun.yu@zilliz.com>pull/12178/head
parent
4121e31df1
commit
e9585625e6
|
@ -573,8 +573,10 @@ func (pc *parserContext) handleLeafValue(nodeRaw *ant_ast.Node, dataType schemap
|
|||
}
|
||||
if node.Value == 1 {
|
||||
gv.Val.(*planpb.GenericValue_BoolVal).BoolVal = true
|
||||
} else {
|
||||
} else if node.Value == 0 {
|
||||
gv.Val.(*planpb.GenericValue_BoolVal).BoolVal = false
|
||||
} else {
|
||||
return nil, fmt.Errorf("bool field should only match 0 or 1")
|
||||
}
|
||||
} else {
|
||||
return nil, fmt.Errorf("type mismatch")
|
||||
|
|
|
@ -253,6 +253,10 @@ func TestExprMultiRange_Str(t *testing.T) {
|
|||
"BoolN1 == 1",
|
||||
"BoolN1 == 0",
|
||||
}
|
||||
invalidExprs := []string{
|
||||
"BoolN1 == 2",
|
||||
"BoolN1 > 2",
|
||||
}
|
||||
|
||||
fields := []*schemapb.FieldSchema{
|
||||
{FieldID: 100, Name: "fakevec", DataType: schemapb.DataType_FloatVector},
|
||||
|
@ -283,6 +287,13 @@ func TestExprMultiRange_Str(t *testing.T) {
|
|||
dbgStr := proto.MarshalTextString(planProto)
|
||||
println(dbgStr)
|
||||
}
|
||||
for offset, exprStr := range invalidExprs {
|
||||
fmt.Printf("invalid case %d: %s\n", offset, exprStr)
|
||||
planProto, err := createQueryPlan(schema, exprStr, "fakevec", queryInfo)
|
||||
assert.Error(t, err)
|
||||
dbgStr := proto.MarshalTextString(planProto)
|
||||
println(dbgStr)
|
||||
}
|
||||
}
|
||||
|
||||
func TestExprFieldCompare_Str(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue