mongo 2.3.1 → 2.4.0.rc0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +2 -3
  4. data/lib/mongo/bulk_write.rb +8 -7
  5. data/lib/mongo/bulk_write/combineable.rb +4 -0
  6. data/lib/mongo/bulk_write/transformable.rb +17 -5
  7. data/lib/mongo/bulk_write/validatable.rb +1 -0
  8. data/lib/mongo/client.rb +3 -0
  9. data/lib/mongo/cluster.rb +8 -0
  10. data/lib/mongo/cluster/app_metadata.rb +135 -0
  11. data/lib/mongo/collection.rb +42 -10
  12. data/lib/mongo/collection/view.rb +15 -1
  13. data/lib/mongo/collection/view/aggregation.rb +5 -0
  14. data/lib/mongo/collection/view/builder/aggregation.rb +13 -3
  15. data/lib/mongo/collection/view/builder/find_command.rb +7 -21
  16. data/lib/mongo/collection/view/builder/map_reduce.rb +22 -5
  17. data/lib/mongo/collection/view/iterable.rb +1 -0
  18. data/lib/mongo/collection/view/map_reduce.rb +5 -0
  19. data/lib/mongo/collection/view/readable.rb +35 -14
  20. data/lib/mongo/collection/view/writable.rb +54 -23
  21. data/lib/mongo/cursor/builder/get_more_command.rb +2 -3
  22. data/lib/mongo/database.rb +10 -2
  23. data/lib/mongo/error.rb +2 -0
  24. data/lib/mongo/error/invalid_application_name.rb +38 -0
  25. data/lib/mongo/error/invalid_server_preference.rb +24 -3
  26. data/lib/mongo/error/unsupported_collation.rb +51 -0
  27. data/lib/mongo/index/view.rb +28 -15
  28. data/lib/mongo/operation.rb +6 -0
  29. data/lib/mongo/operation/commands.rb +3 -0
  30. data/lib/mongo/operation/commands/aggregate.rb +10 -10
  31. data/lib/mongo/operation/commands/create.rb +45 -0
  32. data/lib/mongo/operation/commands/drop.rb +45 -0
  33. data/lib/mongo/operation/commands/drop_database.rb +45 -0
  34. data/lib/mongo/operation/commands/map_reduce.rb +12 -1
  35. data/lib/mongo/operation/commands/parallel_scan.rb +1 -0
  36. data/lib/mongo/operation/read_preference.rb +9 -9
  37. data/lib/mongo/operation/specifiable.rb +34 -0
  38. data/lib/mongo/operation/takes_write_concern.rb +35 -0
  39. data/lib/mongo/operation/write/bulk/bulkable.rb +1 -1
  40. data/lib/mongo/operation/write/command/create_index.rb +6 -0
  41. data/lib/mongo/operation/write/command/drop_index.rb +6 -0
  42. data/lib/mongo/operation/write/command/insert.rb +1 -1
  43. data/lib/mongo/operation/write/command/update.rb +1 -0
  44. data/lib/mongo/operation/write/command/writable.rb +2 -2
  45. data/lib/mongo/operation/write/create_index.rb +2 -2
  46. data/lib/mongo/operation/write/create_user.rb +1 -1
  47. data/lib/mongo/operation/write/delete.rb +5 -1
  48. data/lib/mongo/operation/write/gle.rb +1 -1
  49. data/lib/mongo/operation/write/insert.rb +2 -2
  50. data/lib/mongo/operation/write/remove_user.rb +1 -1
  51. data/lib/mongo/operation/write/update.rb +5 -1
  52. data/lib/mongo/operation/write/update_user.rb +1 -1
  53. data/lib/mongo/operation/write/write_command_enabled.rb +10 -2
  54. data/lib/mongo/protocol/insert.rb +1 -2
  55. data/lib/mongo/protocol/query.rb +3 -7
  56. data/lib/mongo/server.rb +8 -3
  57. data/lib/mongo/server/connection.rb +17 -11
  58. data/lib/mongo/server/description.rb +22 -0
  59. data/lib/mongo/server/description/features.rb +2 -0
  60. data/lib/mongo/server/monitor.rb +5 -0
  61. data/lib/mongo/server/monitor/connection.rb +11 -0
  62. data/lib/mongo/server_selector/nearest.rb +9 -6
  63. data/lib/mongo/server_selector/primary.rb +4 -0
  64. data/lib/mongo/server_selector/primary_preferred.rb +7 -1
  65. data/lib/mongo/server_selector/secondary.rb +5 -0
  66. data/lib/mongo/server_selector/secondary_preferred.rb +7 -2
  67. data/lib/mongo/server_selector/selectable.rb +57 -10
  68. data/lib/mongo/socket/ssl.rb +1 -0
  69. data/lib/mongo/uri.rb +4 -0
  70. data/lib/mongo/version.rb +1 -1
  71. data/lib/mongo/write_concern.rb +1 -0
  72. data/mongo.gemspec +1 -1
  73. data/spec/mongo/auth/cr_spec.rb +7 -1
  74. data/spec/mongo/auth/ldap_spec.rb +7 -1
  75. data/spec/mongo/auth/scram_spec.rb +7 -1
  76. data/spec/mongo/auth/x509_spec.rb +7 -1
  77. data/spec/mongo/bulk_write_spec.rb +598 -5
  78. data/spec/mongo/client_spec.rb +47 -1
  79. data/spec/mongo/cluster/app_metadata_spec.rb +104 -0
  80. data/spec/mongo/cluster/topology/replica_set_spec.rb +14 -8
  81. data/spec/mongo/cluster/topology/sharded_spec.rb +9 -3
  82. data/spec/mongo/cluster/topology/single_spec.rb +10 -4
  83. data/spec/mongo/cluster_spec.rb +29 -0
  84. data/spec/mongo/collection/view/aggregation_spec.rb +139 -0
  85. data/spec/mongo/collection/view/builder/find_command_spec.rb +6 -243
  86. data/spec/mongo/collection/view/map_reduce_spec.rb +104 -0
  87. data/spec/mongo/collection/view/readable_spec.rb +83 -0
  88. data/spec/mongo/collection/view/writable_spec.rb +447 -1
  89. data/spec/mongo/collection/view_spec.rb +57 -0
  90. data/spec/mongo/collection_spec.rb +926 -101
  91. data/spec/mongo/crud_spec.rb +4 -5
  92. data/spec/mongo/database_spec.rb +99 -1
  93. data/spec/mongo/index/view_spec.rb +360 -31
  94. data/spec/mongo/max_staleness_spec.rb +108 -0
  95. data/spec/mongo/operation/read_preference_spec.rb +8 -8
  96. data/spec/mongo/operation/write/command/delete_spec.rb +1 -1
  97. data/spec/mongo/operation/write/command/insert_spec.rb +1 -1
  98. data/spec/mongo/operation/write/command/update_spec.rb +1 -1
  99. data/spec/mongo/server/connection_pool_spec.rb +3 -1
  100. data/spec/mongo/server/connection_spec.rb +17 -7
  101. data/spec/mongo/server/description/features_spec.rb +50 -0
  102. data/spec/mongo/server/description_spec.rb +9 -3
  103. data/spec/mongo/server_selection_spec.rb +5 -3
  104. data/spec/mongo/server_selector/nearest_spec.rb +73 -0
  105. data/spec/mongo/server_selector/primary_preferred_spec.rb +73 -0
  106. data/spec/mongo/server_selector/primary_spec.rb +36 -0
  107. data/spec/mongo/server_selector/secondary_preferred_spec.rb +73 -0
  108. data/spec/mongo/server_selector/secondary_spec.rb +73 -0
  109. data/spec/mongo/server_selector_spec.rb +53 -0
  110. data/spec/mongo/server_spec.rb +3 -1
  111. data/spec/mongo/uri_spec.rb +54 -0
  112. data/spec/mongo/write_concern_spec.rb +18 -0
  113. data/spec/spec_helper.rb +10 -0
  114. data/spec/support/authorization.rb +8 -1
  115. data/spec/support/crud.rb +15 -0
  116. data/spec/support/crud/read.rb +27 -19
  117. data/spec/support/crud/write.rb +28 -3
  118. data/spec/support/crud_tests/read/aggregate.yml +15 -3
  119. data/spec/support/crud_tests/read/count.yml +14 -3
  120. data/spec/support/crud_tests/read/distinct.yml +13 -1
  121. data/spec/support/crud_tests/read/find.yml +12 -2
  122. data/spec/support/crud_tests/write/deleteMany.yml +22 -1
  123. data/spec/support/crud_tests/write/deleteOne.yml +20 -1
  124. data/spec/support/crud_tests/write/findOneAndDelete.yml +27 -2
  125. data/spec/support/crud_tests/write/findOneAndReplace.yml +43 -14
  126. data/spec/support/crud_tests/write/findOneAndUpdate.yml +50 -8
  127. data/spec/support/crud_tests/write/replaceOne.yml +34 -10
  128. data/spec/support/crud_tests/write/updateMany.yml +42 -11
  129. data/spec/support/crud_tests/write/updateOne.yml +32 -7
  130. data/spec/support/max_staleness/ReplicaSetNoPrimary/DefaultNoMaxStaleness.yml +26 -0
  131. data/spec/support/max_staleness/ReplicaSetNoPrimary/Incompatible.yml +25 -0
  132. data/spec/support/max_staleness/ReplicaSetNoPrimary/LastUpdateTime.yml +33 -0
  133. data/spec/support/max_staleness/ReplicaSetNoPrimary/Nearest.yml +33 -0
  134. data/spec/support/max_staleness/ReplicaSetNoPrimary/Nearest2.yml +33 -0
  135. data/spec/support/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred.yml +27 -0
  136. data/spec/support/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred_tags.yml +36 -0
  137. data/spec/support/max_staleness/ReplicaSetNoPrimary/Secondary.yml +51 -0
  138. data/spec/support/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred.yml +26 -0
  139. data/spec/support/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred_tags.yml +51 -0
  140. data/spec/support/max_staleness/ReplicaSetWithPrimary/DefaultNoMaxStaleness.yml +26 -0
  141. data/spec/support/max_staleness/ReplicaSetWithPrimary/Incompatible.yml +25 -0
  142. data/spec/support/max_staleness/ReplicaSetWithPrimary/LastUpdateTime.yml +35 -0
  143. data/spec/support/max_staleness/ReplicaSetWithPrimary/MaxStalenessTooSmall.yml +25 -0
  144. data/spec/support/max_staleness/ReplicaSetWithPrimary/MaxStalenessWithModePrimary.yml +23 -0
  145. data/spec/support/max_staleness/ReplicaSetWithPrimary/Nearest.yml +33 -0
  146. data/spec/support/max_staleness/ReplicaSetWithPrimary/Nearest2.yml +33 -0
  147. data/spec/support/max_staleness/ReplicaSetWithPrimary/Nearest_tags.yml +36 -0
  148. data/spec/support/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred.yml +27 -0
  149. data/spec/support/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred_incompatible.yml +27 -0
  150. data/spec/support/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred.yml +26 -0
  151. data/spec/support/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags.yml +59 -0
  152. data/spec/support/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags2.yml +43 -0
  153. data/spec/support/max_staleness/ReplicaSetWithPrimary/Secondary_tags.yml +59 -0
  154. data/spec/support/max_staleness/ReplicaSetWithPrimary/Secondary_tags2.yml +43 -0
  155. data/spec/support/max_staleness/ReplicaSetWithPrimary/ShortHeartbeartShortMaxStaleness.yml +29 -0
  156. data/spec/support/max_staleness/ReplicaSetWithPrimary/ShortHeartbeartShortMaxStaleness2.yml +29 -0
  157. data/spec/support/max_staleness/ReplicaSetWithPrimary/ZeroMaxStaleness.yml +27 -0
  158. data/spec/support/max_staleness/Sharded/Incompatible.yml +25 -0
  159. data/spec/support/max_staleness/Sharded/SmallMaxStaleness.yml +20 -0
  160. data/spec/support/max_staleness/Single/Incompatible.yml +18 -0
  161. data/spec/support/max_staleness/Single/SmallMaxStaleness.yml +20 -0
  162. data/spec/support/server_selection.rb +25 -0
  163. data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Nearest_multiple.yml +27 -0
  164. data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Secondary_multi_tags.yml +31 -0
  165. data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Secondary_multi_tags2.yml +31 -0
  166. data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Nearest_multiple.yml +34 -0
  167. data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/SecondaryPreferred_tags.yml +28 -0
  168. data/spec/support/shared/server_selector.rb +4 -3
  169. metadata +91 -6
  170. metadata.gz.sig +0 -0
@@ -2,6 +2,8 @@ data:
2
2
  - {_id: 1, x: 11}
3
3
  - {_id: 2, x: 22}
4
4
  - {_id: 3, x: 33}
5
+ - {_id: 4, x: 'ping'}
6
+ - {_id: 5, x: 'pINg'}
5
7
 
6
8
  tests:
7
9
  -
@@ -12,18 +14,35 @@ tests:
12
14
  filter:
13
15
  _id: {$gt: 1}
14
16
 
17
+ outcome:
18
+ result:
19
+ deletedCount: 4
20
+ collection:
21
+ data:
22
+ - {_id: 1, x: 11}
23
+ -
24
+ description: "DeleteMany when many documents match with collation"
25
+ operation:
26
+ name: "deleteMany"
27
+ arguments:
28
+ filter:
29
+ x: 'PING'
30
+ collation: { locale: 'en_US', strength: 2 }
31
+
15
32
  outcome:
16
33
  result:
17
34
  deletedCount: 2
18
35
  collection:
19
36
  data:
20
37
  - {_id: 1, x: 11}
38
+ - {_id: 2, x: 22}
39
+ - {_id: 3, x: 33}
21
40
  -
22
41
  description: "DeleteMany when no document matches"
23
42
  operation:
24
43
  name: "deleteMany"
25
44
  arguments:
26
- filter: {_id: 4}
45
+ filter: {_id: 6}
27
46
 
28
47
  outcome:
29
48
  result:
@@ -33,4 +52,6 @@ tests:
33
52
  - {_id: 1, x: 11}
34
53
  - {_id: 2, x: 22}
35
54
  - {_id: 3, x: 33}
55
+ - {_id: 4, x: 'ping'}
56
+ - {_id: 5, x: 'pINg'}
36
57
 
@@ -2,6 +2,7 @@ data:
2
2
  - {_id: 1, x: 11}
3
3
  - {_id: 2, x: 22}
4
4
  - {_id: 3, x: 33}
5
+ - {_id: 4, x: 'ping'}
5
6
 
6
7
  tests:
7
8
  -
@@ -31,12 +32,29 @@ tests:
31
32
  data:
32
33
  - {_id: 1, x: 11}
33
34
  - {_id: 3, x: 33}
35
+ - {_id: 4, x: 'ping'}
36
+ -
37
+ description: "DeleteOne when one document matches with collation"
38
+ operation:
39
+ name: "deleteOne"
40
+ arguments:
41
+ filter: {x: 'PING'}
42
+ collation: { locale: 'en_US', strength: 2 }
43
+
44
+ outcome:
45
+ result:
46
+ deletedCount: 1
47
+ collection:
48
+ data:
49
+ - {_id: 1, x: 11}
50
+ - {_id: 2, x: 22}
51
+ - {_id: 3, x: 33}
34
52
  -
35
53
  description: "DeleteOne when no documents match"
36
54
  operation:
37
55
  name: "deleteOne"
38
56
  arguments:
39
- filter: {_id: 4}
57
+ filter: {_id: 5}
40
58
 
41
59
  outcome:
42
60
  result:
@@ -46,4 +64,5 @@ tests:
46
64
  - {_id: 1, x: 11}
47
65
  - {_id: 2, x: 22}
48
66
  - {_id: 3, x: 33}
67
+ - {_id: 4, x: 'ping'}
49
68
 
@@ -2,6 +2,8 @@ data:
2
2
  - {_id: 1, x: 11}
3
3
  - {_id: 2, x: 22}
4
4
  - {_id: 3, x: 33}
5
+ - {_id: 4, x: 'ping'}
6
+ - {_id: 5, x: 'pINg'}
5
7
 
6
8
  tests:
7
9
  -
@@ -20,6 +22,8 @@ tests:
20
22
  data:
21
23
  - {_id: 1, x: 11}
22
24
  - {_id: 3, x: 33}
25
+ - {_id: 4, x: 'ping'}
26
+ - {_id: 5, x: 'pINg'}
23
27
  -
24
28
  description: "FindOneAndDelete when one document matches"
25
29
  operation:
@@ -35,12 +39,32 @@ tests:
35
39
  data:
36
40
  - {_id: 1, x: 11}
37
41
  - {_id: 3, x: 33}
42
+ - {_id: 4, x: 'ping'}
43
+ - {_id: 5, x: 'pINg'}
44
+ -
45
+ description: "FindOneAndDelete when one document matches with collation"
46
+ operation:
47
+ name: findOneAndDelete
48
+ arguments:
49
+ filter: {_id: 4, x: 'PING'}
50
+ projection: {x: 1, _id: 0}
51
+ sort: {x: 1}
52
+ collation: { locale: 'en_US', strength: 2 }
53
+
54
+ outcome:
55
+ result: {x: 'ping'}
56
+ collection:
57
+ data:
58
+ - {_id: 1, x: 11}
59
+ - {_id: 2, x: 22}
60
+ - {_id: 3, x: 33}
61
+ - {_id: 5, x: 'pINg'}
38
62
  -
39
63
  description: "FindOneAndDelete when no documents match"
40
64
  operation:
41
65
  name: findOneAndDelete
42
66
  arguments:
43
- filter: {_id: 4}
67
+ filter: {_id: 6}
44
68
  projection: {x: 1, _id: 0}
45
69
  sort: {x: 1}
46
70
 
@@ -51,4 +75,5 @@ tests:
51
75
  - {_id: 1, x: 11}
52
76
  - {_id: 2, x: 22}
53
77
  - {_id: 3, x: 33}
54
-
78
+ - {_id: 4, x: 'ping'}
79
+ - {_id: 5, x: 'pINg'}
@@ -2,6 +2,7 @@ data:
2
2
  - {_id: 1, x: 11}
3
3
  - {_id: 2, x: 22}
4
4
  - {_id: 3, x: 33}
5
+ - {_id: 4, x: 'ping'}
5
6
 
6
7
  tests:
7
8
  -
@@ -9,7 +10,7 @@ tests:
9
10
  operation:
10
11
  name: findOneAndReplace
11
12
  arguments:
12
- filter:
13
+ filter:
13
14
  _id: {$gt: 1}
14
15
  replacement: {x: 32}
15
16
  projection: {x: 1, _id: 0}
@@ -22,12 +23,13 @@ tests:
22
23
  - {_id: 1, x: 11}
23
24
  - {_id: 2, x: 32}
24
25
  - {_id: 3, x: 33}
26
+ - {_id: 4, x: 'ping'}
25
27
  -
26
28
  description: "FindOneAndReplace when many documents match returning the document after modification"
27
29
  operation:
28
30
  name: findOneAndReplace
29
31
  arguments:
30
- filter:
32
+ filter:
31
33
  _id: {$gt: 1}
32
34
  replacement: {x: 32}
33
35
  projection: {x: 1, _id: 0}
@@ -41,6 +43,7 @@ tests:
41
43
  - {_id: 1, x: 11}
42
44
  - {_id: 2, x: 32}
43
45
  - {_id: 3, x: 33}
46
+ - {_id: 4, x: 'ping'}
44
47
  -
45
48
  description: "FindOneAndReplace when one document matches returning the document before modification"
46
49
  operation:
@@ -58,6 +61,7 @@ tests:
58
61
  - {_id: 1, x: 11}
59
62
  - {_id: 2, x: 32}
60
63
  - {_id: 3, x: 33}
64
+ - {_id: 4, x: 'ping'}
61
65
  -
62
66
  description: "FindOneAndReplace when one document matches returning the document after modification"
63
67
  operation:
@@ -76,13 +80,35 @@ tests:
76
80
  - {_id: 1, x: 11}
77
81
  - {_id: 2, x: 32}
78
82
  - {_id: 3, x: 33}
83
+ - {_id: 4, x: 'ping'}
84
+
85
+ -
86
+ description: "FindOneAndReplace when one document matches with collation returning the document after modification"
87
+ operation:
88
+ name: findOneAndReplace
89
+ arguments:
90
+ filter: {x: 'PING'}
91
+ replacement: {x: 32}
92
+ projection: {x: 1, _id: 0}
93
+ returnDocument: After
94
+ sort: {x: 1}
95
+ collation: { locale: 'en_US', strength: 2 }
96
+
97
+ outcome:
98
+ result: {x: 32}
99
+ collection:
100
+ data:
101
+ - {_id: 1, x: 11}
102
+ - {_id: 2, x: 22}
103
+ - {_id: 3, x: 33}
104
+ - {_id: 4, x: 32}
79
105
  -
80
106
  description: "FindOneAndReplace when no documents match returning the document before modification"
81
107
  operation:
82
108
  name: findOneAndReplace
83
109
  arguments:
84
- filter: {_id: 4}
85
- replacement: {x: 44}
110
+ filter: {_id: 5}
111
+ replacement: {x: 55}
86
112
  projection: {x: 1, _id: 0}
87
113
  sort: {x: 1}
88
114
 
@@ -93,13 +119,14 @@ tests:
93
119
  - {_id: 1, x: 11}
94
120
  - {_id: 2, x: 22}
95
121
  - {_id: 3, x: 33}
122
+ - {_id: 4, x: 'ping'}
96
123
  -
97
124
  description: "FindOneAndReplace when no documents match with upsert returning the document before modification"
98
125
  operation:
99
126
  name: findOneAndReplace
100
127
  arguments:
101
- filter: {_id: 4}
102
- replacement: {x: 44}
128
+ filter: {_id: 5}
129
+ replacement: {x: 55}
103
130
  projection: {x: 1, _id: 0}
104
131
  sort: {x: 1}
105
132
  upsert: true
@@ -111,14 +138,15 @@ tests:
111
138
  - {_id: 1, x: 11}
112
139
  - {_id: 2, x: 22}
113
140
  - {_id: 3, x: 33}
114
- - {_id: 4, x: 44}
141
+ - {_id: 4, x: 'ping'}
142
+ - {_id: 5, x: 55}
115
143
  -
116
144
  description: "FindOneAndReplace when no documents match returning the document after modification"
117
145
  operation:
118
146
  name: findOneAndReplace
119
147
  arguments:
120
- filter: {_id: 4}
121
- replacement: {x: 44}
148
+ filter: {_id: 5}
149
+ replacement: {x: 55}
122
150
  projection: {x: 1, _id: 0}
123
151
  returnDocument: After
124
152
  sort: {x: 1}
@@ -130,24 +158,25 @@ tests:
130
158
  - {_id: 1, x: 11}
131
159
  - {_id: 2, x: 22}
132
160
  - {_id: 3, x: 33}
161
+ - {_id: 4, x: 'ping'}
133
162
  -
134
163
  description: "FindOneAndReplace when no documents match with upsert returning the document after modification"
135
164
  operation:
136
165
  name: findOneAndReplace
137
166
  arguments:
138
- filter: {_id: 4}
139
- replacement: {x: 44}
167
+ filter: {_id: 5}
168
+ replacement: {x: 55}
140
169
  projection: {x: 1, _id: 0}
141
170
  returnDocument: After
142
171
  sort: {x: 1}
143
172
  upsert: true
144
173
 
145
174
  outcome:
146
- result: {x: 44}
175
+ result: {x: 55}
147
176
  collection:
148
177
  data:
149
178
  - {_id: 1, x: 11}
150
179
  - {_id: 2, x: 22}
151
180
  - {_id: 3, x: 33}
152
- - {_id: 4, x: 44}
153
-
181
+ - {_id: 4, x: 'ping'}
182
+ - {_id: 5, x: 55}
@@ -2,6 +2,8 @@ data:
2
2
  - {_id: 1, x: 11}
3
3
  - {_id: 2, x: 22}
4
4
  - {_id: 3, x: 33}
5
+ - {_id: 4, x: 'ping'}
6
+ - {_id: 5, x: 'pINg'}
5
7
 
6
8
  tests:
7
9
  -
@@ -9,9 +11,9 @@ tests:
9
11
  operation:
10
12
  name: findOneAndUpdate
11
13
  arguments:
12
- filter:
14
+ filter:
13
15
  _id: {$gt: 1}
14
- update:
16
+ update:
15
17
  $inc: {x: 1}
16
18
  projection: {x: 1, _id: 0}
17
19
  sort: {x: 1}
@@ -23,6 +25,32 @@ tests:
23
25
  - {_id: 1, x: 11}
24
26
  - {_id: 2, x: 23}
25
27
  - {_id: 3, x: 33}
28
+ - {_id: 4, x: 'ping'}
29
+ - {_id: 5, x: 'pINg'}
30
+
31
+ -
32
+ description: "FindOneAndUpdate when many documents match with collation returning the document before modification"
33
+ operation:
34
+ name: findOneAndUpdate
35
+ arguments:
36
+ filter:
37
+ x: 'PING'
38
+ update:
39
+ $set: {x: 'pong'}
40
+ projection: {x: 1, _id: 0}
41
+ sort: {_id: 1}
42
+ collation: { locale: 'en_US', strength: 2 }
43
+
44
+ outcome:
45
+ result: {x: 'ping'}
46
+ collection:
47
+ data:
48
+ - {_id: 1, x: 11}
49
+ - {_id: 2, x: 22}
50
+ - {_id: 3, x: 33}
51
+ - {_id: 4, x: 'pong'}
52
+ - {_id: 5, x: 'pINg'}
53
+
26
54
  -
27
55
  description: "FindOneAndUpdate when many documents match returning the document after modification"
28
56
  operation:
@@ -43,6 +71,8 @@ tests:
43
71
  - {_id: 1, x: 11}
44
72
  - {_id: 2, x: 23}
45
73
  - {_id: 3, x: 33}
74
+ - {_id: 4, x: 'ping'}
75
+ - {_id: 5, x: 'pINg'}
46
76
  -
47
77
  description: "FindOneAndUpdate when one document matches returning the document before modification"
48
78
  operation:
@@ -61,6 +91,8 @@ tests:
61
91
  - {_id: 1, x: 11}
62
92
  - {_id: 2, x: 23}
63
93
  - {_id: 3, x: 33}
94
+ - {_id: 4, x: 'ping'}
95
+ - {_id: 5, x: 'pINg'}
64
96
  -
65
97
  description: "FindOneAndUpdate when one document matches returning the document after modification"
66
98
  operation:
@@ -80,12 +112,14 @@ tests:
80
112
  - {_id: 1, x: 11}
81
113
  - {_id: 2, x: 23}
82
114
  - {_id: 3, x: 33}
115
+ - {_id: 4, x: 'ping'}
116
+ - {_id: 5, x: 'pINg'}
83
117
  -
84
118
  description: "FindOneAndUpdate when no documents match returning the document before modification"
85
119
  operation:
86
120
  name: findOneAndUpdate
87
121
  arguments:
88
- filter: {_id: 4}
122
+ filter: {_id: 6}
89
123
  update:
90
124
  $inc: {x: 1}
91
125
  projection: {x: 1, _id: 0}
@@ -98,12 +132,14 @@ tests:
98
132
  - {_id: 1, x: 11}
99
133
  - {_id: 2, x: 22}
100
134
  - {_id: 3, x: 33}
135
+ - {_id: 4, x: 'ping'}
136
+ - {_id: 5, x: 'pINg'}
101
137
  -
102
138
  description: "FindOneAndUpdate when no documents match with upsert returning the document before modification"
103
139
  operation:
104
140
  name: findOneAndUpdate
105
141
  arguments:
106
- filter: {_id: 4}
142
+ filter: {_id: 6}
107
143
  update:
108
144
  $inc: {x: 1}
109
145
  projection: {x: 1, _id: 0}
@@ -117,13 +153,15 @@ tests:
117
153
  - {_id: 1, x: 11}
118
154
  - {_id: 2, x: 22}
119
155
  - {_id: 3, x: 33}
120
- - {_id: 4, x: 1}
156
+ - {_id: 4, x: 'ping'}
157
+ - {_id: 5, x: 'pINg'}
158
+ - {_id: 6, x: 1}
121
159
  -
122
160
  description: "FindOneAndUpdate when no documents match returning the document after modification"
123
161
  operation:
124
162
  name: findOneAndUpdate
125
163
  arguments:
126
- filter: {_id: 4}
164
+ filter: {_id: 6}
127
165
  update:
128
166
  $inc: {x: 1}
129
167
  projection: {x: 1, _id: 0}
@@ -137,12 +175,14 @@ tests:
137
175
  - {_id: 1, x: 11}
138
176
  - {_id: 2, x: 22}
139
177
  - {_id: 3, x: 33}
178
+ - {_id: 4, x: 'ping'}
179
+ - {_id: 5, x: 'pINg'}
140
180
  -
141
181
  description: "FindOneAndUpdate when no documents match with upsert returning the document after modification"
142
182
  operation:
143
183
  name: findOneAndUpdate
144
184
  arguments:
145
- filter: {_id: 4}
185
+ filter: {_id: 6}
146
186
  update:
147
187
  $inc: {x: 1}
148
188
  projection: {x: 1, _id: 0}
@@ -157,5 +197,7 @@ tests:
157
197
  - {_id: 1, x: 11}
158
198
  - {_id: 2, x: 22}
159
199
  - {_id: 3, x: 33}
160
- - {_id: 4, x: 1}
200
+ - {_id: 4, x: 'ping'}
201
+ - {_id: 5, x: 'pINg'}
202
+ - {_id: 6, x: 1}
161
203
 
@@ -2,6 +2,7 @@ data:
2
2
  - {_id: 1, x: 11}
3
3
  - {_id: 2, x: 22}
4
4
  - {_id: 3, x: 33}
5
+ - {_id: 4, x: 'ping'}
5
6
 
6
7
  tests:
7
8
  -
@@ -9,7 +10,7 @@ tests:
9
10
  operation:
10
11
  name: "replaceOne"
11
12
  arguments:
12
- filter:
13
+ filter:
13
14
  _id: {$gt: 1}
14
15
  replacement: {x: 111}
15
16
 
@@ -36,13 +37,33 @@ tests:
36
37
  - {_id: 1, x: 111}
37
38
  - {_id: 2, x: 22}
38
39
  - {_id: 3, x: 33}
40
+ - {_id: 4, x: 'ping'}
41
+ -
42
+ description: "ReplaceOne when one document matches with collation"
43
+ operation:
44
+ name: "replaceOne"
45
+ arguments:
46
+ filter: {x: 'PING'}
47
+ replacement: {_id: 4, x: 'pong'}
48
+ collation: {locale: 'en_US', strength: 2}
49
+
50
+ outcome:
51
+ result:
52
+ matchedCount: 1
53
+ modifiedCount: 1
54
+ collection:
55
+ data:
56
+ - {_id: 1, x: 11}
57
+ - {_id: 2, x: 22}
58
+ - {_id: 3, x: 33}
59
+ - {_id: 4, x: 'pong'}
39
60
  -
40
61
  description: "ReplaceOne when no documents match"
41
62
  operation:
42
63
  name: "replaceOne"
43
64
  arguments:
44
- filter: {_id: 4}
45
- replacement: {_id: 4, x: 1}
65
+ filter: {_id: 5}
66
+ replacement: {_id: 5, x: 1}
46
67
 
47
68
  outcome:
48
69
  result:
@@ -53,12 +74,13 @@ tests:
53
74
  - {_id: 1, x: 11}
54
75
  - {_id: 2, x: 22}
55
76
  - {_id: 3, x: 33}
77
+ - {_id: 4, x: 'ping'}
56
78
  -
57
79
  description: "ReplaceOne with upsert when no documents match without an id specified"
58
80
  operation:
59
81
  name: "replaceOne"
60
82
  arguments:
61
- filter: {_id: 4}
83
+ filter: {_id: 5}
62
84
  replacement: {x: 1}
63
85
  upsert: true
64
86
 
@@ -66,31 +88,33 @@ tests:
66
88
  result:
67
89
  matchedCount: 0
68
90
  modifiedCount: 0
69
- upsertedId: 4
91
+ upsertedId: 5
70
92
  collection:
71
93
  data:
72
94
  - {_id: 1, x: 11}
73
95
  - {_id: 2, x: 22}
74
96
  - {_id: 3, x: 33}
75
- - {_id: 4, x: 1}
97
+ - {_id: 4, x: 'ping'}
98
+ - {_id: 5, x: 1}
76
99
  -
77
100
  description: "ReplaceOne with upsert when no documents match with an id specified"
78
101
  operation:
79
102
  name: "replaceOne"
80
103
  arguments:
81
- filter: {_id: 4}
82
- replacement: {_id: 4, x: 1}
104
+ filter: {_id: 5}
105
+ replacement: {_id: 5, x: 1}
83
106
  upsert: true
84
107
 
85
108
  outcome:
86
109
  result:
87
110
  matchedCount: 0
88
111
  modifiedCount: 0
89
- upsertedId: 4
112
+ upsertedId: 5
90
113
  collection:
91
114
  data:
92
115
  - {_id: 1, x: 11}
93
116
  - {_id: 2, x: 22}
94
117
  - {_id: 3, x: 33}
95
- - {_id: 4, x: 1}
118
+ - {_id: 4, x: 'ping'}
119
+ - {_id: 5, x: 1}
96
120