0
0

Merge pull request #499 from mschoch/498

add support for parsing BoolFieldQuery from JSON
This commit is contained in:
Marty Schoch 2016-11-16 11:50:44 -05:00 committed by GitHub
commit 3da28dfbc1
2 changed files with 13 additions and 0 deletions

View File

@ -226,6 +226,15 @@ func ParseQuery(input []byte) (Query, error) {
}
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")
}

View File

@ -170,6 +170,10 @@ func TestParseQuery(t *testing.T) {
input: []byte(`{"ids":["a","b","c"]}`),
output: NewDocIDQuery([]string{"a", "b", "c"}),
},
{
input: []byte(`{"bool": true}`),
output: NewBoolFieldQuery(true),
},
{
input: []byte(`{"madeitup":"queryhere"}`),
output: nil,