Skip to content

Commit f3fd620

Browse files
toriesmyrman
authored andcommitted
Allow AND/OR queries to contain a single expression
1 parent 74de312 commit f3fd620

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

schema/query/predicate_parser.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ func (p *predicateParser) parseExpression() (Expression, error) {
9797
if err != nil {
9898
return nil, fmt.Errorf("%s: %v", label, err)
9999
}
100-
if len(subExp) < 2 {
101-
return nil, fmt.Errorf("%s: two expressions or more required", label)
100+
if len(subExp) < 1 {
101+
return nil, fmt.Errorf("%s: one expressions or more required", label)
102102
}
103103
if label == opAnd {
104104
and := And(subExp)

schema/query/predicate_parser_test.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -288,23 +288,13 @@ func TestParse(t *testing.T) {
288288
{
289289
`{"$or": []}`,
290290
Predicate{},
291-
errors.New("char 10: $or: two expressions or more required"),
292-
},
293-
{
294-
`{"$or": [{"foo": "bar"}]}`,
295-
Predicate{},
296-
errors.New("char 24: $or: two expressions or more required"),
291+
errors.New("char 10: $or: one expressions or more required"),
297292
},
298293
{
299294
`{"$and": "foo"}`,
300295
Predicate{},
301296
errors.New("char 9: $and: expected '[' got '\"'"),
302297
},
303-
{
304-
`{"$and": [{"foo": "bar"}]}`,
305-
Predicate{},
306-
errors.New("char 25: $and: two expressions or more required"),
307-
},
308298
{
309299
`{"$and": ["foo", "bar"]}`,
310300
Predicate{},

0 commit comments

Comments
 (0)