mongo 2.5.1 → 2.5.2

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.
Files changed (275) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +3 -2
  3. data.tar.gz.sig +0 -0
  4. data/Rakefile +1 -1
  5. data/lib/mongo/auth/user/view.rb +4 -4
  6. data/lib/mongo/bulk_write.rb +14 -19
  7. data/lib/mongo/cluster.rb +4 -2
  8. data/lib/mongo/cluster/app_metadata.rb +1 -1
  9. data/lib/mongo/cluster/reapers/cursor_reaper.rb +1 -1
  10. data/lib/mongo/collection.rb +13 -13
  11. data/lib/mongo/collection/view.rb +2 -1
  12. data/lib/mongo/collection/view/aggregation.rb +1 -1
  13. data/lib/mongo/collection/view/change_stream.rb +1 -1
  14. data/lib/mongo/collection/view/iterable.rb +4 -4
  15. data/lib/mongo/collection/view/map_reduce.rb +3 -3
  16. data/lib/mongo/collection/view/readable.rb +26 -20
  17. data/lib/mongo/collection/view/writable.rb +12 -12
  18. data/lib/mongo/cursor.rb +4 -7
  19. data/lib/mongo/database.rb +2 -2
  20. data/lib/mongo/database/view.rb +1 -1
  21. data/lib/mongo/grid/stream/write.rb +1 -1
  22. data/lib/mongo/index/view.rb +3 -3
  23. data/lib/mongo/operation.rb +38 -24
  24. data/lib/mongo/operation/aggregate.rb +53 -0
  25. data/lib/mongo/operation/aggregate/command.rb +59 -0
  26. data/lib/mongo/operation/aggregate/op_msg.rb +54 -0
  27. data/lib/mongo/operation/aggregate/result.rb +87 -0
  28. data/lib/mongo/operation/collections_info.rb +62 -0
  29. data/lib/mongo/operation/collections_info/result.rb +39 -0
  30. data/lib/mongo/operation/{executable.rb → command.rb} +16 -13
  31. data/lib/mongo/operation/command/command.rb +38 -0
  32. data/lib/mongo/operation/command/op_msg.rb +53 -0
  33. data/lib/mongo/operation/count.rb +48 -0
  34. data/lib/mongo/operation/count/command.rb +38 -0
  35. data/lib/mongo/operation/count/op_msg.rb +38 -0
  36. data/lib/mongo/operation/create.rb +48 -0
  37. data/lib/mongo/operation/create/command.rb +38 -0
  38. data/lib/mongo/operation/create/op_msg.rb +37 -0
  39. data/lib/mongo/operation/create_index.rb +48 -0
  40. data/lib/mongo/operation/create_index/command.rb +42 -0
  41. data/lib/mongo/operation/create_index/op_msg.rb +41 -0
  42. data/lib/mongo/operation/create_user.rb +48 -0
  43. data/lib/mongo/operation/{commands → create_user}/command.rb +13 -19
  44. data/lib/mongo/operation/create_user/op_msg.rb +41 -0
  45. data/lib/mongo/operation/delete.rb +38 -0
  46. data/lib/mongo/operation/delete/bulk_result.rb +46 -0
  47. data/lib/mongo/operation/delete/command.rb +59 -0
  48. data/lib/mongo/operation/delete/legacy.rb +69 -0
  49. data/lib/mongo/operation/delete/op_msg.rb +60 -0
  50. data/lib/mongo/operation/{write/delete → delete}/result.rb +18 -16
  51. data/lib/mongo/operation/distinct.rb +48 -0
  52. data/lib/mongo/operation/distinct/command.rb +38 -0
  53. data/lib/mongo/operation/distinct/op_msg.rb +38 -0
  54. data/lib/mongo/operation/drop.rb +48 -0
  55. data/lib/mongo/operation/drop/command.rb +38 -0
  56. data/lib/mongo/operation/{commands/count.rb → drop/op_msg.rb} +16 -6
  57. data/lib/mongo/operation/drop_database.rb +48 -0
  58. data/lib/mongo/operation/drop_database/command.rb +38 -0
  59. data/lib/mongo/operation/drop_database/op_msg.rb +37 -0
  60. data/lib/mongo/operation/drop_index.rb +48 -0
  61. data/lib/mongo/operation/drop_index/command.rb +42 -0
  62. data/lib/mongo/operation/{limited.rb → drop_index/op_msg.rb} +19 -15
  63. data/lib/mongo/operation/explain.rb +52 -0
  64. data/lib/mongo/operation/explain/command.rb +54 -0
  65. data/lib/mongo/operation/explain/legacy.rb +53 -0
  66. data/lib/mongo/operation/explain/op_msg.rb +54 -0
  67. data/lib/mongo/operation/explain/result.rb +50 -0
  68. data/lib/mongo/operation/find.rb +52 -0
  69. data/lib/mongo/operation/find/command.rb +54 -0
  70. data/lib/mongo/operation/find/legacy.rb +55 -0
  71. data/lib/mongo/operation/{read/query → find/legacy}/result.rb +3 -3
  72. data/lib/mongo/operation/find/op_msg.rb +59 -0
  73. data/lib/mongo/operation/find/result.rb +60 -0
  74. data/lib/mongo/operation/{commands/users_info/result.rb → get_more.rb} +20 -22
  75. data/lib/mongo/operation/get_more/command.rb +54 -0
  76. data/lib/mongo/operation/{commands/find.rb → get_more/legacy.rb} +15 -8
  77. data/lib/mongo/operation/get_more/op_msg.rb +58 -0
  78. data/lib/mongo/operation/get_more/result.rb +60 -0
  79. data/lib/mongo/operation/indexes.rb +52 -0
  80. data/lib/mongo/operation/indexes/command.rb +54 -0
  81. data/lib/mongo/operation/indexes/legacy.rb +57 -0
  82. data/lib/mongo/operation/indexes/op_msg.rb +54 -0
  83. data/lib/mongo/operation/indexes/result.rb +97 -0
  84. data/lib/mongo/operation/insert.rb +40 -0
  85. data/lib/mongo/operation/insert/bulk_result.rb +70 -0
  86. data/lib/mongo/operation/insert/command.rb +65 -0
  87. data/lib/mongo/operation/insert/legacy.rb +72 -0
  88. data/lib/mongo/operation/insert/op_msg.rb +61 -0
  89. data/lib/mongo/operation/insert/result.rb +64 -0
  90. data/lib/mongo/operation/kill_cursors.rb +25 -14
  91. data/lib/mongo/operation/{takes_write_concern.rb → kill_cursors/command.rb} +14 -12
  92. data/lib/mongo/operation/kill_cursors/legacy.rb +37 -0
  93. data/lib/mongo/operation/kill_cursors/op_msg.rb +37 -0
  94. data/lib/mongo/operation/list_collections.rb +49 -0
  95. data/lib/mongo/operation/list_collections/command.rb +60 -0
  96. data/lib/mongo/operation/list_collections/op_msg.rb +53 -0
  97. data/lib/mongo/operation/list_collections/result.rb +92 -0
  98. data/lib/mongo/operation/map_reduce.rb +49 -0
  99. data/lib/mongo/operation/map_reduce/command.rb +55 -0
  100. data/lib/mongo/operation/map_reduce/op_msg.rb +54 -0
  101. data/lib/mongo/operation/map_reduce/result.rb +129 -0
  102. data/lib/mongo/operation/parallel_scan.rb +49 -0
  103. data/lib/mongo/operation/parallel_scan/command.rb +67 -0
  104. data/lib/mongo/operation/parallel_scan/op_msg.rb +61 -0
  105. data/lib/mongo/operation/parallel_scan/result.rb +61 -0
  106. data/lib/mongo/operation/remove_user.rb +48 -0
  107. data/lib/mongo/operation/remove_user/command.rb +42 -0
  108. data/lib/mongo/operation/remove_user/op_msg.rb +41 -0
  109. data/lib/mongo/operation/result.rb +3 -1
  110. data/lib/mongo/operation/shared/bypass_document_validation.rb +36 -0
  111. data/lib/mongo/operation/{causally_consistent.rb → shared/causal_consistency_supported.rb} +5 -5
  112. data/lib/mongo/operation/shared/executable.rb +45 -0
  113. data/lib/mongo/operation/shared/idable.rb +64 -0
  114. data/lib/mongo/operation/{commands/distinct.rb → shared/limited.rb} +10 -7
  115. data/lib/mongo/operation/{object_id_generator.rb → shared/object_id_generator.rb} +2 -2
  116. data/lib/mongo/operation/{read_preference.rb → shared/read_preference_supported.rb} +14 -24
  117. data/lib/mongo/operation/shared/result/aggregatable.rb +75 -0
  118. data/lib/mongo/operation/shared/sessions_supported.rb +79 -0
  119. data/lib/mongo/operation/{specifiable.rb → shared/specifiable.rb} +40 -4
  120. data/lib/mongo/operation/shared/write.rb +81 -0
  121. data/lib/mongo/operation/shared/write_concern_supported.rb +39 -0
  122. data/lib/mongo/operation/update.rb +38 -0
  123. data/lib/mongo/operation/update/bulk_result.rb +126 -0
  124. data/lib/mongo/operation/update/command.rb +60 -0
  125. data/lib/mongo/operation/update/legacy.rb +80 -0
  126. data/lib/mongo/operation/{write/update → update/legacy}/result.rb +4 -82
  127. data/lib/mongo/operation/update/op_msg.rb +60 -0
  128. data/lib/mongo/operation/update/result.rb +102 -0
  129. data/lib/mongo/operation/update_user.rb +48 -0
  130. data/lib/mongo/operation/update_user/command.rb +41 -0
  131. data/lib/mongo/operation/update_user/op_msg.rb +41 -0
  132. data/lib/mongo/operation/users_info.rb +49 -0
  133. data/lib/mongo/operation/users_info/command.rb +58 -0
  134. data/lib/mongo/operation/users_info/op_msg.rb +57 -0
  135. data/lib/mongo/operation/{commands/collections_info → users_info}/result.rb +18 -17
  136. data/lib/mongo/server.rb +3 -5
  137. data/lib/mongo/server/connectable.rb +3 -3
  138. data/lib/mongo/server/connection.rb +14 -0
  139. data/lib/mongo/server_selector.rb +1 -1
  140. data/lib/mongo/server_selector/selectable.rb +3 -12
  141. data/lib/mongo/session.rb +13 -1
  142. data/lib/mongo/session/session_pool.rb +1 -1
  143. data/lib/mongo/version.rb +1 -1
  144. data/spec/mongo/client_spec.rb +15 -22
  145. data/spec/mongo/cluster/app_metadata_spec.rb +19 -3
  146. data/spec/mongo/cluster/cursor_reaper_spec.rb +37 -0
  147. data/spec/mongo/cluster_spec.rb +2 -2
  148. data/spec/mongo/collection/view/change_stream_spec.rb +2 -2
  149. data/spec/mongo/collection_spec.rb +105 -14
  150. data/spec/mongo/cursor_spec.rb +11 -11
  151. data/spec/mongo/grid/fs_bucket_spec.rb +5 -0
  152. data/spec/mongo/max_staleness_spec.rb +3 -1
  153. data/spec/mongo/operation/{commands/aggregate → aggregate}/result_spec.rb +1 -1
  154. data/spec/mongo/operation/{commands/aggregate_spec.rb → aggregate_spec.rb} +1 -1
  155. data/spec/mongo/operation/{commands/collections_info_spec.rb → collections_info_spec.rb} +4 -2
  156. data/spec/mongo/operation/{commands/command_spec.rb → command_spec.rb} +1 -1
  157. data/spec/mongo/operation/{write/command/create_index_spec.rb → create_index_spec.rb} +1 -1
  158. data/spec/mongo/operation/{write/create_user_spec.rb → create_user_spec.rb} +1 -1
  159. data/spec/mongo/operation/{write/bulk/delete_spec.rb → delete/bulk_spec.rb} +8 -8
  160. data/spec/mongo/operation/delete/command_spec.rb +111 -0
  161. data/spec/mongo/operation/{write/command/delete_spec.rb → delete/op_msg_spec.rb} +40 -34
  162. data/spec/mongo/operation/{write/delete_spec.rb → delete_spec.rb} +7 -7
  163. data/spec/mongo/operation/{write/command/drop_index_spec.rb → drop_index_spec.rb} +1 -1
  164. data/spec/mongo/operation/{read/query_spec.rb → find/legacy_spec.rb} +2 -2
  165. data/spec/mongo/operation/{read/get_more_spec.rb → get_more_spec.rb} +3 -3
  166. data/spec/mongo/operation/{commands/indexes_spec.rb → indexes_spec.rb} +6 -4
  167. data/spec/mongo/operation/{write/bulk/insert_spec.rb → insert/bulk_spec.rb} +9 -9
  168. data/spec/mongo/operation/insert/command_spec.rb +110 -0
  169. data/spec/mongo/operation/{write/command/insert_spec.rb → insert/op_msg_spec.rb} +51 -41
  170. data/spec/mongo/operation/{write/insert_spec.rb → insert_spec.rb} +2 -2
  171. data/spec/mongo/operation/kill_cursors_spec.rb +2 -2
  172. data/spec/mongo/operation/limited_spec.rb +3 -3
  173. data/spec/mongo/operation/{commands/map_reduce_spec.rb → map_reduce_spec.rb} +1 -1
  174. data/spec/mongo/operation/read_preference_spec.rb +2 -2
  175. data/spec/mongo/operation/{write/command/remove_user_spec.rb → remove_user_spec.rb} +1 -1
  176. data/spec/mongo/operation/{write/bulk/update_spec.rb → update/bulk_spec.rb} +8 -8
  177. data/spec/mongo/operation/update/command_spec.rb +114 -0
  178. data/spec/mongo/operation/{write/command/update_spec.rb → update/op_msg_spec.rb} +49 -40
  179. data/spec/mongo/operation/{write/update_spec.rb → update_spec.rb} +6 -6
  180. data/spec/mongo/operation/{write/command/update_user_spec.rb → update_user_spec.rb} +1 -1
  181. data/spec/mongo/server/connection_spec.rb +0 -22
  182. data/spec/mongo/server_selector_spec.rb +55 -0
  183. data/spec/mongo/server_spec.rb +0 -42
  184. data/spec/mongo/session/session_pool_spec.rb +1 -1
  185. data/spec/mongo/uri/srv_protocol_spec.rb +2 -2
  186. data/spec/mongo/uri_spec.rb +2 -2
  187. data/spec/support/gridfs_tests/delete.yml +4 -38
  188. data/spec/support/gridfs_tests/download.yml +12 -30
  189. data/spec/support/server_selection.rb +1 -1
  190. data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Nearest.yml +0 -1
  191. data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Nearest_multiple.yml +0 -1
  192. data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Nearest_non_matching.yml +0 -1
  193. data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/PossiblePrimary.yml +15 -0
  194. data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/PossiblePrimaryNearest.yml +15 -0
  195. data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Primary.yml +0 -3
  196. data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/PrimaryPreferred.yml +0 -1
  197. data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/PrimaryPreferred_non_matching.yml +0 -1
  198. data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Secondary.yml +0 -1
  199. data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/SecondaryPreferred.yml +0 -1
  200. data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/SecondaryPreferred_non_matching.yml +0 -1
  201. data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Secondary_non_matching.yml +0 -1
  202. data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Nearest.yml +0 -1
  203. data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Nearest_multiple.yml +0 -1
  204. data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Nearest_non_matching.yml +0 -1
  205. data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Primary.yml +0 -3
  206. data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/PrimaryPreferred.yml +0 -1
  207. data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/PrimaryPreferred_non_matching.yml +0 -1
  208. data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Secondary.yml +0 -1
  209. data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/SecondaryPreferred.yml +0 -1
  210. data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/SecondaryPreferred_non_matching.yml +0 -1
  211. data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Secondary_non_matching.yml +0 -1
  212. data/spec/support/server_selection/selection/Sharded/read/Nearest.yml +21 -0
  213. data/spec/support/server_selection/selection/Sharded/read/Primary.yml +19 -0
  214. data/spec/support/server_selection/selection/Sharded/read/PrimaryPreferred.yml +21 -0
  215. data/spec/support/server_selection/selection/Sharded/read/Secondary.yml +21 -0
  216. data/spec/support/server_selection/selection/Sharded/read/SecondaryPreferred.yml +0 -5
  217. data/spec/support/server_selection/selection/Single/read/SecondaryPreferred.yml +0 -1
  218. data/spec/support/server_selection/selection/Unknown/read/SecondaryPreferred.yml +0 -1
  219. data/spec/support/shared/session.rb +46 -5
  220. metadata +174 -116
  221. metadata.gz.sig +1 -2
  222. data/lib/mongo/operation/commands.rb +0 -31
  223. data/lib/mongo/operation/commands/aggregate.rb +0 -63
  224. data/lib/mongo/operation/commands/aggregate/result.rb +0 -89
  225. data/lib/mongo/operation/commands/collections_info.rb +0 -71
  226. data/lib/mongo/operation/commands/create.rb +0 -49
  227. data/lib/mongo/operation/commands/drop.rb +0 -49
  228. data/lib/mongo/operation/commands/drop_database.rb +0 -49
  229. data/lib/mongo/operation/commands/explain.rb +0 -27
  230. data/lib/mongo/operation/commands/explain/result.rb +0 -52
  231. data/lib/mongo/operation/commands/find/result.rb +0 -62
  232. data/lib/mongo/operation/commands/get_more.rb +0 -27
  233. data/lib/mongo/operation/commands/get_more/result.rb +0 -62
  234. data/lib/mongo/operation/commands/indexes.rb +0 -73
  235. data/lib/mongo/operation/commands/list_collections.rb +0 -48
  236. data/lib/mongo/operation/commands/list_collections/result.rb +0 -94
  237. data/lib/mongo/operation/commands/list_indexes.rb +0 -48
  238. data/lib/mongo/operation/commands/list_indexes/result.rb +0 -98
  239. data/lib/mongo/operation/commands/map_reduce.rb +0 -65
  240. data/lib/mongo/operation/commands/map_reduce/result.rb +0 -131
  241. data/lib/mongo/operation/commands/parallel_scan.rb +0 -54
  242. data/lib/mongo/operation/commands/parallel_scan/result.rb +0 -64
  243. data/lib/mongo/operation/commands/users_info.rb +0 -52
  244. data/lib/mongo/operation/read.rb +0 -16
  245. data/lib/mongo/operation/read/get_more.rb +0 -52
  246. data/lib/mongo/operation/read/query.rb +0 -55
  247. data/lib/mongo/operation/uses_command_op_msg.rb +0 -78
  248. data/lib/mongo/operation/write.rb +0 -22
  249. data/lib/mongo/operation/write/bulk.rb +0 -20
  250. data/lib/mongo/operation/write/bulk/bulkable.rb +0 -82
  251. data/lib/mongo/operation/write/bulk/delete.rb +0 -71
  252. data/lib/mongo/operation/write/bulk/delete/result.rb +0 -71
  253. data/lib/mongo/operation/write/bulk/insert.rb +0 -96
  254. data/lib/mongo/operation/write/bulk/insert/result.rb +0 -129
  255. data/lib/mongo/operation/write/bulk/legacy_mergable.rb +0 -87
  256. data/lib/mongo/operation/write/bulk/mergable.rb +0 -73
  257. data/lib/mongo/operation/write/bulk/update.rb +0 -81
  258. data/lib/mongo/operation/write/bulk/update/result.rb +0 -196
  259. data/lib/mongo/operation/write/command.rb +0 -23
  260. data/lib/mongo/operation/write/command/create_index.rb +0 -79
  261. data/lib/mongo/operation/write/command/create_user.rb +0 -61
  262. data/lib/mongo/operation/write/command/delete.rb +0 -79
  263. data/lib/mongo/operation/write/command/drop_index.rb +0 -80
  264. data/lib/mongo/operation/write/command/insert.rb +0 -69
  265. data/lib/mongo/operation/write/command/remove_user.rb +0 -60
  266. data/lib/mongo/operation/write/command/update.rb +0 -77
  267. data/lib/mongo/operation/write/command/update_user.rb +0 -61
  268. data/lib/mongo/operation/write/command/writable.rb +0 -70
  269. data/lib/mongo/operation/write/delete.rb +0 -75
  270. data/lib/mongo/operation/write/gle.rb +0 -49
  271. data/lib/mongo/operation/write/idable.rb +0 -63
  272. data/lib/mongo/operation/write/insert.rb +0 -74
  273. data/lib/mongo/operation/write/insert/result.rb +0 -62
  274. data/lib/mongo/operation/write/update.rb +0 -91
  275. data/lib/mongo/operation/write/write_command_enabled.rb +0 -77
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22155206427257fef9e634311719afb58b03f76c
4
- data.tar.gz: c156ef4a3569277ad0c398455d7983c3e2475051
3
+ metadata.gz: 0246e6a64d501929f4951018f1a8d9ca820279c3
4
+ data.tar.gz: e417f701dd239a033bff8b40d15e37f8adf2718f
5
5
  SHA512:
6
- metadata.gz: 4252e5a66f31ee3ba496bd573b37ee08f0dd513b3d1e1b154da01c7d34dc19714fc929de7454cc4ea0415fbb44312a8b1c29cf06c1cfb20adee72e97cd917443
7
- data.tar.gz: efb7c93290353223cfc910a383b0a0edd9f2d0cc3b6405389256f48fe1dd1ed3647449db8d07663300303ba07a25a038f46d4c2ee5b1bdc0e804890e73b698b6
6
+ metadata.gz: '07684a4b81cc5b65e3dff16e1ce48542d165558683c82987a2e21d305434f2b4849688f3f2dad855b7034bfbd9ecb04ff0ce7a5f8572beead07bc0d87db621b8'
7
+ data.tar.gz: db337b9d0dae7d8ffc41833a770a0a4edd80d847440b05ff6c5d99c66c677624baaae948187443b0ab43195dc9904772e8f6334940ae7a20786c03ed3b956dbf
@@ -1,2 +1,3 @@
1
- Bl5������ b{�B��Rg ��̢�%r��ϸ�,�fmŮD���|��mEy5�wa1r�k4x
2
- 4�~I g�;dD��w(��/Cj[�� "t�Ӧ0H0u�����tBeN{x��"��M �jǬ����w}�!��ee��C{W��9���|d�;�=W������*�5q2�b��d�̞a��1ػ��Y��-��+���$7Z��Ͼ��s��@��kC�d�#�C[�o&P� �
1
+ F��Y� �Լ����� ��� ����4
2
+ V7��#��#�|��N�~!G��Hw5S��Q#k8+��l��!S.̌�z�Ԙ=o5�;Gb���o����Zy ����;�dyV�o��mn�"�����
3
+ K�;���K�K�i��Y��w�B��m�� !"�IM/i<�!�a_�5�K3UW $�x���_��$��7�e>��W��l w����k���Jk�ʤaB2��Vl
data.tar.gz.sig CHANGED
Binary file
data/Rakefile CHANGED
@@ -16,7 +16,7 @@ Bundler.require(*default_groups)
16
16
  require 'rspec/core/rake_task'
17
17
 
18
18
  RSpec::Core::RakeTask.new(:spec) do |t|
19
- t.rspec_opts = "--profile 5" if ENV['CI']
19
+ #t.rspec_opts = "--profile 5" if ENV['CI']
20
20
  end
21
21
 
22
22
  task :default => :spec
@@ -44,7 +44,7 @@ module Mongo
44
44
  def create(user_or_name, options = {})
45
45
  user = generate(user_or_name, options)
46
46
  client.send(:with_session, options) do |session|
47
- Operation::Write::Command::CreateUser.new(
47
+ Operation::CreateUser.new(
48
48
  user: user,
49
49
  db_name: database.name,
50
50
  session: session
@@ -79,7 +79,7 @@ module Mongo
79
79
  # @since 2.0.0
80
80
  def remove(name, options = {})
81
81
  client.send(:with_session, options) do |session|
82
- Operation::Write::Command::RemoveUser.new(
82
+ Operation::RemoveUser.new(
83
83
  user_name: name,
84
84
  db_name: database.name,
85
85
  session: session
@@ -103,7 +103,7 @@ module Mongo
103
103
  def update(user_or_name, options = {})
104
104
  client.send(:with_session, options) do |session|
105
105
  user = generate(user_or_name, options)
106
- Operation::Write::Command::UpdateUser.new(
106
+ Operation::UpdateUser.new(
107
107
  user: user,
108
108
  db_name: database.name,
109
109
  session: session
@@ -132,7 +132,7 @@ module Mongo
132
132
 
133
133
  def user_query(name, options = {})
134
134
  client.send(:with_session, options) do |session|
135
- Operation::Commands::UsersInfo.new(
135
+ Operation::UsersInfo.new(
136
136
  user_name: name,
137
137
  db_name: database.name,
138
138
  session: session
@@ -61,7 +61,7 @@ module Mongo
61
61
  write_with_retry(session, write_concern) do |server, txn_num|
62
62
  execute_operation(
63
63
  operation.keys.first,
64
- operation.values.first,
64
+ operation.values.flatten,
65
65
  server,
66
66
  operation_id,
67
67
  result_combiner,
@@ -72,7 +72,7 @@ module Mongo
72
72
  legacy_write_with_retry do |server|
73
73
  execute_operation(
74
74
  operation.keys.first,
75
- operation.values.first,
75
+ operation.values.flatten,
76
76
  server,
77
77
  operation_id,
78
78
  result_combiner,
@@ -175,7 +175,8 @@ module Mongo
175
175
  if values.size > server.max_write_batch_size
176
176
  split_execute(name, values, server, operation_id, combiner, session, txn_num)
177
177
  else
178
- combiner.combine!(send(name, values, server, operation_id, session, txn_num), values.size)
178
+ result = send(name, values, server, operation_id, session, txn_num)
179
+ combiner.combine!(result, values.size)
179
180
  end
180
181
  rescue Error::MaxBSONSize, Error::MaxMessageSize => e
181
182
  raise e if values.size <= 1
@@ -195,35 +196,29 @@ module Mongo
195
196
  end
196
197
 
197
198
  def delete_one(documents, server, operation_id, session, txn_num)
198
- Operation::Write::Bulk::Delete.new(
199
- base_spec(operation_id, session).merge(:deletes => documents, :txn_num => txn_num)
200
- ).execute(server)
199
+ spec = base_spec(operation_id, session).merge(:deletes => documents, :txn_num => txn_num)
200
+ Operation::Delete.new(spec).bulk_execute(server)
201
201
  end
202
202
 
203
203
  def delete_many(documents, server, operation_id, session, txn_num)
204
- Operation::Write::Bulk::Delete.new(
205
- base_spec(operation_id, session).merge(:deletes => documents)
206
- ).execute(server)
204
+ spec = base_spec(operation_id, session).merge(:deletes => documents)
205
+ Operation::Delete.new(spec).bulk_execute(server)
207
206
  end
208
207
 
209
-
210
208
  def insert_one(documents, server, operation_id, session, txn_num)
211
- Operation::Write::Bulk::Insert.new(
212
- base_spec(operation_id, session).merge(:documents => documents, :txn_num => txn_num)
213
- ).execute(server)
209
+ spec = base_spec(operation_id, session).merge(:documents => documents, :txn_num => txn_num)
210
+ Operation::Insert.new(spec).bulk_execute(server)
214
211
  end
215
212
 
216
213
  def update_one(documents, server, operation_id, session, txn_num)
217
- Operation::Write::Bulk::Update.new(
218
- base_spec(operation_id, session).merge(:updates => documents, :txn_num => txn_num)
219
- ).execute(server)
214
+ spec = base_spec(operation_id, session).merge(:updates => documents, :txn_num => txn_num)
215
+ Operation::Update.new(spec).bulk_execute(server)
220
216
  end
221
217
  alias :replace_one :update_one
222
218
 
223
219
  def update_many(documents, server, operation_id, session, txn_num)
224
- Operation::Write::Bulk::Update.new(
225
- base_spec(operation_id, session).merge(:updates => documents)
226
- ).execute(server)
220
+ spec = base_spec(operation_id, session).merge(:updates => documents)
221
+ Operation::Update.new(spec).bulk_execute(server)
227
222
  end
228
223
  end
229
224
  end
@@ -244,14 +244,16 @@ module Mongo
244
244
  # @example Get the next primary server.
245
245
  # cluster.next_primary
246
246
  #
247
- # @param [ true, false ] ping Whether to ping the server before selection.
247
+ # @param [ true, false ] ping Whether to ping the server before selection. Deprecated,
248
+ # not necessary with the implementation of the Server Selection specification.
249
+ #
248
250
  #
249
251
  # @return [ Mongo::Server ] A primary server.
250
252
  #
251
253
  # @since 2.0.0
252
254
  def next_primary(ping = true)
253
255
  @primary_selector ||= ServerSelector.get(ServerSelector::PRIMARY)
254
- @primary_selector.select_server(self, ping)
256
+ @primary_selector.select_server(self)
255
257
  end
256
258
 
257
259
  # Elect a primary server from the description that has just changed to a
@@ -52,7 +52,7 @@ module Mongo
52
52
  #
53
53
  # @since 2.4.0
54
54
  def initialize(cluster)
55
- @app_name = cluster.options[:app_name]
55
+ @app_name = cluster.options[:app_name].to_s if cluster.options[:app_name]
56
56
  @platform = cluster.options[:platform]
57
57
  @compressors = cluster.options[:compressors] || []
58
58
  end
@@ -124,7 +124,7 @@ module Mongo
124
124
  if server.features.find_command_enabled?
125
125
  Cursor::Builder::KillCursorsCommand.update_cursors(op_spec, active_cursors_copy.to_a)
126
126
  if Cursor::Builder::KillCursorsCommand.get_cursors_list(op_spec).size > 0
127
- Operation::Commands::Command.new(op_spec).execute(server)
127
+ Operation::KillCursors.new(op_spec).execute(server)
128
128
  end
129
129
  else
130
130
  Cursor::Builder::OpKillCursors.update_cursors(op_spec, active_cursors_copy.to_a)
@@ -189,12 +189,12 @@ module Mongo
189
189
  raise Error::UnsupportedCollation.new
190
190
  end
191
191
  client.send(:with_session, opts) do |session|
192
- Operation::Commands::Create.new({
193
- selector: operation,
194
- db_name: database.name,
195
- write_concern: write_concern,
196
- session: session
197
- }).execute(server)
192
+ Operation::Create.new({
193
+ selector: operation,
194
+ db_name: database.name,
195
+ write_concern: write_concern,
196
+ session: session
197
+ }).execute(server)
198
198
  end
199
199
  end
200
200
 
@@ -215,12 +215,12 @@ module Mongo
215
215
  # @since 2.0.0
216
216
  def drop(opts = {})
217
217
  client.send(:with_session, opts) do |session|
218
- Operation::Commands::Drop.new({
219
- selector: { :drop => name },
220
- db_name: database.name,
221
- write_concern: write_concern,
222
- session: session
223
- }).execute(next_primary)
218
+ Operation::Drop.new({
219
+ selector: { :drop => name },
220
+ db_name: database.name,
221
+ write_concern: write_concern,
222
+ session: session
223
+ }).execute(next_primary)
224
224
  end
225
225
  rescue Error::OperationFailure => ex
226
226
  raise ex unless ex.message =~ /ns not found/
@@ -420,7 +420,7 @@ module Mongo
420
420
  def insert_one(document, opts = {})
421
421
  client.send(:with_session, opts) do |session|
422
422
  write_with_retry(session, write_concern) do |server, txn_num|
423
- Operation::Write::Insert.new(
423
+ Operation::Insert.new(
424
424
  :documents => [ document ],
425
425
  :db_name => database.name,
426
426
  :coll_name => name,
@@ -122,13 +122,14 @@ module Mongo
122
122
  # @option options :limit [ Integer ] Max number of docs to return.
123
123
  # @option options :max_scan [ Integer ] Constrain the query to only scan the
124
124
  # specified number of docs. Use to prevent queries from running too long.
125
+ # Deprecated as of MongoDB server version 4.0.
125
126
  # @option options :read [ Symbol ] The read preference to use for the query.
126
127
  # If none is provided, the collection's default read preference is used.
127
128
  # @option options :show_disk_loc [ true, false ] Return disk location info as
128
129
  # a field in each doc.
129
130
  # @option options :skip [ Integer ] The number of documents to skip.
130
131
  # @option options :snapshot [ true, false ] Prevents returning a doc more than
131
- # once.
132
+ # once. Deprecated as of MongoDB server version 4.0.
132
133
  # @option options :sort [ Hash ] The key and direction pairs used to sort the
133
134
  # results.
134
135
  # @option options [ Hash ] :collation The collation to use.
@@ -103,7 +103,7 @@ module Mongo
103
103
  end
104
104
 
105
105
  def initial_query_op(session)
106
- Operation::Commands::Aggregate.new(aggregate_spec(session))
106
+ Operation::Aggregate.new(aggregate_spec(session))
107
107
  end
108
108
 
109
109
  def valid_server?(server)
@@ -153,7 +153,7 @@ module Mongo
153
153
 
154
154
  def create_cursor!
155
155
  session = client.send(:get_session, @options)
156
- server = server_selector.select_server(cluster, false)
156
+ server = server_selector.select_server(cluster)
157
157
  result = send_initial_query(server, session)
158
158
  @cursor = Cursor.new(view, result, server, disable_retry: true, session: session)
159
159
  end
@@ -38,7 +38,7 @@ module Mongo
38
38
  @cursor = nil
39
39
  session = client.send(:get_session, @options)
40
40
  read_with_retry do
41
- server = server_selector.select_server(cluster, false)
41
+ server = server_selector.select_server(cluster)
42
42
  result = send_initial_query(server, session)
43
43
  @cursor = Cursor.new(view, result, server, session: session)
44
44
  end
@@ -65,15 +65,15 @@ module Mongo
65
65
  if server.features.find_command_enabled?
66
66
  initial_command_op(session)
67
67
  else
68
- Operation::Read::Query.new(Builder::OpQuery.new(self).specification)
68
+ Operation::Find.new(Builder::OpQuery.new(self).specification)
69
69
  end
70
70
  end
71
71
 
72
72
  def initial_command_op(session)
73
73
  if explained?
74
- Operation::Commands::Explain.new(Builder::FindCommand.new(self, session).explain_specification)
74
+ Operation::Explain.new(Builder::FindCommand.new(self, session).explain_specification)
75
75
  else
76
- Operation::Commands::Find.new(Builder::FindCommand.new(self, session).specification)
76
+ Operation::Find.new(Builder::FindCommand.new(self, session).specification)
77
77
  end
78
78
  end
79
79
 
@@ -217,7 +217,7 @@ module Mongo
217
217
  end
218
218
 
219
219
  def initial_query_op(session)
220
- Operation::Commands::MapReduce.new(map_reduce_spec(session))
220
+ Operation::MapReduce.new(map_reduce_spec(session))
221
221
  end
222
222
 
223
223
  def valid_server?(server)
@@ -247,9 +247,9 @@ module Mongo
247
247
 
248
248
  def fetch_query_op(server, session)
249
249
  if server.features.find_command_enabled?
250
- Operation::Commands::Find.new(find_command_spec(session))
250
+ Operation::Find.new(find_command_spec(session))
251
251
  else
252
- Operation::Read::Query.new(fetch_query_spec)
252
+ Operation::Find.new(fetch_query_spec)
253
253
  end
254
254
  end
255
255
 
@@ -136,16 +136,16 @@ module Mongo
136
136
  read_pref = opts[:read] || read_preference
137
137
  selector = ServerSelector.get(read_pref || server_selector)
138
138
  read_with_retry do
139
- server = selector.select_server(cluster, false)
139
+ server = selector.select_server(cluster)
140
140
  apply_collation!(cmd, server, opts)
141
141
  with_session(opts) do |session|
142
- Operation::Commands::Count.new({
143
- :selector => cmd,
144
- :db_name => database.name,
145
- :options => {:limit => -1},
146
- :read => read_pref,
147
- :session => session
148
- }).execute(server)
142
+ Operation::Count.new({
143
+ :selector => cmd,
144
+ :db_name => database.name,
145
+ :options => {:limit => -1},
146
+ :read => read_pref,
147
+ :session => session
148
+ }).execute(server)
149
149
  end.n.to_i
150
150
  end
151
151
  end
@@ -176,16 +176,16 @@ module Mongo
176
176
  read_pref = opts[:read] || read_preference
177
177
  selector = ServerSelector.get(read_pref || server_selector)
178
178
  read_with_retry do
179
- server = selector.select_server(cluster, false)
179
+ server = selector.select_server(cluster)
180
180
  apply_collation!(cmd, server, opts)
181
181
  with_session(opts) do |session|
182
- Operation::Commands::Distinct.new({
183
- :selector => cmd,
184
- :db_name => database.name,
185
- :options => {:limit => -1},
186
- :read => read_pref,
187
- :session => session
188
- }).execute(server)
182
+ Operation::Distinct.new({
183
+ :selector => cmd,
184
+ :db_name => database.name,
185
+ :options => {:limit => -1},
186
+ :read => read_pref,
187
+ :session => session
188
+ }).execute(server)
189
189
  end.first['values']
190
190
  end
191
191
  end
@@ -244,6 +244,9 @@ module Mongo
244
244
  # @return [ Integer, View ] The value or a new +View+.
245
245
  #
246
246
  # @since 2.0.0
247
+ #
248
+ # @deprecated This option is deprecated as of MongoDB server
249
+ # version 4.0.
247
250
  def max_scan(value = nil)
248
251
  configure(:max_scan, value)
249
252
  end
@@ -380,6 +383,9 @@ module Mongo
380
383
  # @param [ true, false ] value The snapshot value.
381
384
  #
382
385
  # @since 2.0.0
386
+ #
387
+ # @deprecated This option is deprecated as of MongoDB server
388
+ # version 4.0.
383
389
  def snapshot(value = nil)
384
390
  configure(:snapshot, value)
385
391
  end
@@ -473,8 +479,8 @@ module Mongo
473
479
 
474
480
  def parallel_scan(cursor_count, options = {})
475
481
  session = client.send(:get_session, @options)
476
- server = server_selector.select_server(cluster, false)
477
- cmd = Operation::Commands::ParallelScan.new({
482
+ server = server_selector.select_server(cluster)
483
+ cmd = Operation::ParallelScan.new({
478
484
  :coll_name => collection.name,
479
485
  :db_name => database.name,
480
486
  :cursor_count => cursor_count,
@@ -483,14 +489,14 @@ module Mongo
483
489
  }.merge!(options))
484
490
  cmd.execute(server).cursor_ids.map do |cursor_id|
485
491
  result = if server.features.find_command_enabled?
486
- Operation::Commands::GetMore.new({
492
+ Operation::GetMore.new({
487
493
  :selector => {:getMore => cursor_id,
488
494
  :collection => collection.name},
489
495
  :db_name => database.name,
490
496
  :session => session
491
497
  }).execute(server)
492
498
  else
493
- Operation::Read::GetMore.new({
499
+ Operation::GetMore.new({
494
500
  :to_return => 0,
495
501
  :cursor_id => cursor_id,
496
502
  :db_name => database.name,
@@ -49,7 +49,7 @@ module Mongo
49
49
  with_session(opts) do |session|
50
50
  write_with_retry(session, write_concern) do |server, txn_num|
51
51
  apply_collation!(cmd, server, opts)
52
- Operation::Commands::Command.new(
52
+ Operation::Command.new(
53
53
  :selector => cmd,
54
54
  :db_name => database.name,
55
55
  :session => session,
@@ -121,7 +121,7 @@ module Mongo
121
121
  write_with_retry(session, write_concern) do |server, txn_num|
122
122
  apply_collation!(cmd, server, opts)
123
123
  apply_array_filters!(cmd, server, opts)
124
- Operation::Commands::Command.new(
124
+ Operation::Command.new(
125
125
  :selector => cmd,
126
126
  :db_name => database.name,
127
127
  :session => session,
@@ -149,8 +149,8 @@ module Mongo
149
149
  with_session(opts) do |session|
150
150
  legacy_write_with_retry do |server|
151
151
  apply_collation!(delete_doc, server, opts)
152
- Operation::Write::Delete.new(
153
- :delete => delete_doc,
152
+ Operation::Delete.new(
153
+ :deletes => [ delete_doc ],
154
154
  :db_name => collection.database.name,
155
155
  :coll_name => collection.name,
156
156
  :write_concern => collection.write_concern,
@@ -178,8 +178,8 @@ module Mongo
178
178
  with_session(opts) do |session|
179
179
  write_with_retry(session, write_concern) do |server, txn_num|
180
180
  apply_collation!(delete_doc, server, opts)
181
- Operation::Write::Delete.new(
182
- :delete => delete_doc,
181
+ Operation::Delete.new(
182
+ :deletes => [ delete_doc ],
183
183
  :db_name => collection.database.name,
184
184
  :coll_name => collection.name,
185
185
  :write_concern => write_concern,
@@ -217,8 +217,8 @@ module Mongo
217
217
  apply_collation!(update_doc, server, opts)
218
218
  apply_array_filters!(update_doc, server, opts)
219
219
 
220
- Operation::Write::Update.new(
221
- :update => update_doc,
220
+ Operation::Update.new(
221
+ :updates => [ update_doc ],
222
222
  :db_name => collection.database.name,
223
223
  :coll_name => collection.name,
224
224
  :write_concern => write_concern,
@@ -256,8 +256,8 @@ module Mongo
256
256
  legacy_write_with_retry do |server|
257
257
  apply_collation!(update_doc, server, opts)
258
258
  apply_array_filters!(update_doc, server, opts)
259
- Operation::Write::Update.new(
260
- :update => update_doc,
259
+ Operation::Update.new(
260
+ :updates => [ update_doc ],
261
261
  :db_name => collection.database.name,
262
262
  :coll_name => collection.name,
263
263
  :write_concern => collection.write_concern,
@@ -296,8 +296,8 @@ module Mongo
296
296
  apply_collation!(update_doc, server, opts)
297
297
  apply_array_filters!(update_doc, server, opts)
298
298
 
299
- Operation::Write::Update.new(
300
- :update => update_doc,
299
+ Operation::Update.new(
300
+ :updates => [ update_doc ],
301
301
  :db_name => collection.database.name,
302
302
  :coll_name => collection.name,
303
303
  :write_concern => write_concern,