Merge pull request #499 from mschoch/498
add support for parsing BoolFieldQuery from JSON
This commit is contained in:
commit
3da28dfbc1
|
@ -226,6 +226,15 @@ func ParseQuery(input []byte) (Query, error) {
|
||||||
}
|
}
|
||||||
return &rv, nil
|
return &rv, nil
|
||||||
}
|
}
|
||||||
|
_, hasBool := tmp["bool"]
|
||||||
|
if hasBool {
|
||||||
|
var rv BoolFieldQuery
|
||||||
|
err := json.Unmarshal(input, &rv)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &rv, nil
|
||||||
|
}
|
||||||
return nil, fmt.Errorf("unknown query type")
|
return nil, fmt.Errorf("unknown query type")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -170,6 +170,10 @@ func TestParseQuery(t *testing.T) {
|
||||||
input: []byte(`{"ids":["a","b","c"]}`),
|
input: []byte(`{"ids":["a","b","c"]}`),
|
||||||
output: NewDocIDQuery([]string{"a", "b", "c"}),
|
output: NewDocIDQuery([]string{"a", "b", "c"}),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
input: []byte(`{"bool": true}`),
|
||||||
|
output: NewBoolFieldQuery(true),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
input: []byte(`{"madeitup":"queryhere"}`),
|
input: []byte(`{"madeitup":"queryhere"}`),
|
||||||
output: nil,
|
output: nil,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user