mongo 2.4.3 → 2.5.0.beta
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 +3 -2
- data.tar.gz.sig +0 -0
- data/lib/mongo.rb +3 -2
- data/lib/mongo/auth/cr.rb +6 -4
- data/lib/mongo/auth/cr/conversation.rb +33 -17
- data/lib/mongo/auth/ldap.rb +4 -2
- data/lib/mongo/auth/ldap/conversation.rb +19 -9
- data/lib/mongo/auth/scram.rb +7 -4
- data/lib/mongo/auth/scram/conversation.rb +62 -24
- data/lib/mongo/auth/user.rb +10 -0
- data/lib/mongo/auth/user/view.rb +44 -22
- data/lib/mongo/auth/x509.rb +4 -2
- data/lib/mongo/auth/x509/conversation.rb +19 -9
- data/lib/mongo/bulk_write.rb +33 -27
- data/lib/mongo/bulk_write/combineable.rb +5 -0
- data/lib/mongo/bulk_write/transformable.rb +2 -0
- data/lib/mongo/bulk_write/validatable.rb +4 -0
- data/lib/mongo/client.rb +123 -12
- data/lib/mongo/cluster.rb +52 -11
- data/lib/mongo/cluster/app_metadata.rb +8 -2
- data/lib/mongo/cluster/cursor_reaper.rb +0 -1
- data/lib/mongo/cluster/topology.rb +1 -1
- data/lib/mongo/collection.rb +114 -27
- data/lib/mongo/collection/view.rb +8 -2
- data/lib/mongo/collection/view/aggregation.rb +11 -7
- data/lib/mongo/collection/view/builder/aggregation.rb +5 -1
- data/lib/mongo/collection/view/builder/find_command.rb +5 -3
- data/lib/mongo/collection/view/builder/map_reduce.rb +11 -3
- data/lib/mongo/collection/view/builder/op_query.rb +1 -1
- data/lib/mongo/collection/view/change_stream.rb +160 -0
- data/lib/mongo/collection/view/change_stream/retryable.rb +57 -0
- data/lib/mongo/collection/view/iterable.rb +11 -10
- data/lib/mongo/collection/view/map_reduce.rb +22 -18
- data/lib/mongo/collection/view/readable.rb +51 -37
- data/lib/mongo/collection/view/writable.rb +72 -40
- data/lib/mongo/cursor.rb +25 -4
- data/lib/mongo/cursor/builder/get_more_command.rb +4 -2
- data/lib/mongo/database.rb +22 -11
- data/lib/mongo/database/view.rb +16 -12
- data/lib/mongo/error.rb +5 -0
- data/lib/mongo/error/invalid_session.rb +36 -0
- data/lib/mongo/error/missing_resume_token.rb +39 -0
- data/lib/mongo/error/operation_failure.rb +17 -0
- data/lib/mongo/error/parser.rb +3 -2
- data/lib/mongo/error/unknown_payload_type.rb +41 -0
- data/lib/mongo/error/unsupported_array_filters.rb +51 -0
- data/lib/mongo/error/unsupported_message_type.rb +23 -0
- data/lib/mongo/grid/fs_bucket.rb +5 -4
- data/lib/mongo/grid/stream/read.rb +3 -2
- data/lib/mongo/grid/stream/write.rb +2 -2
- data/lib/mongo/index/view.rb +35 -25
- data/lib/mongo/monitoring/event/secure.rb +14 -0
- data/lib/mongo/operation.rb +16 -0
- data/lib/mongo/operation/commands.rb +1 -0
- data/lib/mongo/operation/commands/aggregate.rb +9 -5
- data/lib/mongo/operation/commands/aggregate/result.rb +1 -1
- data/lib/mongo/operation/commands/collections_info.rb +6 -6
- data/lib/mongo/operation/commands/command.rb +2 -1
- data/lib/mongo/operation/commands/create.rb +6 -2
- data/lib/mongo/operation/commands/drop.rb +6 -2
- data/lib/mongo/operation/commands/drop_database.rb +6 -2
- data/lib/mongo/operation/commands/explain.rb +27 -0
- data/lib/mongo/operation/commands/explain/result.rb +52 -0
- data/lib/mongo/operation/commands/indexes.rb +1 -1
- data/lib/mongo/operation/commands/list_collections.rb +1 -1
- data/lib/mongo/operation/commands/list_collections/result.rb +1 -1
- data/lib/mongo/operation/commands/list_indexes.rb +1 -1
- data/lib/mongo/operation/commands/list_indexes/result.rb +1 -1
- data/lib/mongo/operation/commands/map_reduce.rb +8 -4
- data/lib/mongo/operation/commands/map_reduce/result.rb +13 -1
- data/lib/mongo/operation/commands/user_query.rb +1 -1
- data/lib/mongo/operation/commands/users_info.rb +6 -2
- data/lib/mongo/operation/executable.rb +4 -1
- data/lib/mongo/operation/read_preference.rb +10 -5
- data/lib/mongo/operation/result.rb +26 -2
- data/lib/mongo/operation/specifiable.rb +13 -1
- data/lib/mongo/operation/uses_command_op_msg.rb +47 -0
- data/lib/mongo/operation/write/bulk/bulkable.rb +4 -1
- data/lib/mongo/operation/write/bulk/insert/result.rb +4 -4
- data/lib/mongo/operation/write/command/create_index.rb +6 -1
- data/lib/mongo/operation/write/command/delete.rb +28 -4
- data/lib/mongo/operation/write/command/drop_index.rb +6 -1
- data/lib/mongo/operation/write/command/insert.rb +22 -18
- data/lib/mongo/operation/write/command/update.rb +24 -9
- data/lib/mongo/operation/write/command/writable.rb +14 -1
- data/lib/mongo/operation/write/insert.rb +4 -1
- data/lib/mongo/operation/write/insert/result.rb +2 -2
- data/lib/mongo/operation/write/update.rb +7 -1
- data/lib/mongo/operation/write/write_command_enabled.rb +20 -3
- data/lib/mongo/protocol.rb +3 -0
- data/lib/mongo/protocol/bit_vector.rb +2 -2
- data/lib/mongo/protocol/compressed.rb +135 -0
- data/lib/mongo/protocol/delete.rb +8 -6
- data/lib/mongo/protocol/get_more.rb +8 -6
- data/lib/mongo/protocol/insert.rb +8 -6
- data/lib/mongo/protocol/kill_cursors.rb +8 -6
- data/lib/mongo/protocol/message.rb +31 -3
- data/lib/mongo/protocol/msg.rb +172 -0
- data/lib/mongo/protocol/query.rb +26 -6
- data/lib/mongo/protocol/registry.rb +76 -0
- data/lib/mongo/protocol/reply.rb +10 -5
- data/lib/mongo/protocol/serializers.rb +224 -0
- data/lib/mongo/protocol/update.rb +8 -6
- data/lib/mongo/retryable.rb +4 -2
- data/lib/mongo/server.rb +6 -3
- data/lib/mongo/server/connectable.rb +1 -1
- data/lib/mongo/server/connection.rb +30 -8
- data/lib/mongo/server/description.rb +25 -1
- data/lib/mongo/server/description/features.rb +4 -1
- data/lib/mongo/server/monitor.rb +5 -0
- data/lib/mongo/server/monitor/connection.rb +50 -2
- data/lib/mongo/server_selector/nearest.rb +10 -4
- data/lib/mongo/server_selector/primary.rb +20 -0
- data/lib/mongo/server_selector/primary_preferred.rb +10 -4
- data/lib/mongo/server_selector/secondary.rb +10 -4
- data/lib/mongo/server_selector/secondary_preferred.rb +24 -4
- data/lib/mongo/session.rb +180 -0
- data/lib/mongo/session/server_session.rb +73 -0
- data/lib/mongo/session/session_pool.rb +161 -0
- data/lib/mongo/uri.rb +11 -0
- data/lib/mongo/version.rb +1 -1
- data/mongo.gemspec +2 -1
- data/spec/mongo/auth/cr_spec.rb +12 -0
- data/spec/mongo/auth/ldap_spec.rb +2 -0
- data/spec/mongo/auth/scram/conversation_spec.rb +6 -6
- data/spec/mongo/auth/scram_spec.rb +25 -1
- data/spec/mongo/auth/user/view_spec.rb +268 -76
- data/spec/mongo/auth/x509_spec.rb +2 -0
- data/spec/mongo/bulk_write_spec.rb +435 -5
- data/spec/mongo/client_spec.rb +356 -39
- data/spec/mongo/cluster/app_metadata_spec.rb +2 -2
- data/spec/mongo/cluster_spec.rb +176 -0
- data/spec/mongo/collection/view/aggregation_spec.rb +33 -12
- data/spec/mongo/collection/view/builder/find_command_spec.rb +46 -6
- data/spec/mongo/collection/view/change_stream_spec.rb +814 -0
- data/spec/mongo/collection/view/map_reduce_spec.rb +94 -17
- data/spec/mongo/collection/view/readable_spec.rb +3 -12
- data/spec/mongo/collection_spec.rb +1048 -42
- data/spec/mongo/cursor/builder/get_more_command_spec.rb +19 -0
- data/spec/mongo/cursor_spec.rb +2 -2
- data/spec/mongo/database_spec.rb +50 -1
- data/spec/mongo/grid/fs_bucket_spec.rb +225 -137
- data/spec/mongo/grid/stream/read_spec.rb +2 -2
- data/spec/mongo/index/view_spec.rb +146 -8
- data/spec/mongo/monitoring/event/secure_spec.rb +42 -0
- data/spec/mongo/operation/read/query_spec.rb +2 -1
- data/spec/mongo/operation/specifiable_spec.rb +2 -2
- data/spec/mongo/operation/write/command/delete_spec.rb +96 -13
- data/spec/mongo/operation/write/command/insert_spec.rb +111 -12
- data/spec/mongo/operation/write/command/update_spec.rb +93 -10
- data/spec/mongo/operation/write/delete_spec.rb +1 -1
- data/spec/mongo/operation/write/insert_spec.rb +1 -1
- data/spec/mongo/operation/write/update_spec.rb +1 -1
- data/spec/mongo/protocol/compressed_spec.rb +66 -0
- data/spec/mongo/protocol/delete_spec.rb +14 -0
- data/spec/mongo/protocol/get_more_spec.rb +14 -0
- data/spec/mongo/protocol/insert_spec.rb +14 -0
- data/spec/mongo/protocol/kill_cursors_spec.rb +14 -0
- data/spec/mongo/protocol/msg_spec.rb +499 -0
- data/spec/mongo/protocol/query_spec.rb +45 -0
- data/spec/mongo/protocol/registry_spec.rb +31 -0
- data/spec/mongo/protocol/reply_spec.rb +14 -0
- data/spec/mongo/protocol/update_spec.rb +14 -0
- data/spec/mongo/retryable_spec.rb +6 -2
- data/spec/mongo/sdam_spec.rb +4 -0
- data/spec/mongo/server/connection_spec.rb +4 -2
- data/spec/mongo/server/description_spec.rb +28 -1
- data/spec/mongo/session/server_session_spec.rb +16 -0
- data/spec/mongo/session/session_pool_spec.rb +194 -0
- data/spec/mongo/uri_spec.rb +31 -2
- data/spec/spec_helper.rb +104 -0
- data/spec/support/authorization.rb +6 -1
- data/spec/support/crud.rb +3 -1
- data/spec/support/crud/write.rb +6 -1
- data/spec/support/crud_tests/write/findOneAndUpdate-arrayFilters.yml +69 -0
- data/spec/support/crud_tests/write/updateMany-arrayFilters.yml +63 -0
- data/spec/support/crud_tests/write/updateOne-arrayFilters.yml +109 -0
- data/spec/support/sdam/rs/discover_arbiters.yml +1 -1
- data/spec/support/sdam/rs/discover_passives.yml +2 -2
- data/spec/support/sdam/rs/discover_primary.yml +1 -1
- data/spec/support/sdam/rs/discover_secondary.yml +1 -1
- data/spec/support/sdam/rs/discovery.yml +4 -4
- data/spec/support/sdam/rs/equal_electionids.yml +1 -0
- data/spec/support/sdam/rs/ghost_discovered.yml +1 -1
- data/spec/support/sdam/rs/hosts_differ_from_seeds.yml +1 -1
- data/spec/support/sdam/rs/ls_timeout.yml +88 -0
- data/spec/support/sdam/rs/member_reconfig.yml +2 -2
- data/spec/support/sdam/rs/member_standalone.yml +2 -2
- data/spec/support/sdam/rs/new_primary.yml +2 -2
- data/spec/support/sdam/rs/new_primary_new_electionid.yml +3 -0
- data/spec/support/sdam/rs/new_primary_new_setversion.yml +3 -0
- data/spec/support/sdam/rs/new_primary_wrong_set_name.yml +2 -2
- data/spec/support/sdam/rs/non_rs_member.yml +1 -1
- data/spec/support/sdam/rs/normalize_case.yml +1 -1
- data/spec/support/sdam/rs/null_election_id.yml +4 -0
- data/spec/support/sdam/rs/primary_becomes_standalone.yml +2 -2
- data/spec/support/sdam/rs/primary_changes_set_name.yml +2 -2
- data/spec/support/sdam/rs/primary_disconnect.yml +2 -2
- data/spec/support/sdam/rs/primary_disconnect_electionid.yml +5 -0
- data/spec/support/sdam/rs/primary_disconnect_setversion.yml +5 -0
- data/spec/support/sdam/rs/primary_hint_from_secondary_with_mismatched_me.yml +58 -0
- data/spec/support/sdam/rs/primary_reports_new_member.yml +4 -4
- data/spec/support/sdam/rs/primary_to_no_primary_mismatched_me.yml +2 -2
- data/spec/support/sdam/rs/primary_wrong_set_name.yml +1 -1
- data/spec/support/sdam/rs/response_from_removed.yml +2 -2
- data/spec/support/sdam/rs/rsother_discovered.yml +1 -1
- data/spec/support/sdam/rs/sec_not_auth.yml +1 -1
- data/spec/support/sdam/rs/secondary_wrong_set_name.yml +1 -1
- data/spec/support/sdam/rs/secondary_wrong_set_name_with_primary.yml +2 -2
- data/spec/support/sdam/rs/setversion_without_electionid.yml +2 -0
- data/spec/support/sdam/rs/stepdown_change_set_name.yml +2 -2
- data/spec/support/sdam/rs/unexpected_mongos.yml +1 -1
- data/spec/support/sdam/rs/use_setversion_without_electionid.yml +3 -0
- data/spec/support/sdam/rs/wrong_set_name.yml +1 -1
- data/spec/support/sdam/sharded/ls_timeout_mongos.yml +97 -0
- data/spec/support/sdam/sharded/mongos_disconnect.yml +3 -3
- data/spec/support/sdam/sharded/multiple_mongoses.yml +1 -1
- data/spec/support/sdam/sharded/non_mongos_removed.yml +1 -1
- data/spec/support/sdam/sharded/normalize_uri_case.yml +1 -1
- data/spec/support/sdam/single/direct_connection_external_ip.yml +1 -1
- data/spec/support/sdam/single/direct_connection_mongos.yml +1 -1
- data/spec/support/sdam/single/direct_connection_rsarbiter.yml +1 -1
- data/spec/support/sdam/single/direct_connection_rsprimary.yml +1 -1
- data/spec/support/sdam/single/direct_connection_rssecondary.yml +1 -1
- data/spec/support/sdam/single/direct_connection_slave.yml +1 -1
- data/spec/support/sdam/single/direct_connection_standalone.yml +1 -1
- data/spec/support/sdam/single/ls_timeout_standalone.yml +35 -0
- data/spec/support/sdam/single/not_ok_response.yml +1 -1
- data/spec/support/sdam/single/standalone_removed.yml +1 -1
- data/spec/support/sdam/single/unavailable_seed.yml +1 -1
- data/spec/support/server_discovery_and_monitoring.rb +4 -0
- data/spec/support/shared/session.rb +236 -0
- metadata +53 -15
- metadata.gz.sig +0 -0
data/spec/spec_helper.rb
CHANGED
@@ -133,6 +133,35 @@ def single_seed?
|
|
133
133
|
ADDRESSES.size == 1
|
134
134
|
end
|
135
135
|
|
136
|
+
# For instances where behaviour is different on different versions, we need to
|
137
|
+
# determine in the specs if we are 3.6 or higher.
|
138
|
+
#
|
139
|
+
# @since 2.5.0
|
140
|
+
def op_msg_enabled?
|
141
|
+
$mongo_client ||= initialize_scanned_client!
|
142
|
+
$op_msg_enabled ||= $mongo_client.cluster.servers.first.features.op_msg_enabled?
|
143
|
+
end
|
144
|
+
alias :change_stream_enabled? :op_msg_enabled?
|
145
|
+
alias :sessions_enabled? :op_msg_enabled?
|
146
|
+
|
147
|
+
# Whether change streams can be tested. Change streams are available on server versions 3.6
|
148
|
+
# and higher and when connected to a replica set.
|
149
|
+
#
|
150
|
+
# @since 2.5.0
|
151
|
+
def test_change_streams?
|
152
|
+
!BSON::Environment.jruby? && change_stream_enabled? & replica_set?
|
153
|
+
end
|
154
|
+
|
155
|
+
# For instances where behaviour is different on different versions, we need to
|
156
|
+
# determine in the specs if we are 3.6 or higher.
|
157
|
+
#
|
158
|
+
# @since 2.5.0
|
159
|
+
def array_filters_enabled?
|
160
|
+
$mongo_client ||= initialize_scanned_client!
|
161
|
+
$array_filters_enabled ||= $mongo_client.cluster.servers.first.features.array_filters_enabled?
|
162
|
+
end
|
163
|
+
|
164
|
+
|
136
165
|
# For instances where behaviour is different on different versions, we need to
|
137
166
|
# determine in the specs if we are 3.4 or higher.
|
138
167
|
#
|
@@ -183,6 +212,21 @@ def running_ssl?
|
|
183
212
|
SSL
|
184
213
|
end
|
185
214
|
|
215
|
+
# Is the test suite using compression.
|
216
|
+
#
|
217
|
+
# @since 2.5.0
|
218
|
+
def compression_enabled?
|
219
|
+
COMPRESSORS[:compressors]
|
220
|
+
end
|
221
|
+
|
222
|
+
# Is the test suite testing compression.
|
223
|
+
# Requires that the server supports compression and compression is used by the test client.
|
224
|
+
#
|
225
|
+
# @since 2.5.0
|
226
|
+
def testing_compression?
|
227
|
+
compression_enabled? && op_msg_enabled?
|
228
|
+
end
|
229
|
+
|
186
230
|
alias :scram_sha_1_enabled? :list_command_enabled?
|
187
231
|
|
188
232
|
# Depending on whether write commands are enabled, there are different documents that
|
@@ -217,5 +261,65 @@ def initialize_scanned_client!
|
|
217
261
|
Mongo::Client.new(ADDRESSES, TEST_OPTIONS.merge(database: TEST_DB))
|
218
262
|
end
|
219
263
|
|
264
|
+
# Test event subscriber.
|
265
|
+
#
|
266
|
+
# @since 2.5.0
|
267
|
+
class EventSubscriber
|
268
|
+
|
269
|
+
# The started events.
|
270
|
+
#
|
271
|
+
# @since 2.5.0
|
272
|
+
attr_reader :started_events
|
273
|
+
|
274
|
+
# The succeeded events.
|
275
|
+
#
|
276
|
+
# @since 2.5.0
|
277
|
+
attr_reader :succeeded_events
|
278
|
+
|
279
|
+
# The failed events.
|
280
|
+
#
|
281
|
+
# @since 2.5.0
|
282
|
+
attr_reader :failed_events
|
283
|
+
|
284
|
+
# Create the test event subscriber.
|
285
|
+
#
|
286
|
+
# @example Create the subscriber
|
287
|
+
# EventSubscriber.new
|
288
|
+
#
|
289
|
+
# @since 2.5.0
|
290
|
+
def initialize
|
291
|
+
@started_events = []
|
292
|
+
@succeeded_events = []
|
293
|
+
@failed_events = []
|
294
|
+
end
|
295
|
+
|
296
|
+
# Cache the succeeded event.
|
297
|
+
#
|
298
|
+
# @param [ Event ] event The event.
|
299
|
+
#
|
300
|
+
# @since 2.5.0
|
301
|
+
def succeeded(event)
|
302
|
+
@succeeded_events.push(event)
|
303
|
+
end
|
304
|
+
|
305
|
+
# Cache the started event.
|
306
|
+
#
|
307
|
+
# @param [ Event ] event The event.
|
308
|
+
#
|
309
|
+
# @since 2.5.0
|
310
|
+
def started(event)
|
311
|
+
@started_events.push(event)
|
312
|
+
end
|
313
|
+
|
314
|
+
# Cache the failed event.
|
315
|
+
#
|
316
|
+
# @param [ Event ] event The event.
|
317
|
+
#
|
318
|
+
# @since 2.5.0
|
319
|
+
def failed(event)
|
320
|
+
@failed_events.push(event)
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
220
324
|
# require all shared examples
|
221
325
|
Dir['./spec/support/shared/*.rb'].sort.each { |file| require file }
|
@@ -62,6 +62,11 @@ INVALID_WRITE_CONCERN = { w: 4 }
|
|
62
62
|
# @since 2.0.3
|
63
63
|
SSL = (ENV['SSL'] == 'ssl') || (ENV['SSL_ENABLED'] == 'true')
|
64
64
|
|
65
|
+
# What compressor to use, if any.
|
66
|
+
#
|
67
|
+
# @since 2.5.0
|
68
|
+
COMPRESSORS = ENV['COMPRESSORS'] ? { compressors: ENV['COMPRESSORS'].split(',') } : {}
|
69
|
+
|
65
70
|
# SSL options.
|
66
71
|
#
|
67
72
|
# @since 2.1.0
|
@@ -87,7 +92,7 @@ BASE_OPTIONS = {
|
|
87
92
|
# Options for test suite clients.
|
88
93
|
#
|
89
94
|
# @since 2.0.3
|
90
|
-
TEST_OPTIONS = BASE_OPTIONS.merge(CONNECT).merge(SSL_OPTIONS)
|
95
|
+
TEST_OPTIONS = BASE_OPTIONS.merge(CONNECT).merge(SSL_OPTIONS).merge(COMPRESSORS)
|
91
96
|
|
92
97
|
# The root user name.
|
93
98
|
#
|
data/spec/support/crud.rb
CHANGED
@@ -114,7 +114,9 @@ module Mongo
|
|
114
114
|
|
115
115
|
def lower_bound_satisfied?(client)
|
116
116
|
if @min_server_version
|
117
|
-
if @min_server_version >= '3.
|
117
|
+
if @min_server_version >= '3.6'
|
118
|
+
client.cluster.next_primary.features.array_filters_enabled?
|
119
|
+
elsif @min_server_version >= '3.4'
|
118
120
|
client.cluster.next_primary.features.collation_enabled?
|
119
121
|
elsif @min_server_version >= '2.6'
|
120
122
|
client.cluster.next_primary.features.write_command_enabled?
|
data/spec/support/crud/write.rb
CHANGED
@@ -48,7 +48,8 @@ module Mongo
|
|
48
48
|
:upsert => 'upsert',
|
49
49
|
:ordered => 'ordered',
|
50
50
|
:write_concern => 'writeConcern',
|
51
|
-
:collation => 'collation'
|
51
|
+
:collation => 'collation',
|
52
|
+
:array_filters => 'arrayFilters'
|
52
53
|
}.freeze
|
53
54
|
|
54
55
|
# The operation name.
|
@@ -199,6 +200,10 @@ module Mongo
|
|
199
200
|
arguments['filter']
|
200
201
|
end
|
201
202
|
|
203
|
+
def array_filters
|
204
|
+
arguments['arrayFilters']
|
205
|
+
end
|
206
|
+
|
202
207
|
def requests
|
203
208
|
arguments['requests'].map do |request|
|
204
209
|
case request.keys.first
|
@@ -0,0 +1,69 @@
|
|
1
|
+
data:
|
2
|
+
- {_id: 1, y: [{b: 3}, {b: 1}]}
|
3
|
+
- {_id: 2, y: [{b: 0}, {b: 1}]}
|
4
|
+
minServerVersion: '3.6'
|
5
|
+
|
6
|
+
tests:
|
7
|
+
-
|
8
|
+
description: "FindOneAndUpdate when no document matches arrayFilters"
|
9
|
+
operation:
|
10
|
+
name: findOneAndUpdate
|
11
|
+
arguments:
|
12
|
+
filter: {}
|
13
|
+
update:
|
14
|
+
$set: {"y.$[i].b": 2}
|
15
|
+
arrayFilters:
|
16
|
+
- {i.b: 4}
|
17
|
+
|
18
|
+
outcome:
|
19
|
+
result:
|
20
|
+
_id: 1
|
21
|
+
y:
|
22
|
+
- {b: 3}
|
23
|
+
- {b: 1}
|
24
|
+
collection:
|
25
|
+
data:
|
26
|
+
- {_id: 1, y: [{b: 3}, {b: 1}]}
|
27
|
+
- {_id: 2, y: [{b: 0}, {b: 1}]}
|
28
|
+
-
|
29
|
+
description: "FindOneAndUpdate when one document matches arrayFilters"
|
30
|
+
operation:
|
31
|
+
name: findOneAndUpdate
|
32
|
+
arguments:
|
33
|
+
filter: {}
|
34
|
+
update:
|
35
|
+
$set: {"y.$[i].b": 2}
|
36
|
+
arrayFilters:
|
37
|
+
- {i.b: 3}
|
38
|
+
|
39
|
+
outcome:
|
40
|
+
result:
|
41
|
+
_id: 1
|
42
|
+
y:
|
43
|
+
- {b: 3}
|
44
|
+
- {b: 1}
|
45
|
+
collection:
|
46
|
+
data:
|
47
|
+
- {_id: 1, y: [{b: 2}, {b: 1}]}
|
48
|
+
- {_id: 2, y: [{b: 0}, {b: 1}]}
|
49
|
+
-
|
50
|
+
description: "FindOneAndUpdate when multiple documents match arrayFilters"
|
51
|
+
operation:
|
52
|
+
name: findOneAndUpdate
|
53
|
+
arguments:
|
54
|
+
filter: {}
|
55
|
+
update:
|
56
|
+
$set: {"y.$[i].b": 2}
|
57
|
+
arrayFilters:
|
58
|
+
- {i.b: 1}
|
59
|
+
|
60
|
+
outcome:
|
61
|
+
result:
|
62
|
+
_id: 1
|
63
|
+
y:
|
64
|
+
- {b: 3}
|
65
|
+
- {b: 1}
|
66
|
+
collection:
|
67
|
+
data:
|
68
|
+
- {_id: 1, y: [{b: 3}, {b: 2}]}
|
69
|
+
- {_id: 2, y: [{b: 0}, {b: 1}]}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
data:
|
2
|
+
- {_id: 1, y: [{b: 3}, {b: 1}]}
|
3
|
+
- {_id: 2, y: [{b: 0}, {b: 1}]}
|
4
|
+
minServerVersion: '3.6'
|
5
|
+
|
6
|
+
tests:
|
7
|
+
-
|
8
|
+
description: "UpdateMany when no documents match arrayFilters"
|
9
|
+
operation:
|
10
|
+
name: "updateMany"
|
11
|
+
arguments:
|
12
|
+
filter: {}
|
13
|
+
update:
|
14
|
+
$set: {"y.$[i].b": 2}
|
15
|
+
arrayFilters:
|
16
|
+
- {i.b: 4}
|
17
|
+
|
18
|
+
outcome:
|
19
|
+
result:
|
20
|
+
matchedCount: 2
|
21
|
+
modifiedCount: 0
|
22
|
+
collection:
|
23
|
+
data:
|
24
|
+
- {_id: 1, y: [{b: 3}, {b: 1}]}
|
25
|
+
- {_id: 2, y: [{b: 0}, {b: 1}]}
|
26
|
+
-
|
27
|
+
description: "UpdateMany when one document matches arrayFilters"
|
28
|
+
operation:
|
29
|
+
name: "updateMany"
|
30
|
+
arguments:
|
31
|
+
filter: {}
|
32
|
+
update:
|
33
|
+
$set: {"y.$[i].b": 2}
|
34
|
+
arrayFilters:
|
35
|
+
- {i.b: 3}
|
36
|
+
|
37
|
+
outcome:
|
38
|
+
result:
|
39
|
+
matchedCount: 2
|
40
|
+
modifiedCount: 1
|
41
|
+
collection:
|
42
|
+
data:
|
43
|
+
- {_id: 1, y: [{b: 2}, {b: 1}]}
|
44
|
+
- {_id: 2, y: [{b: 0}, {b: 1}]}
|
45
|
+
-
|
46
|
+
description: "UpdateMany when multiple documents match arrayFilters"
|
47
|
+
operation:
|
48
|
+
name: "updateMany"
|
49
|
+
arguments:
|
50
|
+
filter: {}
|
51
|
+
update:
|
52
|
+
$set: {"y.$[i].b": 2}
|
53
|
+
arrayFilters:
|
54
|
+
- {i.b: 1}
|
55
|
+
|
56
|
+
outcome:
|
57
|
+
result:
|
58
|
+
matchedCount: 2
|
59
|
+
modifiedCount: 2
|
60
|
+
collection:
|
61
|
+
data:
|
62
|
+
- {_id: 1, y: [{b: 3}, {b: 2}]}
|
63
|
+
- {_id: 2, y: [{b: 0}, {b: 2}]}
|
@@ -0,0 +1,109 @@
|
|
1
|
+
data:
|
2
|
+
- {_id: 1, y: [{b: 3}, {b: 1}]}
|
3
|
+
- {_id: 2, y: [{b: 0}, {b: 1}]}
|
4
|
+
- {_id: 3, y: [{b: 5, c: [{d: 2}, {d: 1}] }]}
|
5
|
+
minServerVersion: '3.6'
|
6
|
+
|
7
|
+
tests:
|
8
|
+
-
|
9
|
+
description: "UpdateOne when no document matches arrayFilters"
|
10
|
+
operation:
|
11
|
+
name: "updateOne"
|
12
|
+
arguments:
|
13
|
+
filter: {}
|
14
|
+
update:
|
15
|
+
$set: {"y.$[i].b": 2}
|
16
|
+
arrayFilters:
|
17
|
+
- {i.b: 4}
|
18
|
+
|
19
|
+
outcome:
|
20
|
+
result:
|
21
|
+
matchedCount: 1
|
22
|
+
modifiedCount: 0
|
23
|
+
collection:
|
24
|
+
data:
|
25
|
+
- {_id: 1, y: [{b: 3}, {b: 1}]}
|
26
|
+
- {_id: 2, y: [{b: 0}, {b: 1}]}
|
27
|
+
- {_id: 3, y: [{b: 5, c: [{d: 2}, {d: 1}] }]}
|
28
|
+
-
|
29
|
+
description: "UpdateOne when one document matches arrayFilters"
|
30
|
+
operation:
|
31
|
+
name: "updateOne"
|
32
|
+
arguments:
|
33
|
+
filter: {}
|
34
|
+
update:
|
35
|
+
$set: {"y.$[i].b": 2}
|
36
|
+
arrayFilters:
|
37
|
+
- {i.b: 3}
|
38
|
+
|
39
|
+
outcome:
|
40
|
+
result:
|
41
|
+
matchedCount: 1
|
42
|
+
modifiedCount: 1
|
43
|
+
collection:
|
44
|
+
data:
|
45
|
+
- {_id: 1, y: [{b: 2}, {b: 1}]}
|
46
|
+
- {_id: 2, y: [{b: 0}, {b: 1}]}
|
47
|
+
- {_id: 3, y: [{b: 5, c: [{d: 2}, {d: 1}] }]}
|
48
|
+
-
|
49
|
+
description: "UpdateOne when multiple documents match arrayFilters"
|
50
|
+
operation:
|
51
|
+
name: "updateOne"
|
52
|
+
arguments:
|
53
|
+
filter: {}
|
54
|
+
update:
|
55
|
+
$set: {"y.$[i].b": 2}
|
56
|
+
arrayFilters:
|
57
|
+
- {i.b: 1}
|
58
|
+
|
59
|
+
outcome:
|
60
|
+
result:
|
61
|
+
matchedCount: 1
|
62
|
+
modifiedCount: 1
|
63
|
+
collection:
|
64
|
+
data:
|
65
|
+
- {_id: 1, y: [{b: 3}, {b: 2}]}
|
66
|
+
- {_id: 2, y: [{b: 0}, {b: 1}]}
|
67
|
+
- {_id: 3, y: [{b: 5, c: [{d: 2}, {d: 1}] }]}
|
68
|
+
-
|
69
|
+
description: "UpdateOne when no documents match multiple arrayFilters"
|
70
|
+
operation:
|
71
|
+
name: "updateOne"
|
72
|
+
arguments:
|
73
|
+
filter: {_id: 3}
|
74
|
+
update:
|
75
|
+
$set: {"y.$[i].c.$[j].d": 0}
|
76
|
+
arrayFilters:
|
77
|
+
- {i.b: 5}
|
78
|
+
- {j.d: 3}
|
79
|
+
|
80
|
+
outcome:
|
81
|
+
result:
|
82
|
+
matchedCount: 1
|
83
|
+
modifiedCount: 0
|
84
|
+
collection:
|
85
|
+
data:
|
86
|
+
- {_id: 1, y: [{b: 3}, {b: 1}]}
|
87
|
+
- {_id: 2, y: [{b: 0}, {b: 1}]}
|
88
|
+
- {_id: 3, y: [{b: 5, c: [{d: 2}, {d: 1}] }]}
|
89
|
+
-
|
90
|
+
description: "UpdateOne when one document matches multiple arrayFilters"
|
91
|
+
operation:
|
92
|
+
name: "updateOne"
|
93
|
+
arguments:
|
94
|
+
filter: {_id: 3}
|
95
|
+
update:
|
96
|
+
$set: {"y.$[i].c.$[j].d": 0}
|
97
|
+
arrayFilters:
|
98
|
+
- {i.b: 5}
|
99
|
+
- {j.d: 1}
|
100
|
+
|
101
|
+
outcome:
|
102
|
+
result:
|
103
|
+
matchedCount: 1
|
104
|
+
modifiedCount: 1
|
105
|
+
collection:
|
106
|
+
data:
|
107
|
+
- {_id: 1, y: [{b: 3}, {b: 1}]}
|
108
|
+
- {_id: 2, y: [{b: 0}, {b: 1}]}
|
109
|
+
- {_id: 3, y: [{b: 5, c: [{d: 2}, {d: 0}] }]}
|
@@ -33,8 +33,8 @@ phases: [
|
|
33
33
|
setName:
|
34
34
|
}
|
35
35
|
},
|
36
|
-
|
37
36
|
topologyType: "ReplicaSetWithPrimary",
|
37
|
+
logicalSessionTimeoutMinutes: null,
|
38
38
|
setName: "rs"
|
39
39
|
}
|
40
40
|
},
|
@@ -69,8 +69,8 @@ phases: [
|
|
69
69
|
setName: "rs"
|
70
70
|
}
|
71
71
|
},
|
72
|
-
|
73
72
|
topologyType: "ReplicaSetWithPrimary",
|
73
|
+
logicalSessionTimeoutMinutes: null,
|
74
74
|
setName: "rs"
|
75
75
|
}
|
76
76
|
}
|