mongo 2.9.2 → 2.10.0.rc0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/mongo.rb +1 -0
  5. data/lib/mongo/auth/user/view.rb +4 -4
  6. data/lib/mongo/bulk_write.rb +14 -8
  7. data/lib/mongo/bulk_write/result.rb +1 -1
  8. data/lib/mongo/bulk_write/result_combiner.rb +2 -2
  9. data/lib/mongo/bulk_write/transformable.rb +17 -9
  10. data/lib/mongo/client.rb +107 -16
  11. data/lib/mongo/cluster.rb +47 -25
  12. data/lib/mongo/cluster/topology/replica_set_no_primary.rb +1 -1
  13. data/lib/mongo/cluster_time.rb +139 -0
  14. data/lib/mongo/collection.rb +84 -25
  15. data/lib/mongo/collection/view.rb +7 -3
  16. data/lib/mongo/collection/view/aggregation.rb +4 -4
  17. data/lib/mongo/collection/view/builder/aggregation.rb +31 -6
  18. data/lib/mongo/collection/view/builder/find_command.rb +4 -1
  19. data/lib/mongo/collection/view/builder/map_reduce.rb +4 -1
  20. data/lib/mongo/collection/view/change_stream.rb +54 -66
  21. data/lib/mongo/collection/view/iterable.rb +2 -2
  22. data/lib/mongo/collection/view/map_reduce.rb +6 -4
  23. data/lib/mongo/collection/view/readable.rb +36 -16
  24. data/lib/mongo/collection/view/writable.rb +68 -22
  25. data/lib/mongo/cursor.rb +87 -20
  26. data/lib/mongo/database.rb +47 -43
  27. data/lib/mongo/database/view.rb +54 -11
  28. data/lib/mongo/error.rb +13 -4
  29. data/lib/mongo/error/invalid_write_concern.rb +2 -2
  30. data/lib/mongo/error/operation_failure.rb +65 -11
  31. data/lib/mongo/error/parser.rb +41 -8
  32. data/lib/mongo/grid/fs_bucket.rb +26 -6
  33. data/lib/mongo/grid/stream/read.rb +9 -2
  34. data/lib/mongo/grid/stream/write.rb +21 -5
  35. data/lib/mongo/index/view.rb +3 -3
  36. data/lib/mongo/lint.rb +10 -3
  37. data/lib/mongo/operation.rb +2 -0
  38. data/lib/mongo/operation/aggregate/result.rb +19 -6
  39. data/lib/mongo/operation/collections_info.rb +1 -1
  40. data/lib/mongo/operation/get_more/result.rb +9 -0
  41. data/lib/mongo/operation/list_collections/command.rb +1 -3
  42. data/lib/mongo/operation/list_collections/op_msg.rb +1 -2
  43. data/lib/mongo/operation/parallel_scan/command.rb +4 -1
  44. data/lib/mongo/operation/parallel_scan/op_msg.rb +4 -1
  45. data/lib/mongo/operation/result.rb +27 -4
  46. data/lib/mongo/operation/shared/executable.rb +19 -5
  47. data/lib/mongo/operation/shared/executable_no_validate.rb +1 -2
  48. data/lib/mongo/operation/shared/executable_transaction_label.rb +0 -9
  49. data/lib/mongo/operation/shared/polymorphic_result.rb +9 -1
  50. data/lib/mongo/operation/shared/result/aggregatable.rb +2 -2
  51. data/lib/mongo/operation/shared/sessions_supported.rb +42 -32
  52. data/lib/mongo/operation/shared/specifiable.rb +40 -0
  53. data/lib/mongo/operation/shared/unpinnable.rb +39 -0
  54. data/lib/mongo/operation/shared/write.rb +1 -1
  55. data/lib/mongo/protocol/update.rb +6 -2
  56. data/lib/mongo/retryable.rb +79 -39
  57. data/lib/mongo/server/connection.rb +10 -3
  58. data/lib/mongo/server/description.rb +25 -1
  59. data/lib/mongo/server/monitor/connection.rb +1 -1
  60. data/lib/mongo/server_selector.rb +10 -0
  61. data/lib/mongo/server_selector/selectable.rb +172 -32
  62. data/lib/mongo/session.rb +654 -581
  63. data/lib/mongo/session/session_pool.rb +1 -1
  64. data/lib/mongo/socket.rb +7 -28
  65. data/lib/mongo/socket/ssl.rb +26 -1
  66. data/lib/mongo/socket/tcp.rb +3 -0
  67. data/lib/mongo/socket/unix.rb +3 -0
  68. data/lib/mongo/uri.rb +112 -265
  69. data/lib/mongo/uri/srv_protocol.rb +4 -1
  70. data/lib/mongo/version.rb +1 -1
  71. data/lib/mongo/write_concern.rb +10 -29
  72. data/lib/mongo/write_concern/acknowledged.rb +12 -0
  73. data/lib/mongo/write_concern/base.rb +17 -13
  74. data/lib/mongo/write_concern/unacknowledged.rb +12 -0
  75. data/spec/atlas/atlas_connectivity_spec.rb +7 -37
  76. data/spec/atlas/operations_spec.rb +25 -0
  77. data/spec/integration/change_stream_examples_spec.rb +45 -31
  78. data/spec/integration/change_stream_spec.rb +305 -5
  79. data/spec/integration/client_spec.rb +44 -0
  80. data/spec/integration/command_monitoring_spec.rb +1 -0
  81. data/spec/integration/command_spec.rb +7 -1
  82. data/spec/integration/mmapv1_spec.rb +28 -0
  83. data/spec/integration/mongos_pinning_spec.rb +34 -0
  84. data/spec/integration/operation_failure_code_spec.rb +2 -2
  85. data/spec/integration/{read_concern.rb → read_concern_spec.rb} +7 -1
  86. data/spec/integration/read_preference_spec.rb +485 -0
  87. data/spec/integration/retryable_writes_spec.rb +8 -19
  88. data/spec/integration/sdam_error_handling_spec.rb +1 -1
  89. data/spec/integration/sdam_events_spec.rb +2 -2
  90. data/spec/integration/server_description_spec.rb +14 -17
  91. data/spec/integration/server_selector_spec.rb +7 -3
  92. data/spec/integration/server_spec.rb +48 -0
  93. data/spec/integration/ssl_uri_options_spec.rb +1 -1
  94. data/spec/integration/step_down_spec.rb +10 -4
  95. data/spec/integration/transactions_examples_spec.rb +11 -10
  96. data/spec/lite_spec_helper.rb +19 -16
  97. data/spec/mongo/auth/scram/negotiation_spec.rb +11 -8
  98. data/spec/mongo/bulk_write/ordered_combiner_spec.rb +6 -6
  99. data/spec/mongo/bulk_write/unordered_combiner_spec.rb +4 -4
  100. data/spec/mongo/bulk_write_spec.rb +12 -2
  101. data/spec/mongo/client_construction_spec.rb +160 -8
  102. data/spec/mongo/client_spec.rb +5 -4
  103. data/spec/mongo/cluster_spec.rb +6 -6
  104. data/spec/mongo/cluster_time_spec.rb +148 -0
  105. data/spec/mongo/collection/view/aggregation_spec.rb +34 -15
  106. data/spec/mongo/collection/view/change_stream_spec.rb +62 -3
  107. data/spec/mongo/collection/view/map_reduce_spec.rb +7 -5
  108. data/spec/mongo/collection/view/readable_spec.rb +4 -4
  109. data/spec/mongo/collection_spec.rb +331 -14
  110. data/spec/mongo/cursor_spec.rb +117 -5
  111. data/spec/mongo/database_spec.rb +240 -8
  112. data/spec/mongo/error/operation_failure_spec.rb +47 -1
  113. data/spec/mongo/error/parser_spec.rb +160 -23
  114. data/spec/mongo/operation/insert/bulk_spec.rb +2 -1
  115. data/spec/mongo/operation/result_spec.rb +27 -0
  116. data/spec/mongo/operation/update/bulk_spec.rb +1 -0
  117. data/spec/mongo/retryable_spec.rb +2 -0
  118. data/spec/mongo/server/app_metadata_spec.rb +2 -2
  119. data/spec/mongo/server/connection_spec.rb +13 -17
  120. data/spec/mongo/server/monitor/connection_spec.rb +13 -10
  121. data/spec/mongo/server_selector_spec.rb +34 -2
  122. data/spec/mongo/session/session_pool_spec.rb +14 -3
  123. data/spec/mongo/session_spec.rb +3 -3
  124. data/spec/mongo/session_transaction_spec.rb +4 -3
  125. data/spec/mongo/socket/ssl_spec.rb +19 -5
  126. data/spec/mongo/socket_spec.rb +1 -62
  127. data/spec/mongo/uri/srv_protocol_spec.rb +14 -20
  128. data/spec/mongo/uri_option_parsing_spec.rb +94 -8
  129. data/spec/mongo/uri_spec.rb +23 -10
  130. data/spec/mongo/write_concern_spec.rb +56 -3
  131. data/spec/spec_tests/change_streams_spec.rb +2 -1
  132. data/spec/spec_tests/cmap_spec.rb +1 -1
  133. data/spec/spec_tests/crud_spec.rb +12 -2
  134. data/spec/spec_tests/data/change_streams/change-streams-errors.yml +24 -1
  135. data/spec/spec_tests/data/change_streams/change-streams.yml +172 -3
  136. data/spec/spec_tests/data/command_monitoring/bulkWrite.yml +1 -1
  137. data/spec/spec_tests/data/command_monitoring/updateMany.yml +0 -2
  138. data/spec/spec_tests/data/command_monitoring/updateOne.yml +0 -5
  139. data/spec/spec_tests/data/crud/read/aggregate-out.yml +0 -6
  140. data/spec/spec_tests/data/crud/read/count-empty.yml +29 -0
  141. data/spec/spec_tests/data/crud/write/bulkWrite-arrayFilters.yml +1 -0
  142. data/spec/spec_tests/data/crud/write/bulkWrite-collation.yml +101 -0
  143. data/spec/spec_tests/data/crud/write/bulkWrite.yml +401 -0
  144. data/spec/spec_tests/data/crud/write/insertMany.yml +58 -2
  145. data/spec/spec_tests/data/crud/write/updateMany-arrayFilters.yml +3 -0
  146. data/spec/spec_tests/data/crud/write/updateOne-arrayFilters.yml +6 -1
  147. data/spec/spec_tests/data/crud_v2/aggregate-merge.yml +103 -0
  148. data/spec/spec_tests/data/crud_v2/aggregate-out-readConcern.yml +110 -0
  149. data/spec/spec_tests/data/crud_v2/bulkWrite-arrayFilters.yml +81 -0
  150. data/spec/spec_tests/data/crud_v2/db-aggregate.yml +38 -0
  151. data/spec/spec_tests/data/crud_v2/updateWithPipelines.yml +92 -0
  152. data/spec/spec_tests/data/retryable_writes/insertOne-serverErrors.yml +2 -2
  153. data/spec/spec_tests/data/transactions/abort.yml +3 -0
  154. data/spec/spec_tests/data/transactions/bulk.yml +3 -8
  155. data/spec/spec_tests/data/transactions/causal-consistency.yml +3 -8
  156. data/spec/spec_tests/data/transactions/commit.yml +3 -1
  157. data/spec/spec_tests/data/transactions/count.yml +3 -0
  158. data/spec/spec_tests/data/transactions/delete.yml +3 -0
  159. data/spec/spec_tests/data/transactions/error-labels.yml +4 -1
  160. data/spec/spec_tests/data/transactions/errors-client.yml +56 -0
  161. data/spec/spec_tests/data/transactions/errors.yml +3 -0
  162. data/spec/spec_tests/data/transactions/findOneAndDelete.yml +3 -0
  163. data/spec/spec_tests/data/transactions/findOneAndReplace.yml +3 -0
  164. data/spec/spec_tests/data/transactions/findOneAndUpdate.yml +3 -0
  165. data/spec/spec_tests/data/transactions/insert.yml +3 -0
  166. data/spec/spec_tests/data/transactions/isolation.yml +3 -0
  167. data/spec/spec_tests/data/transactions/mongos-pin-auto.yml +1671 -0
  168. data/spec/spec_tests/data/transactions/mongos-recovery-token.yml +347 -0
  169. data/spec/spec_tests/data/transactions/pin-mongos.yml +557 -0
  170. data/spec/spec_tests/data/transactions/read-concern.yml +3 -0
  171. data/spec/spec_tests/data/transactions/read-pref.yml +3 -0
  172. data/spec/spec_tests/data/transactions/reads.yml +3 -0
  173. data/spec/spec_tests/data/transactions/retryable-abort.yml +5 -2
  174. data/spec/spec_tests/data/transactions/retryable-commit.yml +4 -1
  175. data/spec/spec_tests/data/transactions/retryable-writes.yml +3 -0
  176. data/spec/spec_tests/data/transactions/run-command.yml +3 -0
  177. data/spec/spec_tests/data/transactions/transaction-options.yml +6 -0
  178. data/spec/spec_tests/data/transactions/update.yml +3 -8
  179. data/spec/spec_tests/data/transactions/write-concern.yml +348 -38
  180. data/spec/spec_tests/data/transactions_api/callback-aborts.yml +6 -0
  181. data/spec/spec_tests/data/transactions_api/callback-commits.yml +5 -0
  182. data/spec/spec_tests/data/transactions_api/callback-retry.yml +7 -2
  183. data/spec/spec_tests/data/transactions_api/commit-retry.yml +70 -15
  184. data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror-4.2.yml +3 -0
  185. data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror.yml +3 -0
  186. data/spec/spec_tests/data/transactions_api/commit-writeconcernerror.yml +59 -109
  187. data/spec/spec_tests/data/transactions_api/commit.yml +5 -0
  188. data/spec/spec_tests/data/transactions_api/transaction-options.yml +10 -0
  189. data/spec/spec_tests/retryable_reads_spec.rb +5 -2
  190. data/spec/spec_tests/retryable_writes_spec.rb +5 -2
  191. data/spec/spec_tests/sdam_monitoring_spec.rb +3 -3
  192. data/spec/spec_tests/sdam_spec.rb +2 -2
  193. data/spec/spec_tests/transactions_api_spec.rb +1 -67
  194. data/spec/spec_tests/transactions_spec.rb +2 -66
  195. data/spec/support/authorization.rb +4 -0
  196. data/spec/support/change_streams.rb +30 -10
  197. data/spec/support/change_streams/operation.rb +27 -0
  198. data/spec/support/client_registry.rb +44 -25
  199. data/spec/support/cluster_config.rb +25 -14
  200. data/spec/support/cluster_tools.rb +32 -10
  201. data/spec/support/command_monitoring.rb +1 -1
  202. data/spec/support/common_shortcuts.rb +30 -0
  203. data/spec/support/connection_string.rb +8 -3
  204. data/spec/support/constraints.rb +34 -0
  205. data/spec/support/crud.rb +31 -16
  206. data/spec/support/crud/context.rb +23 -0
  207. data/spec/support/crud/operation.rb +311 -14
  208. data/spec/support/crud/spec.rb +2 -1
  209. data/spec/support/crud/test.rb +24 -27
  210. data/spec/support/crud/test_base.rb +22 -0
  211. data/spec/support/crud/verifier.rb +15 -1
  212. data/spec/support/event_subscriber.rb +12 -0
  213. data/spec/support/sdam_formatter_integration.rb +12 -6
  214. data/spec/support/shared/server_selector.rb +10 -0
  215. data/spec/support/shared/session.rb +13 -12
  216. data/spec/support/spec_config.rb +32 -22
  217. data/spec/support/spec_setup.rb +2 -2
  218. data/spec/support/transactions.rb +87 -0
  219. data/spec/support/transactions/context.rb +33 -0
  220. data/spec/support/transactions/operation.rb +99 -349
  221. data/spec/support/transactions/spec.rb +1 -3
  222. data/spec/support/transactions/test.rb +110 -49
  223. data/spec/support/utils.rb +74 -1
  224. metadata +52 -10
  225. metadata.gz.sig +0 -0
  226. data/spec/support/crud/read.rb +0 -265
  227. data/spec/support/crud/write.rb +0 -284
@@ -39,7 +39,7 @@ tests:
39
39
  command:
40
40
  update: *collection_name
41
41
  updates:
42
- - { q: {_id: 3 }, u: { $set: { x: 333 } }, upsert: false, multi: false }
42
+ - { q: {_id: 3 }, u: { $set: { x: 333 } } }
43
43
  ordered: true
44
44
  command_name: "update"
45
45
  database_name: *database_name
@@ -27,7 +27,6 @@ tests:
27
27
  q: { _id: { $gt: 1 }}
28
28
  u: { $inc: { x: 1 }}
29
29
  multi: true
30
- upsert: false
31
30
  command_name: "update"
32
31
  database_name: *database_name
33
32
  -
@@ -54,7 +53,6 @@ tests:
54
53
  q: { _id: { $gt: 1 }}
55
54
  u: { $nothing: { x: 1 }}
56
55
  multi: true
57
- upsert: false
58
56
  command_name: "update"
59
57
  database_name: *database_name
60
58
  -
@@ -26,8 +26,6 @@ tests:
26
26
  -
27
27
  q: { _id: { $gt: 1 }}
28
28
  u: { $inc: { x: 1 }}
29
- multi: false
30
- upsert: false
31
29
  command_name: "update"
32
30
  database_name: *database_name
33
31
  -
@@ -54,7 +52,6 @@ tests:
54
52
  -
55
53
  q: { _id: 4 }
56
54
  u: { $inc: { x: 1 } }
57
- multi: false
58
55
  upsert: true
59
56
  command_name: "update"
60
57
  database_name: *database_name
@@ -81,8 +78,6 @@ tests:
81
78
  -
82
79
  q: { _id: { $gt: 1 }}
83
80
  u: { $nothing: { x: 1 }}
84
- multi: false
85
- upsert: false
86
81
  command_name: "update"
87
82
  database_name: *database_name
88
83
  -
@@ -18,9 +18,6 @@ tests:
18
18
  batchSize: 2
19
19
 
20
20
  outcome:
21
- # Some drivers apparently return a cursor to the output collection.
22
- # Ruby driver does not, hence result is empty.
23
- result: []
24
21
  collection:
25
22
  name: "other_test_collection"
26
23
  data:
@@ -39,9 +36,6 @@ tests:
39
36
  batchSize: 0
40
37
 
41
38
  outcome:
42
- # Some drivers apparently return a cursor to the output collection.
43
- # Ruby driver does not, hence result is empty.
44
- result: []
45
39
  collection:
46
40
  name: "other_test_collection"
47
41
  data:
@@ -0,0 +1,29 @@
1
+ data: []
2
+
3
+ tests:
4
+ -
5
+ description: "Estimated document count with empty collection"
6
+ operation:
7
+ name: estimatedDocumentCount
8
+ arguments: { }
9
+
10
+ outcome:
11
+ result: 0
12
+ -
13
+ description: "Count documents with empty collection"
14
+ operation:
15
+ name: countDocuments
16
+ arguments:
17
+ filter: { }
18
+
19
+ outcome:
20
+ result: 0
21
+ -
22
+ description: "Deprecated count with empty collection"
23
+ operation:
24
+ name: count
25
+ arguments:
26
+ filter: { }
27
+
28
+ outcome:
29
+ result: 0
@@ -33,6 +33,7 @@ tests:
33
33
  outcome:
34
34
  result:
35
35
  deletedCount: 0
36
+ insertedCount: 0
36
37
  insertedIds: {}
37
38
  matchedCount: 3
38
39
  modifiedCount: 3
@@ -0,0 +1,101 @@
1
+ data:
2
+ - {_id: 1, x: 11}
3
+ - {_id: 2, x: 'ping'}
4
+ - {_id: 3, x: 'pINg'}
5
+ - {_id: 4, x: 'pong'}
6
+ - {_id: 5, x: 'pONg'}
7
+
8
+ minServerVersion: '3.4'
9
+
10
+ # See: https://docs.mongodb.com/master/reference/collation/#collation-document
11
+ tests:
12
+ -
13
+ description: "BulkWrite with delete operations and collation"
14
+ operation:
15
+ name: "bulkWrite"
16
+ arguments:
17
+ requests:
18
+ -
19
+ # matches two documents but deletes one
20
+ name: "deleteOne"
21
+ arguments:
22
+ filter: { x: "PING" }
23
+ collation: { locale: "en_US", strength: 2 }
24
+ -
25
+ # matches the remaining document and deletes it
26
+ name: "deleteOne"
27
+ arguments:
28
+ filter: { x: "PING" }
29
+ collation: { locale: "en_US", strength: 2 }
30
+ -
31
+ # matches two documents and deletes them
32
+ name: "deleteMany"
33
+ arguments:
34
+ filter: { x: "PONG" }
35
+ collation: { locale: "en_US", strength: 2 }
36
+ options: { ordered: true }
37
+ outcome:
38
+ result:
39
+ deletedCount: 4
40
+ insertedCount: 0
41
+ insertedIds: {}
42
+ matchedCount: 0
43
+ modifiedCount: 0
44
+ upsertedCount: 0
45
+ upsertedIds: {}
46
+ collection:
47
+ data:
48
+ - {_id: 1, x: 11 }
49
+ -
50
+ description: "BulkWrite with update operations and collation"
51
+ operation:
52
+ name: "bulkWrite"
53
+ arguments:
54
+ requests:
55
+ -
56
+ # matches only one document due to strength and updates
57
+ name: "updateMany"
58
+ arguments:
59
+ filter: { x: "ping" }
60
+ update: { $set: { x: "PONG" } }
61
+ collation: { locale: "en_US", strength: 3 }
62
+ -
63
+ # matches one document and updates
64
+ name: "updateOne"
65
+ arguments:
66
+ filter: { x: "ping" }
67
+ update: { $set: { x: "PONG" } }
68
+ collation: { locale: "en_US", strength: 2 }
69
+ -
70
+ # matches no document due to strength and upserts
71
+ name: "replaceOne"
72
+ arguments:
73
+ filter: { x: "ping" }
74
+ replacement: { _id: 6, x: "ping" }
75
+ upsert: true
76
+ collation: { locale: "en_US", strength: 3 }
77
+ -
78
+ # matches two documents and updates
79
+ name: "updateMany"
80
+ arguments:
81
+ filter: { x: "pong" }
82
+ update: { $set: { x: "PONG" } }
83
+ collation: { locale: "en_US", strength: 2 }
84
+ options: { ordered: true }
85
+ outcome:
86
+ result:
87
+ deletedCount: 0
88
+ insertedCount: 0
89
+ insertedIds: {}
90
+ matchedCount: 6
91
+ modifiedCount: 4
92
+ upsertedCount: 1
93
+ upsertedIds: { 2: 6 }
94
+ collection:
95
+ data:
96
+ - {_id: 1, x: 11 }
97
+ - {_id: 2, x: "PONG" }
98
+ - {_id: 3, x: "PONG" }
99
+ - {_id: 4, x: "PONG" }
100
+ - {_id: 5, x: "PONG" }
101
+ - {_id: 6, x: "ping" }
@@ -0,0 +1,401 @@
1
+ data:
2
+ - {_id: 1, x: 11}
3
+ - {_id: 2, x: 22}
4
+
5
+ minServerVersion: '2.6'
6
+
7
+ tests:
8
+ -
9
+ description: "BulkWrite with deleteOne operations"
10
+ operation:
11
+ name: "bulkWrite"
12
+ arguments:
13
+ # Note: as in the "DeleteOne when many documents match" test in
14
+ # deleteOne.yml, we omit a deleteOne operation that might match
15
+ # multiple documents as that would hinder our ability to assert
16
+ # the final state of the collection under test.
17
+ requests:
18
+ -
19
+ # does not match an existing document
20
+ name: "deleteOne"
21
+ arguments:
22
+ filter: { _id: 3 }
23
+ -
24
+ # deletes the matched document
25
+ name: "deleteOne"
26
+ arguments:
27
+ filter: { _id: 2 }
28
+ options: { ordered: true }
29
+ outcome:
30
+ result:
31
+ deletedCount: 1
32
+ insertedCount: 0
33
+ insertedIds: {}
34
+ matchedCount: 0
35
+ modifiedCount: 0
36
+ upsertedCount: 0
37
+ upsertedIds: {}
38
+ collection:
39
+ data:
40
+ - {_id: 1, x: 11 }
41
+ -
42
+ description: "BulkWrite with deleteMany operations"
43
+ operation:
44
+ name: "bulkWrite"
45
+ arguments:
46
+ requests:
47
+ -
48
+ # does not match any existing documents
49
+ name: "deleteMany"
50
+ arguments:
51
+ filter: { x: { $lt: 11 } }
52
+ -
53
+ # deletes the matched documents
54
+ name: "deleteMany"
55
+ arguments:
56
+ filter: { x: { $lte: 22 } }
57
+ options: { ordered: true }
58
+ outcome:
59
+ result:
60
+ deletedCount: 2
61
+ insertedCount: 0
62
+ insertedIds: {}
63
+ matchedCount: 0
64
+ modifiedCount: 0
65
+ upsertedCount: 0
66
+ upsertedIds: {}
67
+ collection:
68
+ data: []
69
+ -
70
+ description: "BulkWrite with insertOne operations"
71
+ operation:
72
+ name: "bulkWrite"
73
+ arguments:
74
+ requests:
75
+ -
76
+ name: "insertOne"
77
+ arguments:
78
+ document: { _id: 3, x: 33 }
79
+ -
80
+ name: "insertOne"
81
+ arguments:
82
+ document: { _id: 4, x: 44 }
83
+ options: { ordered: true }
84
+ outcome:
85
+ result:
86
+ deletedCount: 0
87
+ insertedCount: 2
88
+ insertedIds: { 0: 3, 1: 4 }
89
+ matchedCount: 0
90
+ modifiedCount: 0
91
+ upsertedCount: 0
92
+ upsertedIds: {}
93
+ collection:
94
+ data:
95
+ - {_id: 1, x: 11 }
96
+ - {_id: 2, x: 22 }
97
+ - {_id: 3, x: 33 }
98
+ - {_id: 4, x: 44 }
99
+ -
100
+ description: "BulkWrite with replaceOne operations"
101
+ operation:
102
+ name: "bulkWrite"
103
+ arguments:
104
+ # Note: as in the "ReplaceOne when many documents match" test in
105
+ # replaceOne.yml, we omit a replaceOne operation that might
106
+ # match multiple documents as that would hinder our ability to
107
+ # assert the final state of the collection under test.
108
+ requests:
109
+ -
110
+ # does not match an existing document
111
+ name: "replaceOne"
112
+ arguments:
113
+ filter: { _id: 3 }
114
+ replacement: { x: 33 }
115
+ -
116
+ # modifies the matched document
117
+ name: "replaceOne"
118
+ arguments:
119
+ filter: { _id: 1 }
120
+ replacement: { x: 12 }
121
+ -
122
+ # does not match an existing document and upserts
123
+ name: "replaceOne"
124
+ arguments:
125
+ filter: { _id: 3 }
126
+ replacement: { x: 33 }
127
+ upsert: true
128
+ options: { ordered: true }
129
+ outcome:
130
+ result:
131
+ deletedCount: 0
132
+ insertedCount: 0
133
+ insertedIds: {}
134
+ matchedCount: 1
135
+ modifiedCount: 1
136
+ upsertedCount: 1
137
+ upsertedIds: { 2: 3 }
138
+ collection:
139
+ data:
140
+ - {_id: 1, x: 12 }
141
+ - {_id: 2, x: 22 }
142
+ - {_id: 3, x: 33 }
143
+ -
144
+ description: "BulkWrite with updateOne operations"
145
+ operation:
146
+ name: "bulkWrite"
147
+ arguments:
148
+ # Note: as in the "UpdateOne when many documents match" test in
149
+ # updateOne.yml, we omit an updateOne operation that might match
150
+ # multiple documents as that would hinder our ability to assert
151
+ # the final state of the collection under test.
152
+ requests:
153
+ -
154
+ # does not match an existing document
155
+ name: "updateOne"
156
+ arguments:
157
+ filter: { _id: 0 }
158
+ update: { $set: { x: 0 } }
159
+ -
160
+ # does not modify the matched document
161
+ name: "updateOne"
162
+ arguments:
163
+ filter: { _id: 1 }
164
+ update: { $set: { x: 11 } }
165
+ -
166
+ # modifies the matched document
167
+ name: "updateOne"
168
+ arguments:
169
+ filter: { _id: 2 }
170
+ update: { $inc: { x: 1 } }
171
+ -
172
+ # does not match an existing document and upserts
173
+ name: "updateOne"
174
+ arguments:
175
+ filter: { _id: 3 }
176
+ update: { $set: { x: 33 } }
177
+ upsert: true
178
+ options: { ordered: true }
179
+ outcome:
180
+ result:
181
+ deletedCount: 0
182
+ insertedCount: 0
183
+ insertedIds: {}
184
+ matchedCount: 2
185
+ modifiedCount: 1
186
+ upsertedCount: 1
187
+ upsertedIds: { 3: 3 }
188
+ collection:
189
+ data:
190
+ - {_id: 1, x: 11 }
191
+ - {_id: 2, x: 23 }
192
+ - {_id: 3, x: 33 }
193
+ -
194
+ description: "BulkWrite with updateMany operations"
195
+ operation:
196
+ name: "bulkWrite"
197
+ arguments:
198
+ requests:
199
+ -
200
+ # does not match any existing documents
201
+ name: "updateMany"
202
+ arguments:
203
+ filter: { x: { $lt: 11 } }
204
+ update: { $set: { x: 0 } }
205
+ -
206
+ # does not modify the matched documents
207
+ name: "updateMany"
208
+ arguments:
209
+ filter: { x: { $lte: 22 } }
210
+ update: { $unset: { y: 1 } }
211
+ -
212
+ # modifies the matched documents
213
+ name: "updateMany"
214
+ arguments:
215
+ filter: { x: { $lte: 22 } }
216
+ update: { $inc: { x: 1 } }
217
+ -
218
+ # does not match any existing documents and upserts
219
+ name: "updateMany"
220
+ arguments:
221
+ filter: { _id: 3 }
222
+ update: { $set: { x: 33 } }
223
+ upsert: true
224
+ options: { ordered: true }
225
+ outcome:
226
+ result:
227
+ deletedCount: 0
228
+ insertedCount: 0
229
+ insertedIds: {}
230
+ matchedCount: 4
231
+ modifiedCount: 2
232
+ upsertedCount: 1
233
+ upsertedIds: { 3: 3 }
234
+ collection:
235
+ data:
236
+ - {_id: 1, x: 12 }
237
+ - {_id: 2, x: 23 }
238
+ - {_id: 3, x: 33 }
239
+ -
240
+ description: "BulkWrite with mixed ordered operations"
241
+ operation:
242
+ name: "bulkWrite"
243
+ arguments:
244
+ requests:
245
+ -
246
+ name: "insertOne"
247
+ arguments:
248
+ document: { _id: 3, x: 33 }
249
+ -
250
+ name: "updateOne"
251
+ arguments:
252
+ filter: { _id: 2 }
253
+ update: { $inc: { x: 1 } }
254
+ -
255
+ name: "updateMany"
256
+ arguments:
257
+ filter: { _id: { $gt: 1 } }
258
+ update: { $inc: { x: 1 } }
259
+ -
260
+ name: "insertOne"
261
+ arguments:
262
+ document: { _id: 4, x: 44 }
263
+ -
264
+ name: "deleteMany"
265
+ arguments:
266
+ filter: { x: { $nin: [ 24, 34 ] } }
267
+ -
268
+ name: "replaceOne"
269
+ arguments:
270
+ filter: { _id: 4 }
271
+ replacement: { _id: 4, x: 44 }
272
+ upsert: true
273
+ options: { ordered: true }
274
+ outcome:
275
+ result:
276
+ deletedCount: 2
277
+ insertedCount: 2
278
+ insertedIds: { 0: 3, 3: 4 }
279
+ matchedCount: 3
280
+ modifiedCount: 3
281
+ upsertedCount: 1
282
+ upsertedIds: { 5: 4 }
283
+ collection:
284
+ data:
285
+ - {_id: 2, x: 24 }
286
+ - {_id: 3, x: 34 }
287
+ - {_id: 4, x: 44 }
288
+ -
289
+ description: "BulkWrite with mixed unordered operations"
290
+ operation:
291
+ name: "bulkWrite"
292
+ arguments:
293
+ # We omit inserting multiple documents and updating documents
294
+ # that may not exist at the start of this test as we cannot
295
+ # assume the order in which the operations will execute.
296
+ requests:
297
+ -
298
+ name: "replaceOne"
299
+ arguments:
300
+ filter: { _id: 3 }
301
+ replacement: { _id: 3, x: 33 }
302
+ upsert: true
303
+ -
304
+ name: "deleteOne"
305
+ arguments:
306
+ filter: { _id: 1 }
307
+ -
308
+ name: "updateOne"
309
+ arguments:
310
+ filter: { _id: 2 }
311
+ update: { $inc: { x: 1 } }
312
+ options: { ordered: false }
313
+ outcome:
314
+ result:
315
+ deletedCount: 1
316
+ insertedCount: 0
317
+ insertedIds: {}
318
+ matchedCount: 1
319
+ modifiedCount: 1
320
+ upsertedCount: 1
321
+ upsertedIds: { 0: 3 }
322
+ collection:
323
+ data:
324
+ - {_id: 2, x: 23 }
325
+ - {_id: 3, x: 33 }
326
+ -
327
+ description: "BulkWrite continue-on-error behavior with unordered (preexisting duplicate key)"
328
+ operation:
329
+ name: "bulkWrite"
330
+ arguments:
331
+ requests:
332
+ -
333
+ name: "insertOne"
334
+ arguments:
335
+ document: { _id: 2, x: 22 }
336
+ -
337
+ name: "insertOne"
338
+ arguments:
339
+ document: { _id: 3, x: 33 }
340
+ -
341
+ name: "insertOne"
342
+ arguments:
343
+ document: { _id: 4, x: 44 }
344
+ options: { ordered: false }
345
+ outcome:
346
+ error: true
347
+ result:
348
+ deletedCount: 0
349
+ insertedCount: 2
350
+ # Since the map of insertedIds is generated before execution it
351
+ # could indicate inserts that did not actually succeed. We omit
352
+ # this field rather than expect drivers to provide an accurate
353
+ # map filtered by write errors.
354
+ matchedCount: 0
355
+ modifiedCount: 0
356
+ upsertedCount: 0
357
+ upsertedIds: { }
358
+ collection:
359
+ data:
360
+ - { _id: 1, x: 11 }
361
+ - { _id: 2, x: 22 }
362
+ - { _id: 3, x: 33 }
363
+ - { _id: 4, x: 44 }
364
+ -
365
+ description: "BulkWrite continue-on-error behavior with unordered (duplicate key in requests)"
366
+ operation:
367
+ name: "bulkWrite"
368
+ arguments:
369
+ requests:
370
+ -
371
+ name: "insertOne"
372
+ arguments:
373
+ document: { _id: 3, x: 33 }
374
+ -
375
+ name: "insertOne"
376
+ arguments:
377
+ document: { _id: 3, x: 33 }
378
+ -
379
+ name: "insertOne"
380
+ arguments:
381
+ document: { _id: 4, x: 44 }
382
+ options: { ordered: false }
383
+ outcome:
384
+ error: true
385
+ result:
386
+ deletedCount: 0
387
+ insertedCount: 2
388
+ # Since the map of insertedIds is generated before execution it
389
+ # could indicate inserts that did not actually succeed. We omit
390
+ # this field rather than expect drivers to provide an accurate
391
+ # map filtered by write errors.
392
+ matchedCount: 0
393
+ modifiedCount: 0
394
+ upsertedCount: 0
395
+ upsertedIds: { }
396
+ collection:
397
+ data:
398
+ - { _id: 1, x: 11 }
399
+ - { _id: 2, x: 22 }
400
+ - { _id: 3, x: 33 }
401
+ - { _id: 4, x: 44 }