mongo 2.16.3 → 2.17.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.md +1 -1
- data/lib/mongo/auth/aws/request.rb +0 -1
- data/lib/mongo/client.rb +4 -0
- data/lib/mongo/cluster/reapers/cursor_reaper.rb +26 -14
- data/lib/mongo/collection/view/aggregation.rb +62 -17
- data/lib/mongo/collection/view/builder/aggregation.rb +11 -13
- data/lib/mongo/collection/view/builder/map_reduce.rb +1 -1
- data/lib/mongo/collection/view/change_stream.rb +7 -3
- data/lib/mongo/collection/view/iterable.rb +2 -3
- data/lib/mongo/collection/view/map_reduce.rb +2 -0
- data/lib/mongo/collection/view/readable.rb +24 -1
- data/lib/mongo/collection/view/writable.rb +23 -0
- data/lib/mongo/collection.rb +21 -1
- data/lib/mongo/cursor/kill_spec.rb +19 -2
- data/lib/mongo/cursor.rb +5 -5
- data/lib/mongo/database/view.rb +4 -2
- data/lib/mongo/database.rb +6 -6
- data/lib/mongo/error/snapshot_session_invalid_server_version.rb +31 -0
- data/lib/mongo/error/snapshot_session_transaction_prohibited.rb +30 -0
- data/lib/mongo/error.rb +2 -0
- data/lib/mongo/operation/delete/op_msg.rb +2 -1
- data/lib/mongo/operation/find/builder/command.rb +1 -0
- data/lib/mongo/operation/result.rb +6 -0
- data/lib/mongo/operation/shared/executable.rb +4 -0
- data/lib/mongo/operation/shared/sessions_supported.rb +18 -2
- data/lib/mongo/operation/update/op_msg.rb +2 -1
- data/lib/mongo/server/description/features.rb +3 -1
- data/lib/mongo/server_selector/base.rb +26 -4
- data/lib/mongo/session.rb +19 -0
- data/lib/mongo/socket/ocsp_cache.rb +2 -3
- data/lib/mongo/socket.rb +1 -5
- data/lib/mongo/utils.rb +0 -6
- data/lib/mongo/version.rb +1 -1
- data/mongo.gemspec +1 -1
- data/spec/integration/read_preference_spec.rb +16 -12
- data/spec/mongo/cluster/cursor_reaper_spec.rb +22 -15
- data/spec/mongo/collection/view/aggregation_spec.rb +71 -95
- data/spec/mongo/collection/view/change_stream_spec.rb +1 -1
- data/spec/mongo/collection/view/map_reduce_spec.rb +14 -1
- data/spec/mongo/cursor_spec.rb +3 -2
- data/spec/mongo/operation/read_preference_op_msg_spec.rb +24 -1
- data/spec/mongo/server_selector_spec.rb +136 -15
- data/spec/mongo/socket/ssl_spec.rb +26 -58
- data/spec/mongo/utils_spec.rb +0 -14
- data/spec/runners/crud/verifier.rb +1 -2
- data/spec/runners/unified/assertions.rb +3 -1
- data/spec/runners/unified/crud_operations.rb +77 -23
- data/spec/runners/unified/ddl_operations.rb +29 -1
- data/spec/runners/unified/entity_map.rb +3 -3
- data/spec/runners/unified/support_operations.rb +6 -1
- data/spec/runners/unified/test.rb +15 -3
- data/spec/spec_tests/data/crud_unified/aggregate-let.yml +138 -0
- data/spec/spec_tests/data/crud_unified/aggregate-write-readPreference.yml +155 -0
- data/spec/spec_tests/data/crud_unified/db-aggregate-write-readPreference.yml +151 -0
- data/spec/spec_tests/data/crud_unified/deleteMany-let.yml +91 -0
- data/spec/spec_tests/data/crud_unified/deleteOne-let.yml +89 -0
- data/spec/spec_tests/data/crud_unified/find-let.yml +71 -0
- data/spec/spec_tests/data/crud_unified/findOneAndDelete-let.yml +88 -0
- data/spec/spec_tests/data/crud_unified/findOneAndReplace-let.yml +94 -0
- data/spec/spec_tests/data/crud_unified/findOneAndUpdate-let.yml +96 -0
- data/spec/spec_tests/data/crud_unified/updateMany-let.yml +103 -0
- data/spec/spec_tests/data/crud_unified/updateOne-let.yml +98 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/DefaultNoMaxStaleness.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/LastUpdateTime.yml +3 -3
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Nearest.yml +3 -3
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Nearest2.yml +3 -3
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred_tags.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Secondary.yml +4 -4
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred_tags.yml +4 -4
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/ZeroMaxStaleness.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/DefaultNoMaxStaleness.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/LastUpdateTime.yml +3 -3
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/LongHeartbeat.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/LongHeartbeat2.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/MaxStalenessTooSmall.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/MaxStalenessWithModePrimary.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Nearest.yml +3 -3
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Nearest2.yml +3 -3
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Nearest_tags.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags.yml +5 -5
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags2.yml +3 -3
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Secondary_tags.yml +5 -5
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Secondary_tags2.yml +3 -3
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/ZeroMaxStaleness.yml +2 -2
- data/spec/spec_tests/data/max_staleness/Sharded/SmallMaxStaleness.yml +2 -2
- data/spec/spec_tests/data/max_staleness/Single/SmallMaxStaleness.yml +1 -1
- data/spec/spec_tests/data/max_staleness/Unknown/SmallMaxStaleness.yml +1 -1
- data/spec/spec_tests/data/sessions_unified/snapshot-sessions-not-supported-client-error.yml +69 -0
- data/spec/spec_tests/data/sessions_unified/snapshot-sessions-not-supported-server-error.yml +102 -0
- data/spec/spec_tests/data/sessions_unified/snapshot-sessions-unsupported-ops.yml +258 -0
- data/spec/spec_tests/data/sessions_unified/snapshot-sessions.yml +482 -0
- data/spec/spec_tests/sessions_unified_spec.rb +13 -0
- data.tar.gz.sig +0 -0
- metadata +36 -2
- metadata.gz.sig +0 -0
@@ -0,0 +1,151 @@
|
|
1
|
+
description: db-aggregate-write-readPreference
|
2
|
+
|
3
|
+
schemaVersion: '1.4'
|
4
|
+
|
5
|
+
runOnRequirements:
|
6
|
+
# 3.6+ non-standalone is needed to utilize $readPreference in OP_MSG.
|
7
|
+
# Serverless does not support $listLocalSessions and $currentOp stages, and
|
8
|
+
# mongos does not allow combining them with $out or $merge.
|
9
|
+
- minServerVersion: "3.6"
|
10
|
+
topologies: [ replicaset ]
|
11
|
+
serverless: forbid
|
12
|
+
|
13
|
+
_yamlAnchors:
|
14
|
+
readConcern: &readConcern
|
15
|
+
level: &readConcernLevel "local"
|
16
|
+
writeConcern: &writeConcern
|
17
|
+
w: &writeConcernW 1
|
18
|
+
|
19
|
+
createEntities:
|
20
|
+
- client:
|
21
|
+
id: &client0 client0
|
22
|
+
observeEvents:
|
23
|
+
- commandStartedEvent
|
24
|
+
# Used to test that read and write concerns are still inherited
|
25
|
+
uriOptions:
|
26
|
+
readConcernLevel: *readConcernLevel
|
27
|
+
w: *writeConcernW
|
28
|
+
- database:
|
29
|
+
id: &database0 database0
|
30
|
+
client: *client0
|
31
|
+
databaseName: &database0Name db0
|
32
|
+
databaseOptions:
|
33
|
+
readPreference: &readPreference
|
34
|
+
# secondaryPreferred is specified for compatibility with clusters that
|
35
|
+
# may not have a secondary (e.g. each shard is only a primary).
|
36
|
+
mode: secondaryPreferred
|
37
|
+
# maxStalenessSeconds is specified to ensure that drivers forward the
|
38
|
+
# read preference to mongos or a load balancer. That would not be the
|
39
|
+
# case with only secondaryPreferred.
|
40
|
+
maxStalenessSeconds: 600
|
41
|
+
- collection:
|
42
|
+
id: &collection0 collection0
|
43
|
+
database: *database0
|
44
|
+
collectionName: &collection0Name coll0
|
45
|
+
|
46
|
+
initialData:
|
47
|
+
- collectionName: *collection0Name
|
48
|
+
databaseName: *database0Name
|
49
|
+
documents: []
|
50
|
+
|
51
|
+
tests:
|
52
|
+
- description: "Database-level aggregate with $out includes read preference for 5.0+ server"
|
53
|
+
runOnRequirements:
|
54
|
+
- minServerVersion: "5.0"
|
55
|
+
serverless: "forbid"
|
56
|
+
operations:
|
57
|
+
- object: *database0
|
58
|
+
name: aggregate
|
59
|
+
arguments:
|
60
|
+
pipeline: &outPipeline
|
61
|
+
- { $listLocalSessions: {} }
|
62
|
+
- { $limit: 1 }
|
63
|
+
- { $addFields: { _id: 1 } }
|
64
|
+
- { $project: { _id: 1 } }
|
65
|
+
- { $out: *collection0Name }
|
66
|
+
expectEvents:
|
67
|
+
- client: *client0
|
68
|
+
events:
|
69
|
+
- commandStartedEvent:
|
70
|
+
command:
|
71
|
+
aggregate: 1
|
72
|
+
pipeline: *outPipeline
|
73
|
+
$readPreference: *readPreference
|
74
|
+
readConcern: *readConcern
|
75
|
+
writeConcern: *writeConcern
|
76
|
+
outcome: &outcome
|
77
|
+
- collectionName: *collection0Name
|
78
|
+
databaseName: *database0Name
|
79
|
+
documents:
|
80
|
+
- { _id: 1 }
|
81
|
+
|
82
|
+
- description: "Database-level aggregate with $out omits read preference for pre-5.0 server"
|
83
|
+
runOnRequirements:
|
84
|
+
# MongoDB 4.2 introduced support for read concerns and write stages.
|
85
|
+
# Pre-4.2 servers may allow a "local" read concern anyway, but some
|
86
|
+
# drivers may avoid inheriting a client-level read concern for pre-4.2.
|
87
|
+
- minServerVersion: "4.2"
|
88
|
+
maxServerVersion: "4.4.99"
|
89
|
+
serverless: "forbid"
|
90
|
+
operations:
|
91
|
+
- object: *database0
|
92
|
+
name: aggregate
|
93
|
+
arguments:
|
94
|
+
pipeline: *outPipeline
|
95
|
+
expectEvents:
|
96
|
+
- client: *client0
|
97
|
+
events:
|
98
|
+
- commandStartedEvent:
|
99
|
+
command:
|
100
|
+
aggregate: 1
|
101
|
+
pipeline: *outPipeline
|
102
|
+
$readPreference: { $$exists: false }
|
103
|
+
readConcern: *readConcern
|
104
|
+
writeConcern: *writeConcern
|
105
|
+
outcome: *outcome
|
106
|
+
|
107
|
+
- description: "Database-level aggregate with $merge includes read preference for 5.0+ server"
|
108
|
+
runOnRequirements:
|
109
|
+
- minServerVersion: "5.0"
|
110
|
+
operations:
|
111
|
+
- object: *database0
|
112
|
+
name: aggregate
|
113
|
+
arguments:
|
114
|
+
pipeline: &mergePipeline
|
115
|
+
- { $listLocalSessions: {} }
|
116
|
+
- { $limit: 1 }
|
117
|
+
- { $addFields: { _id: 1 } }
|
118
|
+
- { $project: { _id: 1 } }
|
119
|
+
- { $merge: { into: *collection0Name } }
|
120
|
+
expectEvents:
|
121
|
+
- client: *client0
|
122
|
+
events:
|
123
|
+
- commandStartedEvent:
|
124
|
+
command:
|
125
|
+
aggregate: 1
|
126
|
+
pipeline: *mergePipeline
|
127
|
+
$readPreference: *readPreference
|
128
|
+
readConcern: *readConcern
|
129
|
+
writeConcern: *writeConcern
|
130
|
+
outcome: *outcome
|
131
|
+
|
132
|
+
- description: "Database-level aggregate with $merge omits read preference for pre-5.0 server"
|
133
|
+
runOnRequirements:
|
134
|
+
- minServerVersion: "4.2"
|
135
|
+
maxServerVersion: "4.4.99"
|
136
|
+
operations:
|
137
|
+
- object: *database0
|
138
|
+
name: aggregate
|
139
|
+
arguments:
|
140
|
+
pipeline: *mergePipeline
|
141
|
+
expectEvents:
|
142
|
+
- client: *client0
|
143
|
+
events:
|
144
|
+
- commandStartedEvent:
|
145
|
+
command:
|
146
|
+
aggregate: 1
|
147
|
+
pipeline: *mergePipeline
|
148
|
+
$readPreference: { $$exists: false }
|
149
|
+
readConcern: *readConcern
|
150
|
+
writeConcern: *writeConcern
|
151
|
+
outcome: *outcome
|
@@ -0,0 +1,91 @@
|
|
1
|
+
description: "deleteMany-let"
|
2
|
+
|
3
|
+
schemaVersion: "1.0"
|
4
|
+
|
5
|
+
createEntities:
|
6
|
+
- client:
|
7
|
+
id: &client0 client0
|
8
|
+
observeEvents: [ commandStartedEvent ]
|
9
|
+
- database:
|
10
|
+
id: &database0 database0
|
11
|
+
client: *client0
|
12
|
+
databaseName: &database0Name crud-tests
|
13
|
+
- collection:
|
14
|
+
id: &collection0 collection0
|
15
|
+
database: *database0
|
16
|
+
collectionName: &collection0Name coll0
|
17
|
+
|
18
|
+
initialData: &initialData
|
19
|
+
- collectionName: *collection0Name
|
20
|
+
databaseName: *database0Name
|
21
|
+
documents:
|
22
|
+
- { _id: 1 }
|
23
|
+
- { _id: 2, name: "name" }
|
24
|
+
- { _id: 3, name: "name" }
|
25
|
+
|
26
|
+
tests:
|
27
|
+
- description: "deleteMany with let option"
|
28
|
+
runOnRequirements:
|
29
|
+
- minServerVersion: "5.0"
|
30
|
+
operations:
|
31
|
+
- name: deleteMany
|
32
|
+
object: *collection0
|
33
|
+
arguments:
|
34
|
+
filter: &filter
|
35
|
+
$expr:
|
36
|
+
$eq: [ "$name", "$$name" ]
|
37
|
+
let: &let0
|
38
|
+
name: "name"
|
39
|
+
expectResult:
|
40
|
+
deletedCount: 2
|
41
|
+
expectEvents:
|
42
|
+
- client: *client0
|
43
|
+
events:
|
44
|
+
- commandStartedEvent:
|
45
|
+
command:
|
46
|
+
delete: *collection0Name
|
47
|
+
deletes:
|
48
|
+
-
|
49
|
+
q: *filter
|
50
|
+
let: *let0
|
51
|
+
outcome:
|
52
|
+
-
|
53
|
+
collectionName: *collection0Name
|
54
|
+
databaseName: *database0Name
|
55
|
+
documents:
|
56
|
+
- { _id: 1 }
|
57
|
+
|
58
|
+
- description: "deleteMany with let option unsupported (server-side error)"
|
59
|
+
runOnRequirements:
|
60
|
+
- minServerVersion: "3.6.0"
|
61
|
+
maxServerVersion: "4.4.99"
|
62
|
+
operations:
|
63
|
+
- name: deleteMany
|
64
|
+
object: *collection0
|
65
|
+
arguments:
|
66
|
+
filter: &filter1
|
67
|
+
$expr:
|
68
|
+
$eq: [ "$name", "$$name" ]
|
69
|
+
let: &let1
|
70
|
+
name: "name"
|
71
|
+
expectError:
|
72
|
+
errorContains: "'delete.let' is an unknown field"
|
73
|
+
isClientError: false
|
74
|
+
expectEvents:
|
75
|
+
- client: *client0
|
76
|
+
events:
|
77
|
+
- commandStartedEvent:
|
78
|
+
command:
|
79
|
+
delete: *collection0Name
|
80
|
+
deletes:
|
81
|
+
-
|
82
|
+
q: *filter1
|
83
|
+
let: *let1
|
84
|
+
outcome:
|
85
|
+
-
|
86
|
+
collectionName: *collection0Name
|
87
|
+
databaseName: *database0Name
|
88
|
+
documents:
|
89
|
+
- { _id: 1 }
|
90
|
+
- { _id: 2, name: "name" }
|
91
|
+
- { _id: 3, name: "name" }
|
@@ -0,0 +1,89 @@
|
|
1
|
+
description: "deleteOne-let"
|
2
|
+
|
3
|
+
schemaVersion: "1.0"
|
4
|
+
|
5
|
+
createEntities:
|
6
|
+
- client:
|
7
|
+
id: &client0 client0
|
8
|
+
observeEvents: [ commandStartedEvent ]
|
9
|
+
- database:
|
10
|
+
id: &database0 database0
|
11
|
+
client: *client0
|
12
|
+
databaseName: &database0Name crud-tests
|
13
|
+
- collection:
|
14
|
+
id: &collection0 collection0
|
15
|
+
database: *database0
|
16
|
+
collectionName: &collection0Name coll0
|
17
|
+
|
18
|
+
initialData: &initialData
|
19
|
+
- collectionName: *collection0Name
|
20
|
+
databaseName: *database0Name
|
21
|
+
documents:
|
22
|
+
- { _id: 1 }
|
23
|
+
- { _id: 2 }
|
24
|
+
|
25
|
+
tests:
|
26
|
+
- description: "deleteOne with let option"
|
27
|
+
runOnRequirements:
|
28
|
+
- minServerVersion: "5.0"
|
29
|
+
operations:
|
30
|
+
- name: deleteOne
|
31
|
+
object: *collection0
|
32
|
+
arguments:
|
33
|
+
filter: &filter
|
34
|
+
$expr:
|
35
|
+
$eq: [ "$_id", "$$id" ]
|
36
|
+
let: &let0
|
37
|
+
id: 1
|
38
|
+
expectResult:
|
39
|
+
deletedCount: 1
|
40
|
+
expectEvents:
|
41
|
+
- client: *client0
|
42
|
+
events:
|
43
|
+
- commandStartedEvent:
|
44
|
+
command:
|
45
|
+
delete: *collection0Name
|
46
|
+
deletes:
|
47
|
+
-
|
48
|
+
q: *filter
|
49
|
+
let: *let0
|
50
|
+
outcome:
|
51
|
+
-
|
52
|
+
collectionName: *collection0Name
|
53
|
+
databaseName: *database0Name
|
54
|
+
documents:
|
55
|
+
- { _id: 2 }
|
56
|
+
|
57
|
+
- description: "deleteOne with let option unsupported (server-side error)"
|
58
|
+
runOnRequirements:
|
59
|
+
- minServerVersion: "3.6.0"
|
60
|
+
maxServerVersion: "4.4.99"
|
61
|
+
operations:
|
62
|
+
- name: deleteOne
|
63
|
+
object: *collection0
|
64
|
+
arguments:
|
65
|
+
filter: &filter1
|
66
|
+
$expr:
|
67
|
+
$eq: [ "$_id", "$$id" ]
|
68
|
+
let: &let1
|
69
|
+
id: 1
|
70
|
+
expectError:
|
71
|
+
errorContains: "'delete.let' is an unknown field"
|
72
|
+
isClientError: false
|
73
|
+
expectEvents:
|
74
|
+
- client: *client0
|
75
|
+
events:
|
76
|
+
- commandStartedEvent:
|
77
|
+
command:
|
78
|
+
delete: *collection0Name
|
79
|
+
deletes:
|
80
|
+
-
|
81
|
+
q: *filter1
|
82
|
+
let: *let1
|
83
|
+
outcome:
|
84
|
+
-
|
85
|
+
collectionName: *collection0Name
|
86
|
+
databaseName: *database0Name
|
87
|
+
documents:
|
88
|
+
- { _id: 1 }
|
89
|
+
- { _id: 2 }
|
@@ -0,0 +1,71 @@
|
|
1
|
+
description: "find-let"
|
2
|
+
|
3
|
+
schemaVersion: "1.0"
|
4
|
+
|
5
|
+
createEntities:
|
6
|
+
- client:
|
7
|
+
id: &client0 client0
|
8
|
+
observeEvents: [ commandStartedEvent ]
|
9
|
+
- database:
|
10
|
+
id: &database0 database0
|
11
|
+
client: *client0
|
12
|
+
databaseName: &database0Name crud-tests
|
13
|
+
- collection:
|
14
|
+
id: &collection0 collection0
|
15
|
+
database: *database0
|
16
|
+
collectionName: &collection0Name coll0
|
17
|
+
|
18
|
+
initialData: &initialData
|
19
|
+
- collectionName: *collection0Name
|
20
|
+
databaseName: *database0Name
|
21
|
+
documents:
|
22
|
+
- { _id: 1 }
|
23
|
+
- { _id: 2 }
|
24
|
+
|
25
|
+
tests:
|
26
|
+
- description: "Find with let option"
|
27
|
+
runOnRequirements:
|
28
|
+
- minServerVersion: "5.0"
|
29
|
+
operations:
|
30
|
+
- name: find
|
31
|
+
object: *collection0
|
32
|
+
arguments:
|
33
|
+
filter: &filter
|
34
|
+
$expr:
|
35
|
+
$eq: [ "$_id", "$$id" ]
|
36
|
+
let: &let0
|
37
|
+
id: 1
|
38
|
+
expectResult:
|
39
|
+
- { _id: 1 }
|
40
|
+
expectEvents:
|
41
|
+
- client: *client0
|
42
|
+
events:
|
43
|
+
- commandStartedEvent:
|
44
|
+
command:
|
45
|
+
find: *collection0Name
|
46
|
+
filter: *filter
|
47
|
+
let: *let0
|
48
|
+
|
49
|
+
- description: "Find with let option unsupported (server-side error)"
|
50
|
+
runOnRequirements:
|
51
|
+
- minServerVersion: "3.6.0"
|
52
|
+
maxServerVersion: "4.4.99"
|
53
|
+
operations:
|
54
|
+
- name: find
|
55
|
+
object: *collection0
|
56
|
+
arguments:
|
57
|
+
filter: &filter1
|
58
|
+
_id: 1
|
59
|
+
let: &let1
|
60
|
+
x: 1
|
61
|
+
expectError:
|
62
|
+
errorContains: "Unrecognized field 'let'"
|
63
|
+
isClientError: false
|
64
|
+
expectEvents:
|
65
|
+
- client: *client0
|
66
|
+
events:
|
67
|
+
- commandStartedEvent:
|
68
|
+
command:
|
69
|
+
find: *collection0Name
|
70
|
+
filter: *filter1
|
71
|
+
let: *let1
|
@@ -0,0 +1,88 @@
|
|
1
|
+
description: "findOneAndDelete-let"
|
2
|
+
|
3
|
+
schemaVersion: "1.0"
|
4
|
+
|
5
|
+
createEntities:
|
6
|
+
- client:
|
7
|
+
id: &client0 client0
|
8
|
+
observeEvents: [ commandStartedEvent ]
|
9
|
+
- database:
|
10
|
+
id: &database0 database0
|
11
|
+
client: *client0
|
12
|
+
databaseName: &database0Name crud-tests
|
13
|
+
- collection:
|
14
|
+
id: &collection0 collection0
|
15
|
+
database: *database0
|
16
|
+
collectionName: &collection0Name coll0
|
17
|
+
|
18
|
+
initialData: &initialData
|
19
|
+
- collectionName: *collection0Name
|
20
|
+
databaseName: *database0Name
|
21
|
+
documents:
|
22
|
+
- { _id: 1 }
|
23
|
+
- { _id: 2 }
|
24
|
+
|
25
|
+
tests:
|
26
|
+
- description: "findOneAndDelete with let option"
|
27
|
+
runOnRequirements:
|
28
|
+
- minServerVersion: "5.0"
|
29
|
+
operations:
|
30
|
+
- name: findOneAndDelete
|
31
|
+
object: *collection0
|
32
|
+
arguments:
|
33
|
+
filter: &filter
|
34
|
+
$expr:
|
35
|
+
$eq: [ "$_id", "$$id" ]
|
36
|
+
let: &let0
|
37
|
+
id: 1
|
38
|
+
expectEvents:
|
39
|
+
- client: *client0
|
40
|
+
events:
|
41
|
+
- commandStartedEvent:
|
42
|
+
command:
|
43
|
+
findAndModify: *collection0Name
|
44
|
+
query: *filter
|
45
|
+
remove: true
|
46
|
+
let: *let0
|
47
|
+
outcome:
|
48
|
+
-
|
49
|
+
collectionName: *collection0Name
|
50
|
+
databaseName: *database0Name
|
51
|
+
documents:
|
52
|
+
- { _id: 2 }
|
53
|
+
|
54
|
+
- description: "findOneAndDelete with let option unsupported (server-side error)"
|
55
|
+
runOnRequirements:
|
56
|
+
- minServerVersion: "4.2.0"
|
57
|
+
maxServerVersion: "4.4.99"
|
58
|
+
operations:
|
59
|
+
- name: findOneAndDelete
|
60
|
+
object: *collection0
|
61
|
+
arguments:
|
62
|
+
filter: &filter1
|
63
|
+
$expr:
|
64
|
+
$eq: [ "$_id", "$$id" ]
|
65
|
+
let: &let1
|
66
|
+
id: 1
|
67
|
+
expectError:
|
68
|
+
# This error message is consistent between 4.2.x and 4.4.x servers.
|
69
|
+
# Older servers return a different error message.
|
70
|
+
errorContains: "field 'let' is an unknown field"
|
71
|
+
isClientError: false
|
72
|
+
expectEvents:
|
73
|
+
- client: *client0
|
74
|
+
events:
|
75
|
+
- commandStartedEvent:
|
76
|
+
command:
|
77
|
+
findAndModify: *collection0Name
|
78
|
+
query: *filter1
|
79
|
+
remove: true
|
80
|
+
let: *let1
|
81
|
+
outcome:
|
82
|
+
-
|
83
|
+
collectionName: *collection0Name
|
84
|
+
databaseName: *database0Name
|
85
|
+
documents:
|
86
|
+
- { _id: 1 }
|
87
|
+
- { _id: 2 }
|
88
|
+
|
@@ -0,0 +1,94 @@
|
|
1
|
+
description: "findOneAndReplace-let"
|
2
|
+
|
3
|
+
schemaVersion: "1.0"
|
4
|
+
|
5
|
+
createEntities:
|
6
|
+
- client:
|
7
|
+
id: &client0 client0
|
8
|
+
observeEvents: [ commandStartedEvent ]
|
9
|
+
- database:
|
10
|
+
id: &database0 database0
|
11
|
+
client: *client0
|
12
|
+
databaseName: &database0Name crud-tests
|
13
|
+
- collection:
|
14
|
+
id: &collection0 collection0
|
15
|
+
database: *database0
|
16
|
+
collectionName: &collection0Name coll0
|
17
|
+
|
18
|
+
initialData: &initialData
|
19
|
+
- collectionName: *collection0Name
|
20
|
+
databaseName: *database0Name
|
21
|
+
documents:
|
22
|
+
- { _id: 1 }
|
23
|
+
- { _id: 2 }
|
24
|
+
|
25
|
+
tests:
|
26
|
+
- description: "findOneAndReplace with let option"
|
27
|
+
runOnRequirements:
|
28
|
+
- minServerVersion: "5.0"
|
29
|
+
operations:
|
30
|
+
- name: findOneAndReplace
|
31
|
+
object: *collection0
|
32
|
+
arguments:
|
33
|
+
filter: &filter
|
34
|
+
$expr:
|
35
|
+
$eq: [ "$_id", "$$id" ]
|
36
|
+
replacement: &replacement
|
37
|
+
x: "x"
|
38
|
+
let: &let0
|
39
|
+
id: 1
|
40
|
+
expectResult:
|
41
|
+
_id: 1
|
42
|
+
expectEvents:
|
43
|
+
- client: *client0
|
44
|
+
events:
|
45
|
+
- commandStartedEvent:
|
46
|
+
command:
|
47
|
+
findAndModify: *collection0Name
|
48
|
+
query: *filter
|
49
|
+
update: *replacement
|
50
|
+
let: *let0
|
51
|
+
outcome:
|
52
|
+
-
|
53
|
+
collectionName: *collection0Name
|
54
|
+
databaseName: *database0Name
|
55
|
+
documents:
|
56
|
+
- { _id: 1, x: "x" }
|
57
|
+
- { _id: 2 }
|
58
|
+
|
59
|
+
- description: "findOneAndReplace with let option unsupported (server-side error)"
|
60
|
+
runOnRequirements:
|
61
|
+
- minServerVersion: "4.2.0"
|
62
|
+
maxServerVersion: "4.4.99"
|
63
|
+
operations:
|
64
|
+
- name: findOneAndReplace
|
65
|
+
object: *collection0
|
66
|
+
arguments:
|
67
|
+
filter: &filter1
|
68
|
+
$expr:
|
69
|
+
$eq: [ "$_id", "$$id" ]
|
70
|
+
replacement: &replacement1
|
71
|
+
x: "x"
|
72
|
+
let: &let1
|
73
|
+
id: 1
|
74
|
+
expectError:
|
75
|
+
# This error message is consistent between 4.2.x and 4.4.x servers.
|
76
|
+
# Older servers return a different error message.
|
77
|
+
errorContains: "field 'let' is an unknown field"
|
78
|
+
isClientError: false
|
79
|
+
expectEvents:
|
80
|
+
- client: *client0
|
81
|
+
events:
|
82
|
+
- commandStartedEvent:
|
83
|
+
command:
|
84
|
+
findAndModify: *collection0Name
|
85
|
+
query: *filter1
|
86
|
+
update: *replacement1
|
87
|
+
let: *let1
|
88
|
+
outcome:
|
89
|
+
-
|
90
|
+
collectionName: *collection0Name
|
91
|
+
databaseName: *database0Name
|
92
|
+
documents:
|
93
|
+
- { _id: 1 }
|
94
|
+
- { _id: 2 }
|
@@ -0,0 +1,96 @@
|
|
1
|
+
description: "findOneAndUpdate-let"
|
2
|
+
|
3
|
+
schemaVersion: "1.0"
|
4
|
+
|
5
|
+
createEntities:
|
6
|
+
- client:
|
7
|
+
id: &client0 client0
|
8
|
+
observeEvents: [ commandStartedEvent ]
|
9
|
+
- database:
|
10
|
+
id: &database0 database0
|
11
|
+
client: *client0
|
12
|
+
databaseName: &database0Name crud-tests
|
13
|
+
- collection:
|
14
|
+
id: &collection0 collection0
|
15
|
+
database: *database0
|
16
|
+
collectionName: &collection0Name coll0
|
17
|
+
|
18
|
+
initialData: &initialData
|
19
|
+
- collectionName: *collection0Name
|
20
|
+
databaseName: *database0Name
|
21
|
+
documents:
|
22
|
+
- { _id: 1 }
|
23
|
+
- { _id: 2 }
|
24
|
+
|
25
|
+
tests:
|
26
|
+
- description: "findOneAndUpdate with let option"
|
27
|
+
runOnRequirements:
|
28
|
+
- minServerVersion: "5.0"
|
29
|
+
operations:
|
30
|
+
- name: findOneAndUpdate
|
31
|
+
object: *collection0
|
32
|
+
arguments:
|
33
|
+
filter: &filter
|
34
|
+
$expr:
|
35
|
+
$eq: [ "$_id", "$$id" ]
|
36
|
+
update: &update
|
37
|
+
- $set: {x: "$$x" }
|
38
|
+
let: &let0
|
39
|
+
id: 1
|
40
|
+
x: "foo"
|
41
|
+
expectResult:
|
42
|
+
_id: 1
|
43
|
+
expectEvents:
|
44
|
+
- client: *client0
|
45
|
+
events:
|
46
|
+
- commandStartedEvent:
|
47
|
+
command:
|
48
|
+
findAndModify: *collection0Name
|
49
|
+
query: *filter
|
50
|
+
update: *update
|
51
|
+
let: *let0
|
52
|
+
outcome:
|
53
|
+
-
|
54
|
+
collectionName: *collection0Name
|
55
|
+
databaseName: *database0Name
|
56
|
+
documents:
|
57
|
+
- { _id: 1, x: "foo" }
|
58
|
+
- { _id: 2 }
|
59
|
+
|
60
|
+
- description: "findOneAndUpdate with let option unsupported (server-side error)"
|
61
|
+
runOnRequirements:
|
62
|
+
- minServerVersion: "4.2.0"
|
63
|
+
maxServerVersion: "4.4.99"
|
64
|
+
operations:
|
65
|
+
- name: findOneAndUpdate
|
66
|
+
object: *collection0
|
67
|
+
arguments:
|
68
|
+
filter: &filter1
|
69
|
+
$expr:
|
70
|
+
$eq: [ "$_id", "$$id" ]
|
71
|
+
update: &update1
|
72
|
+
- $set: {x: "$$x"}
|
73
|
+
let: &let1
|
74
|
+
id: 1
|
75
|
+
x: "foo"
|
76
|
+
expectError:
|
77
|
+
# This error message is consistent between 4.2.x and 4.4.x servers.
|
78
|
+
# Older servers return a different error message.
|
79
|
+
errorContains: "field 'let' is an unknown field"
|
80
|
+
isClientError: false
|
81
|
+
expectEvents:
|
82
|
+
- client: *client0
|
83
|
+
events:
|
84
|
+
- commandStartedEvent:
|
85
|
+
command:
|
86
|
+
findAndModify: *collection0Name
|
87
|
+
query: *filter1
|
88
|
+
update: *update1
|
89
|
+
let: *let1
|
90
|
+
outcome:
|
91
|
+
-
|
92
|
+
collectionName: *collection0Name
|
93
|
+
databaseName: *database0Name
|
94
|
+
documents:
|
95
|
+
- { _id: 1 }
|
96
|
+
- { _id: 2 }
|