Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
description: operator-matchAsDocument

schemaVersion: "1.13"

createEntities:
- client:
id: &client0 client0
- database:
id: &database0 database0
client: *client0
databaseName: &database0Name test
- collection:
id: &collection0 collection0
database: *database0
collectionName: &collection0Name coll0

initialData:
- collectionName: *collection0Name
databaseName: *database0Name
documents:
- { _id: 1, json: '{ "x": 1, "y": 2 }' }
# Documents with non-objects or invalid JSON
- { _id: 2, json: '1' }
- { _id: 3, json: '[ "foo" ]' }
- { _id: 4, json: '{ "x" }' }

tests:
- description: matchAsDocument with non-matching filter
operations:
- name: find
object: *collection0
arguments:
filter: { _id : 1 }
limit: 1
expectResult:
- { _id: 1, json: { $$matchAsDocument: { x: 1, y: "two" } } }
-
description: matchAsDocument evaluates special operators
operations:
- name: find
object: *collection0
arguments:
filter: { _id : 1 }
limit: 1
expectResult:
- { _id: 1, json: { $$matchAsDocument: { x: 1, y: { $$exists: false } } } }
-
description: matchAsDocument does not permit extra fields
operations:
- name: find
object: *collection0
arguments:
filter: { _id : 1 }
limit: 1
expectResult:
- { _id: 1, json: { $$matchAsDocument: { x: 1 } } }
-
description: matchAsDocument expects JSON object but given scalar
operations:
- name: find
object: *collection0
arguments:
filter: { _id : 2 }
limit: 1
expectResult:
# The following $$matchAsRoot expression would match any document, so
# this ensures the failure is due to the actual value.
- { _id: 2, json: &match_any_document { $$matchAsDocument: { $$matchAsRoot: { } } } }
-
description: matchAsDocument expects JSON object but given array
operations:
- name: find
object: *collection0
arguments:
filter: { _id : 3 }
limit: 1
expectResult:
- { _id: 3, json: *match_any_document }
-
description: matchAsDocument fails to decode Extended JSON
operations:
- name: find
object: *collection0
arguments:
filter: { _id : 4 }
limit: 1
expectResult:
- { _id: 4, json: *match_any_document }

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
description: operator-matchAsRoot

schemaVersion: "1.13"

createEntities:
- client:
id: &client0 client0
- database:
id: &database0 database0
client: *client0
databaseName: &database0Name test
- collection:
id: &collection0 collection0
database: *database0
collectionName: &collection0Name coll0

initialData:
- collectionName: *collection0Name
databaseName: *database0Name
documents:
- { _id: 1, x: { y: 2, z: 3 } }

tests:
-
description: matchAsRoot with nested document does not match
operations:
- name: find
object: *collection0
arguments:
filter: { _id : 1 }
limit: 1
expectResult:
- { _id: 1, x: { $$matchAsRoot: { y: 3 } } }
Loading
Loading