mongo 2.3.1 → 2.4.0.rc0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -3
- data/lib/mongo/bulk_write.rb +8 -7
- data/lib/mongo/bulk_write/combineable.rb +4 -0
- data/lib/mongo/bulk_write/transformable.rb +17 -5
- data/lib/mongo/bulk_write/validatable.rb +1 -0
- data/lib/mongo/client.rb +3 -0
- data/lib/mongo/cluster.rb +8 -0
- data/lib/mongo/cluster/app_metadata.rb +135 -0
- data/lib/mongo/collection.rb +42 -10
- data/lib/mongo/collection/view.rb +15 -1
- data/lib/mongo/collection/view/aggregation.rb +5 -0
- data/lib/mongo/collection/view/builder/aggregation.rb +13 -3
- data/lib/mongo/collection/view/builder/find_command.rb +7 -21
- data/lib/mongo/collection/view/builder/map_reduce.rb +22 -5
- data/lib/mongo/collection/view/iterable.rb +1 -0
- data/lib/mongo/collection/view/map_reduce.rb +5 -0
- data/lib/mongo/collection/view/readable.rb +35 -14
- data/lib/mongo/collection/view/writable.rb +54 -23
- data/lib/mongo/cursor/builder/get_more_command.rb +2 -3
- data/lib/mongo/database.rb +10 -2
- data/lib/mongo/error.rb +2 -0
- data/lib/mongo/error/invalid_application_name.rb +38 -0
- data/lib/mongo/error/invalid_server_preference.rb +24 -3
- data/lib/mongo/error/unsupported_collation.rb +51 -0
- data/lib/mongo/index/view.rb +28 -15
- data/lib/mongo/operation.rb +6 -0
- data/lib/mongo/operation/commands.rb +3 -0
- data/lib/mongo/operation/commands/aggregate.rb +10 -10
- data/lib/mongo/operation/commands/create.rb +45 -0
- data/lib/mongo/operation/commands/drop.rb +45 -0
- data/lib/mongo/operation/commands/drop_database.rb +45 -0
- data/lib/mongo/operation/commands/map_reduce.rb +12 -1
- data/lib/mongo/operation/commands/parallel_scan.rb +1 -0
- data/lib/mongo/operation/read_preference.rb +9 -9
- data/lib/mongo/operation/specifiable.rb +34 -0
- data/lib/mongo/operation/takes_write_concern.rb +35 -0
- data/lib/mongo/operation/write/bulk/bulkable.rb +1 -1
- data/lib/mongo/operation/write/command/create_index.rb +6 -0
- data/lib/mongo/operation/write/command/drop_index.rb +6 -0
- data/lib/mongo/operation/write/command/insert.rb +1 -1
- data/lib/mongo/operation/write/command/update.rb +1 -0
- data/lib/mongo/operation/write/command/writable.rb +2 -2
- data/lib/mongo/operation/write/create_index.rb +2 -2
- data/lib/mongo/operation/write/create_user.rb +1 -1
- data/lib/mongo/operation/write/delete.rb +5 -1
- data/lib/mongo/operation/write/gle.rb +1 -1
- data/lib/mongo/operation/write/insert.rb +2 -2
- data/lib/mongo/operation/write/remove_user.rb +1 -1
- data/lib/mongo/operation/write/update.rb +5 -1
- data/lib/mongo/operation/write/update_user.rb +1 -1
- data/lib/mongo/operation/write/write_command_enabled.rb +10 -2
- data/lib/mongo/protocol/insert.rb +1 -2
- data/lib/mongo/protocol/query.rb +3 -7
- data/lib/mongo/server.rb +8 -3
- data/lib/mongo/server/connection.rb +17 -11
- data/lib/mongo/server/description.rb +22 -0
- data/lib/mongo/server/description/features.rb +2 -0
- data/lib/mongo/server/monitor.rb +5 -0
- data/lib/mongo/server/monitor/connection.rb +11 -0
- data/lib/mongo/server_selector/nearest.rb +9 -6
- data/lib/mongo/server_selector/primary.rb +4 -0
- data/lib/mongo/server_selector/primary_preferred.rb +7 -1
- data/lib/mongo/server_selector/secondary.rb +5 -0
- data/lib/mongo/server_selector/secondary_preferred.rb +7 -2
- data/lib/mongo/server_selector/selectable.rb +57 -10
- data/lib/mongo/socket/ssl.rb +1 -0
- data/lib/mongo/uri.rb +4 -0
- data/lib/mongo/version.rb +1 -1
- data/lib/mongo/write_concern.rb +1 -0
- data/mongo.gemspec +1 -1
- data/spec/mongo/auth/cr_spec.rb +7 -1
- data/spec/mongo/auth/ldap_spec.rb +7 -1
- data/spec/mongo/auth/scram_spec.rb +7 -1
- data/spec/mongo/auth/x509_spec.rb +7 -1
- data/spec/mongo/bulk_write_spec.rb +598 -5
- data/spec/mongo/client_spec.rb +47 -1
- data/spec/mongo/cluster/app_metadata_spec.rb +104 -0
- data/spec/mongo/cluster/topology/replica_set_spec.rb +14 -8
- data/spec/mongo/cluster/topology/sharded_spec.rb +9 -3
- data/spec/mongo/cluster/topology/single_spec.rb +10 -4
- data/spec/mongo/cluster_spec.rb +29 -0
- data/spec/mongo/collection/view/aggregation_spec.rb +139 -0
- data/spec/mongo/collection/view/builder/find_command_spec.rb +6 -243
- data/spec/mongo/collection/view/map_reduce_spec.rb +104 -0
- data/spec/mongo/collection/view/readable_spec.rb +83 -0
- data/spec/mongo/collection/view/writable_spec.rb +447 -1
- data/spec/mongo/collection/view_spec.rb +57 -0
- data/spec/mongo/collection_spec.rb +926 -101
- data/spec/mongo/crud_spec.rb +4 -5
- data/spec/mongo/database_spec.rb +99 -1
- data/spec/mongo/index/view_spec.rb +360 -31
- data/spec/mongo/max_staleness_spec.rb +108 -0
- data/spec/mongo/operation/read_preference_spec.rb +8 -8
- data/spec/mongo/operation/write/command/delete_spec.rb +1 -1
- data/spec/mongo/operation/write/command/insert_spec.rb +1 -1
- data/spec/mongo/operation/write/command/update_spec.rb +1 -1
- data/spec/mongo/server/connection_pool_spec.rb +3 -1
- data/spec/mongo/server/connection_spec.rb +17 -7
- data/spec/mongo/server/description/features_spec.rb +50 -0
- data/spec/mongo/server/description_spec.rb +9 -3
- data/spec/mongo/server_selection_spec.rb +5 -3
- data/spec/mongo/server_selector/nearest_spec.rb +73 -0
- data/spec/mongo/server_selector/primary_preferred_spec.rb +73 -0
- data/spec/mongo/server_selector/primary_spec.rb +36 -0
- data/spec/mongo/server_selector/secondary_preferred_spec.rb +73 -0
- data/spec/mongo/server_selector/secondary_spec.rb +73 -0
- data/spec/mongo/server_selector_spec.rb +53 -0
- data/spec/mongo/server_spec.rb +3 -1
- data/spec/mongo/uri_spec.rb +54 -0
- data/spec/mongo/write_concern_spec.rb +18 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/support/authorization.rb +8 -1
- data/spec/support/crud.rb +15 -0
- data/spec/support/crud/read.rb +27 -19
- data/spec/support/crud/write.rb +28 -3
- data/spec/support/crud_tests/read/aggregate.yml +15 -3
- data/spec/support/crud_tests/read/count.yml +14 -3
- data/spec/support/crud_tests/read/distinct.yml +13 -1
- data/spec/support/crud_tests/read/find.yml +12 -2
- data/spec/support/crud_tests/write/deleteMany.yml +22 -1
- data/spec/support/crud_tests/write/deleteOne.yml +20 -1
- data/spec/support/crud_tests/write/findOneAndDelete.yml +27 -2
- data/spec/support/crud_tests/write/findOneAndReplace.yml +43 -14
- data/spec/support/crud_tests/write/findOneAndUpdate.yml +50 -8
- data/spec/support/crud_tests/write/replaceOne.yml +34 -10
- data/spec/support/crud_tests/write/updateMany.yml +42 -11
- data/spec/support/crud_tests/write/updateOne.yml +32 -7
- data/spec/support/max_staleness/ReplicaSetNoPrimary/DefaultNoMaxStaleness.yml +26 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/Incompatible.yml +25 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/LastUpdateTime.yml +33 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/Nearest.yml +33 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/Nearest2.yml +33 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred.yml +27 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred_tags.yml +36 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/Secondary.yml +51 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred.yml +26 -0
- data/spec/support/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred_tags.yml +51 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/DefaultNoMaxStaleness.yml +26 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/Incompatible.yml +25 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/LastUpdateTime.yml +35 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/MaxStalenessTooSmall.yml +25 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/MaxStalenessWithModePrimary.yml +23 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/Nearest.yml +33 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/Nearest2.yml +33 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/Nearest_tags.yml +36 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred.yml +27 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred_incompatible.yml +27 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred.yml +26 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags.yml +59 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags2.yml +43 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/Secondary_tags.yml +59 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/Secondary_tags2.yml +43 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/ShortHeartbeartShortMaxStaleness.yml +29 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/ShortHeartbeartShortMaxStaleness2.yml +29 -0
- data/spec/support/max_staleness/ReplicaSetWithPrimary/ZeroMaxStaleness.yml +27 -0
- data/spec/support/max_staleness/Sharded/Incompatible.yml +25 -0
- data/spec/support/max_staleness/Sharded/SmallMaxStaleness.yml +20 -0
- data/spec/support/max_staleness/Single/Incompatible.yml +18 -0
- data/spec/support/max_staleness/Single/SmallMaxStaleness.yml +20 -0
- data/spec/support/server_selection.rb +25 -0
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Nearest_multiple.yml +27 -0
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Secondary_multi_tags.yml +31 -0
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Secondary_multi_tags2.yml +31 -0
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Nearest_multiple.yml +34 -0
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/SecondaryPreferred_tags.yml +28 -0
- data/spec/support/shared/server_selector.rb +4 -3
- metadata +91 -6
- metadata.gz.sig +0 -0
@@ -14,8 +14,14 @@ describe Mongo::Auth::LDAP do
|
|
14
14
|
Mongo::Event::Listeners.new
|
15
15
|
end
|
16
16
|
|
17
|
+
let(:cluster) do
|
18
|
+
double('cluster').tap do |cl|
|
19
|
+
allow(cl).to receive(:app_metadata).and_return(app_metadata)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
17
23
|
let(:server) do
|
18
|
-
Mongo::Server.new(address,
|
24
|
+
Mongo::Server.new(address, cluster, monitoring, listeners, TEST_OPTIONS)
|
19
25
|
end
|
20
26
|
|
21
27
|
let(:connection) do
|
@@ -14,8 +14,14 @@ describe Mongo::Auth::SCRAM do
|
|
14
14
|
Mongo::Event::Listeners.new
|
15
15
|
end
|
16
16
|
|
17
|
+
let(:cluster) do
|
18
|
+
double('cluster').tap do |cl|
|
19
|
+
allow(cl).to receive(:app_metadata).and_return(app_metadata)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
17
23
|
let(:server) do
|
18
|
-
Mongo::Server.new(address,
|
24
|
+
Mongo::Server.new(address, cluster, monitoring, listeners, TEST_OPTIONS)
|
19
25
|
end
|
20
26
|
|
21
27
|
let(:connection) do
|
@@ -14,8 +14,14 @@ describe Mongo::Auth::X509 do
|
|
14
14
|
Mongo::Event::Listeners.new
|
15
15
|
end
|
16
16
|
|
17
|
+
let(:cluster) do
|
18
|
+
double('cluster').tap do |cl|
|
19
|
+
allow(cl).to receive(:app_metadata).and_return(app_metadata)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
17
23
|
let(:server) do
|
18
|
-
Mongo::Server.new(address,
|
24
|
+
Mongo::Server.new(address, cluster, monitoring, listeners, TEST_OPTIONS)
|
19
25
|
end
|
20
26
|
|
21
27
|
let(:connection) do
|
@@ -12,6 +12,7 @@ describe Mongo::BulkWrite do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
let(:collection_with_validator) do
|
15
|
+
begin; authorized_client[:validating].drop; rescue; end
|
15
16
|
authorized_client[:validating,
|
16
17
|
:validator => { :a => { '$exists' => true } }].tap do |c|
|
17
18
|
c.create
|
@@ -22,6 +23,10 @@ describe Mongo::BulkWrite do
|
|
22
23
|
authorized_collection.client.with(write: { w: (WRITE_CONCERN[:w] + 1) })[authorized_collection.name]
|
23
24
|
end
|
24
25
|
|
26
|
+
let(:collation) do
|
27
|
+
{ locale: 'en_US', strength: 2 }
|
28
|
+
end
|
29
|
+
|
25
30
|
describe '#execute' do
|
26
31
|
|
27
32
|
shared_examples_for 'an executable bulk write' do
|
@@ -205,6 +210,64 @@ describe Mongo::BulkWrite do
|
|
205
210
|
}.to raise_error(Mongo::Error::OperationFailure)
|
206
211
|
end
|
207
212
|
end
|
213
|
+
|
214
|
+
context 'when the write has a collation specified' do
|
215
|
+
|
216
|
+
before do
|
217
|
+
authorized_collection.insert_one(name: 'bang')
|
218
|
+
end
|
219
|
+
|
220
|
+
let(:requests) do
|
221
|
+
[{ delete_one: { filter: { name: 'BANG' }, collation: collation } }]
|
222
|
+
end
|
223
|
+
|
224
|
+
context 'when the server selected supports collations', if: collation_enabled? do
|
225
|
+
|
226
|
+
let!(:result) do
|
227
|
+
bulk_write.execute
|
228
|
+
end
|
229
|
+
|
230
|
+
it 'applies the collation' do
|
231
|
+
expect(authorized_collection.find(name: 'bang').count).to eq(0)
|
232
|
+
end
|
233
|
+
|
234
|
+
it 'reports the deleted count' do
|
235
|
+
expect(result.deleted_count).to eq(1)
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
context 'when the server selected does not support collations', unless: collation_enabled? do
|
240
|
+
|
241
|
+
it 'raises an exception' do
|
242
|
+
expect {
|
243
|
+
bulk_write.execute
|
244
|
+
}.to raise_exception(Mongo::Error::UnsupportedCollation)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
context 'when a collation is not specified' do
|
250
|
+
|
251
|
+
before do
|
252
|
+
authorized_collection.insert_one(name: 'bang')
|
253
|
+
end
|
254
|
+
|
255
|
+
let(:requests) do
|
256
|
+
[{ delete_one: { filter: { name: 'BANG' }}}]
|
257
|
+
end
|
258
|
+
|
259
|
+
let!(:result) do
|
260
|
+
bulk_write.execute
|
261
|
+
end
|
262
|
+
|
263
|
+
it 'does not apply the collation' do
|
264
|
+
expect(authorized_collection.find(name: 'bang').count).to eq(1)
|
265
|
+
end
|
266
|
+
|
267
|
+
it 'reports the deleted count' do
|
268
|
+
expect(result.deleted_count).to eq(0)
|
269
|
+
end
|
270
|
+
end
|
208
271
|
end
|
209
272
|
|
210
273
|
context 'when multiple documents match delete selector' do
|
@@ -273,6 +336,68 @@ describe Mongo::BulkWrite do
|
|
273
336
|
end
|
274
337
|
end
|
275
338
|
end
|
339
|
+
|
340
|
+
context 'when the write has a collation specified' do
|
341
|
+
|
342
|
+
before do
|
343
|
+
authorized_collection.insert_one(name: 'bang')
|
344
|
+
authorized_collection.insert_one(name: 'doink')
|
345
|
+
end
|
346
|
+
|
347
|
+
let(:requests) do
|
348
|
+
[{ delete_one: { filter: { name: 'BANG' }, collation: collation }},
|
349
|
+
{ delete_one: { filter: { name: 'DOINK' }, collation: collation }}]
|
350
|
+
end
|
351
|
+
|
352
|
+
context 'when the server selected supports collations', if: collation_enabled? do
|
353
|
+
|
354
|
+
let!(:result) do
|
355
|
+
bulk_write.execute
|
356
|
+
end
|
357
|
+
|
358
|
+
it 'applies the collation' do
|
359
|
+
expect(authorized_collection.find(name: { '$in' => ['bang', 'doink']}).count).to eq(0)
|
360
|
+
end
|
361
|
+
|
362
|
+
it 'reports the deleted count' do
|
363
|
+
expect(result.deleted_count).to eq(2)
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
context 'when the server selected does not support collations', unless: collation_enabled? do
|
368
|
+
|
369
|
+
it 'raises an exception' do
|
370
|
+
expect {
|
371
|
+
bulk_write.execute
|
372
|
+
}.to raise_exception(Mongo::Error::UnsupportedCollation)
|
373
|
+
end
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
context 'when the write does not have a collation specified' do
|
378
|
+
|
379
|
+
before do
|
380
|
+
authorized_collection.insert_one(name: 'bang')
|
381
|
+
authorized_collection.insert_one(name: 'doink')
|
382
|
+
end
|
383
|
+
|
384
|
+
let(:requests) do
|
385
|
+
[{ delete_one: { filter: { name: 'BANG' }}},
|
386
|
+
{ delete_one: { filter: { name: 'DOINK' }}}]
|
387
|
+
end
|
388
|
+
|
389
|
+
let!(:result) do
|
390
|
+
bulk_write.execute
|
391
|
+
end
|
392
|
+
|
393
|
+
it 'does not apply the collation' do
|
394
|
+
expect(authorized_collection.find(name: { '$in' => ['bang', 'doink']}).count).to eq(2)
|
395
|
+
end
|
396
|
+
|
397
|
+
it 'reports the deleted count' do
|
398
|
+
expect(result.deleted_count).to eq(0)
|
399
|
+
end
|
400
|
+
end
|
276
401
|
end
|
277
402
|
|
278
403
|
context 'when provided a single delete many' do
|
@@ -314,6 +439,66 @@ describe Mongo::BulkWrite do
|
|
314
439
|
end
|
315
440
|
end
|
316
441
|
end
|
442
|
+
|
443
|
+
context 'when the write has a collation specified' do
|
444
|
+
|
445
|
+
before do
|
446
|
+
authorized_collection.insert_one(name: 'bang')
|
447
|
+
authorized_collection.insert_one(name: 'bang')
|
448
|
+
end
|
449
|
+
|
450
|
+
let(:requests) do
|
451
|
+
[{ delete_many: { filter: { name: 'BANG' }, collation: collation }}]
|
452
|
+
end
|
453
|
+
|
454
|
+
context 'when the server selected supports collations', if: collation_enabled? do
|
455
|
+
|
456
|
+
let!(:result) do
|
457
|
+
bulk_write.execute
|
458
|
+
end
|
459
|
+
|
460
|
+
it 'applies the collation' do
|
461
|
+
expect(authorized_collection.find(name: 'bang').count).to eq(0)
|
462
|
+
end
|
463
|
+
|
464
|
+
it 'reports the deleted count' do
|
465
|
+
expect(result.deleted_count).to eq(2)
|
466
|
+
end
|
467
|
+
end
|
468
|
+
|
469
|
+
context 'when the server selected does not support collations', unless: collation_enabled? do
|
470
|
+
|
471
|
+
it 'raises an exception' do
|
472
|
+
expect {
|
473
|
+
bulk_write.execute
|
474
|
+
}.to raise_exception(Mongo::Error::UnsupportedCollation)
|
475
|
+
end
|
476
|
+
end
|
477
|
+
end
|
478
|
+
|
479
|
+
context 'when a collation is not specified' do
|
480
|
+
|
481
|
+
before do
|
482
|
+
authorized_collection.insert_one(name: 'bang')
|
483
|
+
authorized_collection.insert_one(name: 'bang')
|
484
|
+
end
|
485
|
+
|
486
|
+
let(:requests) do
|
487
|
+
[{ delete_many: { filter: { name: 'BANG' }}}]
|
488
|
+
end
|
489
|
+
|
490
|
+
let!(:result) do
|
491
|
+
bulk_write.execute
|
492
|
+
end
|
493
|
+
|
494
|
+
it 'does not apply the collation' do
|
495
|
+
expect(authorized_collection.find(name: 'bang').count).to eq(2)
|
496
|
+
end
|
497
|
+
|
498
|
+
it 'reports the deleted count' do
|
499
|
+
expect(result.deleted_count).to eq(0)
|
500
|
+
end
|
501
|
+
end
|
317
502
|
end
|
318
503
|
|
319
504
|
context 'when provided multiple delete many ops' do
|
@@ -361,6 +546,70 @@ describe Mongo::BulkWrite do
|
|
361
546
|
end
|
362
547
|
end
|
363
548
|
end
|
549
|
+
|
550
|
+
context 'when the write has a collation specified' do
|
551
|
+
|
552
|
+
before do
|
553
|
+
authorized_collection.insert_one(name: 'bang')
|
554
|
+
authorized_collection.insert_one(name: 'bang')
|
555
|
+
authorized_collection.insert_one(name: 'doink')
|
556
|
+
end
|
557
|
+
|
558
|
+
let(:requests) do
|
559
|
+
[{ delete_many: { filter: { name: 'BANG' }, collation: collation }},
|
560
|
+
{ delete_many: { filter: { name: 'DOINK' }, collation: collation }}]
|
561
|
+
end
|
562
|
+
|
563
|
+
context 'when the server selected supports collations', if: collation_enabled? do
|
564
|
+
|
565
|
+
let!(:result) do
|
566
|
+
bulk_write.execute
|
567
|
+
end
|
568
|
+
|
569
|
+
it 'applies the collation' do
|
570
|
+
expect(authorized_collection.find(name: { '$in' => ['bang', 'doink'] }).count).to eq(0)
|
571
|
+
end
|
572
|
+
|
573
|
+
it 'reports the deleted count' do
|
574
|
+
expect(result.deleted_count).to eq(3)
|
575
|
+
end
|
576
|
+
end
|
577
|
+
|
578
|
+
context 'when the server selected does not support collations', unless: collation_enabled? do
|
579
|
+
|
580
|
+
it 'raises an exception' do
|
581
|
+
expect {
|
582
|
+
bulk_write.execute
|
583
|
+
}.to raise_exception(Mongo::Error::UnsupportedCollation)
|
584
|
+
end
|
585
|
+
end
|
586
|
+
end
|
587
|
+
|
588
|
+
context 'when a collation is not specified' do
|
589
|
+
|
590
|
+
before do
|
591
|
+
authorized_collection.insert_one(name: 'bang')
|
592
|
+
authorized_collection.insert_one(name: 'bang')
|
593
|
+
authorized_collection.insert_one(name: 'doink')
|
594
|
+
end
|
595
|
+
|
596
|
+
let(:requests) do
|
597
|
+
[{ delete_many: { filter: { name: 'BANG' }}},
|
598
|
+
{ delete_many: { filter: { name: 'DOINK' }}}]
|
599
|
+
end
|
600
|
+
|
601
|
+
let!(:result) do
|
602
|
+
bulk_write.execute
|
603
|
+
end
|
604
|
+
|
605
|
+
it 'does not apply the collation' do
|
606
|
+
expect(authorized_collection.find(name: { '$in' => ['bang', 'doink'] }).count).to eq(3)
|
607
|
+
end
|
608
|
+
|
609
|
+
it 'reports the deleted count' do
|
610
|
+
expect(result.deleted_count).to eq(0)
|
611
|
+
end
|
612
|
+
end
|
364
613
|
end
|
365
614
|
|
366
615
|
context 'when providing a single replace one' do
|
@@ -402,6 +651,90 @@ describe Mongo::BulkWrite do
|
|
402
651
|
end
|
403
652
|
end
|
404
653
|
end
|
654
|
+
|
655
|
+
context 'when the write has a collation specified' do
|
656
|
+
|
657
|
+
before do
|
658
|
+
authorized_collection.insert_one(name: 'bang')
|
659
|
+
end
|
660
|
+
|
661
|
+
let(:requests) do
|
662
|
+
[{ replace_one: { filter: { name: 'BANG' },
|
663
|
+
replacement: { other: 'pong' },
|
664
|
+
collation: collation }}]
|
665
|
+
end
|
666
|
+
|
667
|
+
context 'when the server selected supports collations', if: collation_enabled? do
|
668
|
+
|
669
|
+
let!(:result) do
|
670
|
+
bulk_write.execute
|
671
|
+
end
|
672
|
+
|
673
|
+
it 'applies the collation' do
|
674
|
+
expect(authorized_collection.find(other: 'pong').count).to eq(1)
|
675
|
+
end
|
676
|
+
|
677
|
+
it 'reports the upserted id' do
|
678
|
+
expect(result.upserted_ids).to eq([])
|
679
|
+
end
|
680
|
+
|
681
|
+
it 'reports the upserted count' do
|
682
|
+
expect(result.upserted_count).to eq(0)
|
683
|
+
end
|
684
|
+
|
685
|
+
it 'reports the modified count' do
|
686
|
+
expect(result.modified_count).to eq(1)
|
687
|
+
end
|
688
|
+
|
689
|
+
it 'reports the matched count' do
|
690
|
+
expect(result.matched_count).to eq(1)
|
691
|
+
end
|
692
|
+
end
|
693
|
+
|
694
|
+
context 'when the server selected does not support collations', unless: collation_enabled? do
|
695
|
+
|
696
|
+
it 'raises an exception' do
|
697
|
+
expect {
|
698
|
+
bulk_write.execute
|
699
|
+
}.to raise_exception(Mongo::Error::UnsupportedCollation)
|
700
|
+
end
|
701
|
+
end
|
702
|
+
end
|
703
|
+
|
704
|
+
context 'when the write does not have a collation specified' do
|
705
|
+
|
706
|
+
before do
|
707
|
+
authorized_collection.insert_one(name: 'bang')
|
708
|
+
end
|
709
|
+
|
710
|
+
let(:requests) do
|
711
|
+
[{ replace_one: { filter: { name: 'BANG' }, replacement: { other: 'pong' }}}]
|
712
|
+
end
|
713
|
+
|
714
|
+
let!(:result) do
|
715
|
+
bulk_write.execute
|
716
|
+
end
|
717
|
+
|
718
|
+
it 'does not apply the collation' do
|
719
|
+
expect(authorized_collection.find(other: 'pong').count).to eq(0)
|
720
|
+
end
|
721
|
+
|
722
|
+
it 'reports the upserted id' do
|
723
|
+
expect(result.upserted_ids).to eq([])
|
724
|
+
end
|
725
|
+
|
726
|
+
it 'reports the upserted count' do
|
727
|
+
expect(result.upserted_count).to eq(0)
|
728
|
+
end
|
729
|
+
|
730
|
+
it 'reports the modified count' do
|
731
|
+
expect(result.modified_count).to eq(0)
|
732
|
+
end
|
733
|
+
|
734
|
+
it 'reports the matched count' do
|
735
|
+
expect(result.matched_count).to eq(0)
|
736
|
+
end
|
737
|
+
end
|
405
738
|
end
|
406
739
|
|
407
740
|
context 'when providing a single update one' do
|
@@ -523,12 +856,12 @@ describe Mongo::BulkWrite do
|
|
523
856
|
expect(result.upserted_count).to eq(1)
|
524
857
|
end
|
525
858
|
|
526
|
-
it 'reports the
|
859
|
+
it 'reports the modified_count count' do
|
527
860
|
expect(result.modified_count).to eq(0)
|
528
861
|
end
|
529
862
|
|
530
|
-
it 'reports the
|
531
|
-
expect(result.
|
863
|
+
it 'reports the matched count' do
|
864
|
+
expect(result.matched_count).to eq(0)
|
532
865
|
end
|
533
866
|
|
534
867
|
it 'reports the upserted id', if: write_command_enabled? do
|
@@ -556,10 +889,184 @@ describe Mongo::BulkWrite do
|
|
556
889
|
end
|
557
890
|
end
|
558
891
|
end
|
892
|
+
|
893
|
+
context 'when the write has a collation specified' do
|
894
|
+
|
895
|
+
before do
|
896
|
+
authorized_collection.insert_one(name: 'bang')
|
897
|
+
end
|
898
|
+
|
899
|
+
let(:requests) do
|
900
|
+
[{ update_one: { filter: { name: 'BANG' },
|
901
|
+
update: { "$set" => { name: 'pong' }},
|
902
|
+
collation: collation }}]
|
903
|
+
end
|
904
|
+
|
905
|
+
context 'when the server selected supports collations', if: collation_enabled? do
|
906
|
+
|
907
|
+
let!(:result) do
|
908
|
+
bulk_write.execute
|
909
|
+
end
|
910
|
+
|
911
|
+
it 'applies the collation' do
|
912
|
+
expect(authorized_collection.find(name: 'pong').count).to eq(1)
|
913
|
+
end
|
914
|
+
|
915
|
+
it 'reports the upserted id' do
|
916
|
+
expect(result.upserted_ids).to eq([])
|
917
|
+
end
|
918
|
+
|
919
|
+
it 'reports the upserted count' do
|
920
|
+
expect(result.upserted_count).to eq(0)
|
921
|
+
end
|
922
|
+
|
923
|
+
it 'reports the modified count' do
|
924
|
+
expect(result.modified_count).to eq(1)
|
925
|
+
end
|
926
|
+
|
927
|
+
it 'reports the matched count' do
|
928
|
+
expect(result.matched_count).to eq(1)
|
929
|
+
end
|
930
|
+
end
|
931
|
+
|
932
|
+
context 'when the server selected does not support collations', unless: collation_enabled? do
|
933
|
+
|
934
|
+
it 'raises an exception' do
|
935
|
+
expect {
|
936
|
+
bulk_write.execute
|
937
|
+
}.to raise_exception(Mongo::Error::UnsupportedCollation)
|
938
|
+
end
|
939
|
+
end
|
940
|
+
end
|
941
|
+
|
942
|
+
context 'when the write does not have a collation specified' do
|
943
|
+
|
944
|
+
before do
|
945
|
+
authorized_collection.insert_one(name: 'bang')
|
946
|
+
end
|
947
|
+
|
948
|
+
let(:requests) do
|
949
|
+
[{ update_one: { filter: { name: 'BANG' }, update: { "$set" => { name: 'pong' }}}}]
|
950
|
+
end
|
951
|
+
|
952
|
+
let!(:result) do
|
953
|
+
bulk_write.execute
|
954
|
+
end
|
955
|
+
|
956
|
+
it 'does not apply the collation' do
|
957
|
+
expect(authorized_collection.find(name: 'pong').count).to eq(0)
|
958
|
+
end
|
959
|
+
|
960
|
+
it 'reports the upserted id' do
|
961
|
+
expect(result.upserted_ids).to eq([])
|
962
|
+
end
|
963
|
+
|
964
|
+
it 'reports the upserted count' do
|
965
|
+
expect(result.upserted_count).to eq(0)
|
966
|
+
end
|
967
|
+
|
968
|
+
it 'reports the modified count' do
|
969
|
+
expect(result.modified_count).to eq(0)
|
970
|
+
end
|
971
|
+
|
972
|
+
it 'reports the matched count' do
|
973
|
+
expect(result.matched_count).to eq(0)
|
974
|
+
end
|
975
|
+
end
|
559
976
|
end
|
560
977
|
|
561
978
|
context 'when providing multiple update ones' do
|
562
979
|
|
980
|
+
context 'when the write has a collation specified' do
|
981
|
+
|
982
|
+
before do
|
983
|
+
authorized_collection.insert_one(name: 'bang')
|
984
|
+
authorized_collection.insert_one(name: 'doink')
|
985
|
+
end
|
986
|
+
|
987
|
+
let(:requests) do
|
988
|
+
[{ update_one: { filter: { name: 'BANG' },
|
989
|
+
update: { "$set" => { name: 'pong' }},
|
990
|
+
collation: collation }},
|
991
|
+
{ update_one: { filter: { name: 'DOINK' },
|
992
|
+
update: { "$set" => { name: 'pong' }},
|
993
|
+
collation: collation }}]
|
994
|
+
end
|
995
|
+
|
996
|
+
context 'when the server selected supports collations', if: collation_enabled? do
|
997
|
+
|
998
|
+
let!(:result) do
|
999
|
+
bulk_write.execute
|
1000
|
+
end
|
1001
|
+
|
1002
|
+
it 'applies the collation' do
|
1003
|
+
expect(authorized_collection.find(name: 'pong').count).to eq(2)
|
1004
|
+
end
|
1005
|
+
|
1006
|
+
it 'reports the upserted id' do
|
1007
|
+
expect(result.upserted_ids).to eq([])
|
1008
|
+
end
|
1009
|
+
|
1010
|
+
it 'reports the upserted count' do
|
1011
|
+
expect(result.upserted_count).to eq(0)
|
1012
|
+
end
|
1013
|
+
|
1014
|
+
it 'reports the modified count' do
|
1015
|
+
expect(result.modified_count).to eq(2)
|
1016
|
+
end
|
1017
|
+
|
1018
|
+
it 'reports the matched count' do
|
1019
|
+
expect(result.matched_count).to eq(2)
|
1020
|
+
end
|
1021
|
+
end
|
1022
|
+
|
1023
|
+
context 'when the server selected does not support collations', unless: collation_enabled? do
|
1024
|
+
|
1025
|
+
it 'raises an exception' do
|
1026
|
+
expect {
|
1027
|
+
bulk_write.execute
|
1028
|
+
}.to raise_exception(Mongo::Error::UnsupportedCollation)
|
1029
|
+
end
|
1030
|
+
end
|
1031
|
+
end
|
1032
|
+
|
1033
|
+
context 'when the write does not have a collation specified' do
|
1034
|
+
|
1035
|
+
before do
|
1036
|
+
authorized_collection.insert_one(name: 'bang')
|
1037
|
+
authorized_collection.insert_one(name: 'doink')
|
1038
|
+
end
|
1039
|
+
|
1040
|
+
let(:requests) do
|
1041
|
+
[{ update_one: { filter: { name: 'BANG' }, update: { "$set" => { name: 'pong' }}}},
|
1042
|
+
{ update_one: { filter: { name: 'DOINK' }, update: { "$set" => { name: 'pong' }}}}]
|
1043
|
+
end
|
1044
|
+
|
1045
|
+
let!(:result) do
|
1046
|
+
bulk_write.execute
|
1047
|
+
end
|
1048
|
+
|
1049
|
+
it 'does not apply the collation' do
|
1050
|
+
expect(authorized_collection.find(name: 'pong').count).to eq(0)
|
1051
|
+
end
|
1052
|
+
|
1053
|
+
it 'reports the upserted id' do
|
1054
|
+
expect(result.upserted_ids).to eq([])
|
1055
|
+
end
|
1056
|
+
|
1057
|
+
it 'reports the upserted count' do
|
1058
|
+
expect(result.upserted_count).to eq(0)
|
1059
|
+
end
|
1060
|
+
|
1061
|
+
it 'reports the modified count' do
|
1062
|
+
expect(result.modified_count).to eq(0)
|
1063
|
+
end
|
1064
|
+
|
1065
|
+
it 'reports the matched count' do
|
1066
|
+
expect(result.matched_count).to eq(0)
|
1067
|
+
end
|
1068
|
+
end
|
1069
|
+
|
563
1070
|
context 'when upsert is false' do
|
564
1071
|
|
565
1072
|
let(:requests) do
|
@@ -593,7 +1100,7 @@ describe Mongo::BulkWrite do
|
|
593
1100
|
end
|
594
1101
|
|
595
1102
|
it 'reports the matched count' do
|
596
|
-
expect(result.
|
1103
|
+
expect(result.matched_count).to eq(2)
|
597
1104
|
end
|
598
1105
|
|
599
1106
|
|
@@ -760,6 +1267,92 @@ describe Mongo::BulkWrite do
|
|
760
1267
|
|
761
1268
|
context 'when providing a single update many' do
|
762
1269
|
|
1270
|
+
context 'when the write has a collation specified' do
|
1271
|
+
|
1272
|
+
before do
|
1273
|
+
authorized_collection.insert_one(name: 'bang')
|
1274
|
+
authorized_collection.insert_one(name: 'bang')
|
1275
|
+
end
|
1276
|
+
|
1277
|
+
let(:requests) do
|
1278
|
+
[{ update_many: { filter: { name: 'BANG' },
|
1279
|
+
update: { "$set" => { name: 'pong' }},
|
1280
|
+
collation: collation }}]
|
1281
|
+
end
|
1282
|
+
|
1283
|
+
context 'when the server selected supports collations', if: collation_enabled? do
|
1284
|
+
|
1285
|
+
let!(:result) do
|
1286
|
+
bulk_write.execute
|
1287
|
+
end
|
1288
|
+
|
1289
|
+
it 'applies the collation' do
|
1290
|
+
expect(authorized_collection.find(name: 'pong').count).to eq(2)
|
1291
|
+
end
|
1292
|
+
|
1293
|
+
it 'reports the upserted id' do
|
1294
|
+
expect(result.upserted_ids).to eq([])
|
1295
|
+
end
|
1296
|
+
|
1297
|
+
it 'reports the upserted count' do
|
1298
|
+
expect(result.upserted_count).to eq(0)
|
1299
|
+
end
|
1300
|
+
|
1301
|
+
it 'reports the modified count' do
|
1302
|
+
expect(result.modified_count).to eq(2)
|
1303
|
+
end
|
1304
|
+
|
1305
|
+
it 'reports the matched count' do
|
1306
|
+
expect(result.matched_count).to eq(2)
|
1307
|
+
end
|
1308
|
+
end
|
1309
|
+
|
1310
|
+
context 'when the server selected does not support collations', unless: collation_enabled? do
|
1311
|
+
|
1312
|
+
it 'raises an exception' do
|
1313
|
+
expect {
|
1314
|
+
bulk_write.execute
|
1315
|
+
}.to raise_exception(Mongo::Error::UnsupportedCollation)
|
1316
|
+
end
|
1317
|
+
end
|
1318
|
+
end
|
1319
|
+
|
1320
|
+
context 'when the write does not have a collation specified' do
|
1321
|
+
|
1322
|
+
before do
|
1323
|
+
authorized_collection.insert_one(name: 'bang')
|
1324
|
+
authorized_collection.insert_one(name: 'bang')
|
1325
|
+
end
|
1326
|
+
|
1327
|
+
let(:requests) do
|
1328
|
+
[{ update_many: { filter: { name: 'BANG' }, update: { "$set" => { name: 'pong' }}}}]
|
1329
|
+
end
|
1330
|
+
|
1331
|
+
let!(:result) do
|
1332
|
+
bulk_write.execute
|
1333
|
+
end
|
1334
|
+
|
1335
|
+
it 'does not apply the collation' do
|
1336
|
+
expect(authorized_collection.find(name: 'pong').count).to eq(0)
|
1337
|
+
end
|
1338
|
+
|
1339
|
+
it 'reports the upserted id' do
|
1340
|
+
expect(result.upserted_ids).to eq([])
|
1341
|
+
end
|
1342
|
+
|
1343
|
+
it 'reports the upserted count' do
|
1344
|
+
expect(result.upserted_count).to eq(0)
|
1345
|
+
end
|
1346
|
+
|
1347
|
+
it 'reports the modified count' do
|
1348
|
+
expect(result.modified_count).to eq(0)
|
1349
|
+
end
|
1350
|
+
|
1351
|
+
it 'reports the matched count' do
|
1352
|
+
expect(result.matched_count).to eq(0)
|
1353
|
+
end
|
1354
|
+
end
|
1355
|
+
|
763
1356
|
context 'when upsert is false' do
|
764
1357
|
|
765
1358
|
let(:requests) do
|
@@ -791,7 +1384,7 @@ describe Mongo::BulkWrite do
|
|
791
1384
|
end
|
792
1385
|
|
793
1386
|
it 'reports the matched count' do
|
794
|
-
expect(result.
|
1387
|
+
expect(result.matched_count).to eq(2)
|
795
1388
|
end
|
796
1389
|
|
797
1390
|
context 'when there is a write concern error' do
|