@@ -19,7 +19,10 @@ initialData:
19
19
databaseName : *database0Name
20
20
documents :
21
21
- { _id: 1, json: '{ "x": 1, "y": 2 }' }
22
- - { _id: 2, json: '{ "x" }' }
22
+ # Documents with non-objects or invalid JSON
23
+ - { _id: 2, json: '1' }
24
+ - { _id: 3, json: '[ "foo" ]' }
25
+ - { _id: 4, json: '{ "x" }' }
23
26
24
27
tests :
25
28
- description : matchAsDocument with non-matching filter
@@ -52,12 +55,34 @@ tests:
52
55
expectResult :
53
56
- { _id: 1, json: { $$matchAsDocument: { x: 1 } } }
54
57
-
55
- description : matchAsDocument fails to decode Extended JSON
58
+ description : matchAsDocument expects JSON object but given scalar
56
59
operations :
57
60
- name : find
58
61
object : *collection0
59
62
arguments :
60
63
filter : { _id : 2 }
61
64
limit : 1
62
65
expectResult :
63
- - { _id: 2, json: { $$matchAsDocument: { x: 1 } } }
66
+ # The following $$matchAsRoot expression would match any document, so
67
+ # this ensures the failure is due to the actual value.
68
+ - { _id: 2, json: &match_any_document { $$matchAsDocument: { $$matchAsRoot: { } } } }
69
+ -
70
+ description : matchAsDocument expects JSON object but given array
71
+ operations :
72
+ - name : find
73
+ object : *collection0
74
+ arguments :
75
+ filter : { _id : 3 }
76
+ limit : 1
77
+ expectResult :
78
+ - { _id: 3, json: *match_any_document }
79
+ -
80
+ description : matchAsDocument fails to decode Extended JSON
81
+ operations :
82
+ - name : find
83
+ object : *collection0
84
+ arguments :
85
+ filter : { _id : 4 }
86
+ limit : 1
87
+ expectResult :
88
+ - { _id: 4, json: *match_any_document }
0 commit comments