mongo 2.13.2 → 2.14.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) 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 +9 -0
  5. data/lib/mongo/address.rb +1 -1
  6. data/lib/mongo/address/ipv4.rb +1 -1
  7. data/lib/mongo/address/ipv6.rb +1 -1
  8. data/lib/mongo/bulk_write.rb +17 -0
  9. data/lib/mongo/caching_cursor.rb +74 -0
  10. data/lib/mongo/client.rb +47 -8
  11. data/lib/mongo/cluster.rb +3 -3
  12. data/lib/mongo/cluster/topology/single.rb +1 -1
  13. data/lib/mongo/collection.rb +26 -0
  14. data/lib/mongo/collection/view.rb +24 -20
  15. data/lib/mongo/collection/view/aggregation.rb +25 -4
  16. data/lib/mongo/collection/view/builder/find_command.rb +38 -18
  17. data/lib/mongo/collection/view/explainable.rb +27 -8
  18. data/lib/mongo/collection/view/iterable.rb +72 -12
  19. data/lib/mongo/collection/view/readable.rb +12 -2
  20. data/lib/mongo/collection/view/writable.rb +15 -1
  21. data/lib/mongo/crypt/encryption_io.rb +6 -6
  22. data/lib/mongo/cursor.rb +1 -0
  23. data/lib/mongo/database.rb +6 -0
  24. data/lib/mongo/database/view.rb +1 -1
  25. data/lib/mongo/error.rb +2 -0
  26. data/lib/mongo/error/invalid_read_concern.rb +28 -0
  27. data/lib/mongo/error/server_certificate_revoked.rb +22 -0
  28. data/lib/mongo/error/unsupported_option.rb +14 -12
  29. data/lib/mongo/lint.rb +2 -1
  30. data/lib/mongo/logger.rb +3 -3
  31. data/lib/mongo/operation.rb +2 -0
  32. data/lib/mongo/operation/aggregate/result.rb +9 -8
  33. data/lib/mongo/operation/collections_info/command.rb +0 -5
  34. data/lib/mongo/operation/collections_info/result.rb +3 -16
  35. data/lib/mongo/operation/delete/bulk_result.rb +2 -0
  36. data/lib/mongo/operation/delete/result.rb +3 -0
  37. data/lib/mongo/operation/explain/command.rb +4 -0
  38. data/lib/mongo/operation/explain/legacy.rb +4 -0
  39. data/lib/mongo/operation/explain/op_msg.rb +6 -0
  40. data/lib/mongo/operation/explain/result.rb +3 -0
  41. data/lib/mongo/operation/find/legacy/result.rb +2 -0
  42. data/lib/mongo/operation/find/result.rb +3 -0
  43. data/lib/mongo/operation/get_more/result.rb +3 -0
  44. data/lib/mongo/operation/indexes/result.rb +5 -0
  45. data/lib/mongo/operation/insert/bulk_result.rb +5 -0
  46. data/lib/mongo/operation/insert/result.rb +5 -0
  47. data/lib/mongo/operation/list_collections/result.rb +5 -0
  48. data/lib/mongo/operation/map_reduce/result.rb +10 -0
  49. data/lib/mongo/operation/parallel_scan/result.rb +4 -0
  50. data/lib/mongo/operation/result.rb +35 -6
  51. data/lib/mongo/operation/shared/bypass_document_validation.rb +1 -0
  52. data/lib/mongo/operation/shared/causal_consistency_supported.rb +1 -0
  53. data/lib/mongo/operation/shared/collections_info_or_list_collections.rb +2 -0
  54. data/lib/mongo/operation/shared/executable.rb +1 -0
  55. data/lib/mongo/operation/shared/idable.rb +2 -1
  56. data/lib/mongo/operation/shared/limited.rb +1 -0
  57. data/lib/mongo/operation/shared/object_id_generator.rb +1 -0
  58. data/lib/mongo/operation/shared/result/aggregatable.rb +1 -0
  59. data/lib/mongo/operation/shared/sessions_supported.rb +1 -0
  60. data/lib/mongo/operation/shared/specifiable.rb +1 -0
  61. data/lib/mongo/operation/shared/write.rb +1 -0
  62. data/lib/mongo/operation/shared/write_concern_supported.rb +1 -0
  63. data/lib/mongo/operation/update/legacy/result.rb +7 -0
  64. data/lib/mongo/operation/update/result.rb +8 -0
  65. data/lib/mongo/operation/users_info/result.rb +3 -0
  66. data/lib/mongo/query_cache.rb +242 -0
  67. data/lib/mongo/retryable.rb +8 -1
  68. data/lib/mongo/server.rb +5 -1
  69. data/lib/mongo/server/connection_common.rb +2 -2
  70. data/lib/mongo/server/connection_pool.rb +3 -0
  71. data/lib/mongo/server/monitor.rb +1 -1
  72. data/lib/mongo/server/monitor/connection.rb +3 -3
  73. data/lib/mongo/server/pending_connection.rb +2 -2
  74. data/lib/mongo/server/push_monitor.rb +1 -1
  75. data/lib/mongo/server_selector/base.rb +5 -1
  76. data/lib/mongo/session.rb +3 -0
  77. data/lib/mongo/socket.rb +6 -4
  78. data/lib/mongo/socket/ocsp_cache.rb +97 -0
  79. data/lib/mongo/socket/ocsp_verifier.rb +368 -0
  80. data/lib/mongo/socket/ssl.rb +45 -24
  81. data/lib/mongo/srv/monitor.rb +7 -13
  82. data/lib/mongo/srv/resolver.rb +14 -10
  83. data/lib/mongo/timeout.rb +2 -0
  84. data/lib/mongo/uri.rb +21 -390
  85. data/lib/mongo/uri/options_mapper.rb +582 -0
  86. data/lib/mongo/uri/srv_protocol.rb +3 -2
  87. data/lib/mongo/utils.rb +12 -1
  88. data/lib/mongo/version.rb +1 -1
  89. data/spec/NOTES.aws-auth.md +12 -7
  90. data/spec/README.md +56 -1
  91. data/spec/integration/bson_symbol_spec.rb +2 -4
  92. data/spec/integration/bulk_write_spec.rb +48 -0
  93. data/spec/integration/client_authentication_options_spec.rb +55 -28
  94. data/spec/integration/connection_pool_populator_spec.rb +3 -1
  95. data/spec/integration/cursor_reaping_spec.rb +53 -17
  96. data/spec/integration/ocsp_connectivity_spec.rb +26 -0
  97. data/spec/integration/ocsp_verifier_cache_spec.rb +188 -0
  98. data/spec/integration/ocsp_verifier_spec.rb +334 -0
  99. data/spec/integration/query_cache_spec.rb +1045 -0
  100. data/spec/integration/query_cache_transactions_spec.rb +179 -0
  101. data/spec/integration/retryable_writes/retryable_writes_40_and_newer_spec.rb +1 -0
  102. data/spec/integration/retryable_writes/shared/performs_legacy_retries.rb +2 -0
  103. data/spec/integration/sdam_error_handling_spec.rb +68 -17
  104. data/spec/integration/sdam_events_spec.rb +5 -8
  105. data/spec/integration/server_selection_spec.rb +36 -0
  106. data/spec/integration/srv_monitoring_spec.rb +38 -3
  107. data/spec/integration/srv_spec.rb +56 -0
  108. data/spec/lite_spec_helper.rb +4 -2
  109. data/spec/mongo/address_spec.rb +1 -1
  110. data/spec/mongo/caching_cursor_spec.rb +70 -0
  111. data/spec/mongo/client_construction_spec.rb +54 -1
  112. data/spec/mongo/client_encryption_spec.rb +10 -16
  113. data/spec/mongo/client_spec.rb +40 -0
  114. data/spec/mongo/cluster/topology/single_spec.rb +14 -5
  115. data/spec/mongo/cluster_spec.rb +3 -0
  116. data/spec/mongo/collection/view/explainable_spec.rb +87 -4
  117. data/spec/mongo/collection/view/map_reduce_spec.rb +2 -0
  118. data/spec/mongo/collection_spec.rb +60 -0
  119. data/spec/mongo/crypt/auto_decryption_context_spec.rb +1 -1
  120. data/spec/mongo/crypt/auto_encryption_context_spec.rb +1 -1
  121. data/spec/mongo/crypt/data_key_context_spec.rb +1 -1
  122. data/spec/mongo/crypt/explicit_decryption_context_spec.rb +1 -1
  123. data/spec/mongo/crypt/explicit_encryption_context_spec.rb +1 -1
  124. data/spec/mongo/database_spec.rb +44 -64
  125. data/spec/mongo/error/no_server_available_spec.rb +1 -1
  126. data/spec/mongo/logger_spec.rb +13 -11
  127. data/spec/mongo/query_cache_spec.rb +279 -0
  128. data/spec/mongo/server/app_metadata_shared.rb +1 -1
  129. data/spec/mongo/server/connection_pool_spec.rb +7 -3
  130. data/spec/mongo/server/connection_spec.rb +14 -7
  131. data/spec/mongo/socket/ssl_spec.rb +1 -1
  132. data/spec/mongo/socket_spec.rb +1 -1
  133. data/spec/mongo/uri/srv_protocol_spec.rb +64 -33
  134. data/spec/mongo/uri_option_parsing_spec.rb +11 -11
  135. data/spec/mongo/uri_spec.rb +68 -41
  136. data/spec/mongo/utils_spec.rb +39 -0
  137. data/spec/runners/auth.rb +3 -0
  138. data/spec/runners/connection_string.rb +35 -124
  139. data/spec/spec_tests/cmap_spec.rb +7 -3
  140. data/spec/spec_tests/data/change_streams/change-streams-errors.yml +0 -1
  141. data/spec/spec_tests/data/change_streams/change-streams.yml +0 -1
  142. data/spec/spec_tests/data/cmap/pool-checkout-connection.yml +6 -2
  143. data/spec/spec_tests/data/cmap/pool-create-min-size.yml +3 -0
  144. data/spec/spec_tests/data/connection_string/valid-warnings.yml +24 -0
  145. data/spec/spec_tests/data/sdam_monitoring/discovered_standalone.yml +1 -3
  146. data/spec/spec_tests/data/sdam_monitoring/standalone.yml +2 -2
  147. data/spec/spec_tests/data/sdam_monitoring/standalone_repeated.yml +2 -2
  148. data/spec/spec_tests/data/sdam_monitoring/standalone_suppress_equal_description_changes.yml +2 -2
  149. data/spec/spec_tests/data/sdam_monitoring/standalone_to_rs_with_me_mismatch.yml +2 -2
  150. data/spec/spec_tests/data/uri_options/auth-options.yml +25 -0
  151. data/spec/spec_tests/data/uri_options/compression-options.yml +6 -3
  152. data/spec/spec_tests/data/uri_options/read-preference-options.yml +24 -0
  153. data/spec/spec_tests/data/uri_options/ruby-connection-options.yml +1 -0
  154. data/spec/spec_tests/data/uri_options/tls-options.yml +160 -4
  155. data/spec/spec_tests/dns_seedlist_discovery_spec.rb +9 -1
  156. data/spec/spec_tests/uri_options_spec.rb +31 -33
  157. data/spec/support/certificates/atlas-ocsp-ca.crt +28 -0
  158. data/spec/support/certificates/atlas-ocsp.crt +41 -0
  159. data/spec/support/client_registry_macros.rb +11 -2
  160. data/spec/support/common_shortcuts.rb +45 -0
  161. data/spec/support/constraints.rb +23 -0
  162. data/spec/support/lite_constraints.rb +24 -0
  163. data/spec/support/matchers.rb +16 -0
  164. data/spec/support/ocsp +1 -0
  165. data/spec/support/session_registry.rb +52 -0
  166. data/spec/support/spec_config.rb +22 -0
  167. data/spec/support/utils.rb +19 -1
  168. metadata +1017 -992
  169. metadata.gz.sig +0 -0
  170. data/spec/shared/LICENSE +0 -20
  171. data/spec/shared/lib/mrss/child_process_helper.rb +0 -80
  172. data/spec/shared/lib/mrss/constraints.rb +0 -303
  173. data/spec/shared/lib/mrss/lite_constraints.rb +0 -175
  174. data/spec/shared/lib/mrss/spec_organizer.rb +0 -149
@@ -263,6 +263,7 @@ module Mongo
263
263
  # @param [ Hash ] options The options for the operation.
264
264
  #
265
265
  # @option options [ Session ] :session The session to use for the operation.
266
+ # @option opts [ Hash ] :write_concern The write concern options.
266
267
  #
267
268
  # @return [ Result ] The result of the command.
268
269
  #
@@ -270,6 +271,11 @@ module Mongo
270
271
  def drop(options = {})
271
272
  operation = { :dropDatabase => 1 }
272
273
  client.send(:with_session, options) do |session|
274
+ write_concern = if options[:write_concern]
275
+ WriteConcern.get(options[:write_concern])
276
+ else
277
+ self.write_concern
278
+ end
273
279
  Operation::DropDatabase.new({
274
280
  selector: operation,
275
281
  db_name: name,
@@ -100,7 +100,7 @@ module Mongo
100
100
  #
101
101
  # @return [ Array<Hash> ] Info for each collection in the database.
102
102
  #
103
- # @since 2.0.5
103
+ # @since 2.0.5
104
104
  def list_collections(options = {})
105
105
  session = client.send(:get_session)
106
106
  collections_info(session, ServerSelector.primary, options)
@@ -188,6 +188,7 @@ require 'mongo/error/invalid_min_pool_size'
188
188
  require 'mongo/error/invalid_read_option'
189
189
  require 'mongo/error/invalid_application_name'
190
190
  require 'mongo/error/invalid_nonce'
191
+ require 'mongo/error/invalid_read_concern'
191
192
  require 'mongo/error/invalid_replacement_document'
192
193
  require 'mongo/error/invalid_server_auth_response'
193
194
  # Subclass of InvalidServerAuthResponse
@@ -215,6 +216,7 @@ require 'mongo/error/session_ended'
215
216
  require 'mongo/error/sessions_not_supported'
216
217
  require 'mongo/error/pool_closed_error'
217
218
  require 'mongo/error/raise_original_error'
219
+ require 'mongo/error/server_certificate_revoked'
218
220
  require 'mongo/error/socket_error'
219
221
  require 'mongo/error/socket_timeout_error'
220
222
  require 'mongo/error/failed_string_prep_validation'
@@ -0,0 +1,28 @@
1
+ # Copyright (C) 2020 MongoDB Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Mongo
16
+ class Error
17
+
18
+ # Raised when an invalid read concern is provided.
19
+ class InvalidReadConcern < Error
20
+ # Instantiate the new exception.
21
+ def initialize(msg = nil)
22
+ super(msg || 'Invalid read concern option provided.' \
23
+ 'The only valid key is :level, for which accepted values are' \
24
+ ':local, :majority, and :snapshot')
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,22 @@
1
+ # Copyright (C) 2020 MongoDB Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Mongo
16
+ class Error
17
+
18
+ # Server certificate has been revoked (determined via OCSP).
19
+ class ServerCertificateRevoked < Error
20
+ end
21
+ end
22
+ end
@@ -17,39 +17,39 @@ module Mongo
17
17
 
18
18
  # Raised if an unsupported option is specified for an operation.
19
19
  class UnsupportedOption < Error
20
- # @api private
21
- #
22
20
  # The error message provided when the user passes the hint option to
23
21
  # a write operation against a server that does not support the hint
24
22
  # option and does not provide option validation.
23
+ #
24
+ # @api private
25
25
  HINT_MESSAGE = "The MongoDB server handling this request does not support " \
26
26
  "the hint option on this command. The hint option is supported on update " \
27
27
  "commands on MongoDB server versions 4.2 and later and on findAndModify " \
28
28
  "and delete commands on MongoDB server versions 4.4 and later"
29
29
 
30
- # @api private
31
- #
32
30
  # The error message provided when the user passes the hint option to
33
31
  # an unacknowledged write operation.
32
+ #
33
+ # @api private
34
34
  UNACKNOWLEDGED_HINT_MESSAGE = "The hint option cannot be specified on " \
35
35
  "an unacknowledged write operation. Remove the hint option or perform " \
36
36
  "this operation with a write concern of at least { w: 1 }"
37
37
 
38
- # @api private
39
- #
40
38
  # The error message provided when the user passes the allow_disk_use
41
39
  # option to a find operation against a server that does not support the
42
40
  # allow_disk_use operation and does not provide option validation.
41
+ #
42
+ # @api private
43
43
  ALLOW_DISK_USE_MESSAGE = "The MongoDB server handling this request does " \
44
44
  "not support the allow_disk_use option on this command. The " \
45
45
  "allow_disk_use option is supported on find commands on MongoDB " \
46
46
  "server versions 4.4 and later"
47
47
 
48
- # @api private
49
- #
50
48
  # The error message provided when the user passes the commit_quorum option
51
49
  # to a createIndexes operation against a server that does not support
52
50
  # that option.
51
+ #
52
+ # @api private
53
53
  COMMIT_QUORUM_MESSAGE = "The MongoDB server handling this request does " \
54
54
  "not support the commit_quorum option on this command. The commit_quorum " \
55
55
  "option is supported on createIndexes commands on MongoDB server versions " \
@@ -57,14 +57,14 @@ module Mongo
57
57
 
58
58
  # Raise an error about an unsupported hint option.
59
59
  #
60
- # @param [ Hash ] options
61
- #
62
60
  # @option options [ Boolean ] unacknowledged_write Whether this error
63
61
  # pertains to a hint option passed to an unacknowledged write. Defaults
64
62
  # to false.
65
63
  #
66
64
  # @return [ Mongo::Error::UnsupportedOption ] An error with a default
67
65
  # error message.
66
+ #
67
+ # @api private
68
68
  def self.hint_error(**options)
69
69
  unacknowledged_write = options[:unacknowledged_write] || false
70
70
 
@@ -79,10 +79,10 @@ module Mongo
79
79
 
80
80
  # Raise an error about an unsupported allow_disk_use option.
81
81
  #
82
- # @param [ Hash ] options
83
- #
84
82
  # @return [ Mongo::Error::UnsupportedOption ] An error with a default
85
83
  # error message.
84
+ #
85
+ # @api private
86
86
  def self.allow_disk_use_error
87
87
  new(ALLOW_DISK_USE_MESSAGE)
88
88
  end
@@ -91,6 +91,8 @@ module Mongo
91
91
  #
92
92
  # @return [ Mongo::Error::UnsupportedOption ] An error with a default
93
93
  # error message.
94
+ #
95
+ # @api private
94
96
  def self.commit_quorum_error
95
97
  new(COMMIT_QUORUM_MESSAGE)
96
98
  end
@@ -4,12 +4,13 @@ module Mongo
4
4
  module Lint
5
5
 
6
6
  # Raises LintError if +obj+ is not of type +cls+.
7
- module_function def assert_type(obj, cls)
7
+ def assert_type(obj, cls)
8
8
  return unless enabled?
9
9
  unless obj.is_a?(cls)
10
10
  raise Error::LintError, "Expected #{obj} to be a #{cls}"
11
11
  end
12
12
  end
13
+ module_function :assert_type
13
14
 
14
15
  def validate_underscore_read_preference(read_pref)
15
16
  return unless enabled?
@@ -21,7 +21,7 @@ module Mongo
21
21
 
22
22
  class << self
23
23
 
24
- # Get the wrapped logger. If none was set will return a default debug
24
+ # Get the wrapped logger. If none was set will return a default info
25
25
  # level logger.
26
26
  #
27
27
  # @example Get the wrapped logger.
@@ -75,8 +75,8 @@ module Mongo
75
75
  private
76
76
 
77
77
  def default_logger
78
- logger = ::Logger.new($stdout)
79
- logger.level = ::Logger::DEBUG
78
+ logger = ::Logger.new(STDOUT)
79
+ logger.level = ::Logger::INFO
80
80
  logger
81
81
  end
82
82
  end
@@ -50,6 +50,8 @@ require 'mongo/operation/create_index'
50
50
  require 'mongo/operation/drop_index'
51
51
 
52
52
  module Mongo
53
+
54
+ # @api private
53
55
  module Operation
54
56
 
55
57
  # The q field constant.
@@ -14,25 +14,24 @@
14
14
 
15
15
  module Mongo
16
16
  module Operation
17
-
18
- # Aggregate result wrapper.
19
- #
20
- # @since 2.0.0
21
17
  class Aggregate
22
18
 
23
19
  # Defines custom behavior of results in an aggregation context.
24
20
  #
25
21
  # @since 2.0.0
22
+ # @api semiprivate
26
23
  class Result < Operation::Result
27
24
 
28
25
  # The field name for the aggregation explain information.
29
26
  #
30
27
  # @since 2.0.5
28
+ # @api private
31
29
  EXPLAIN = 'stages'.freeze
32
30
 
33
31
  # The legacy field name for the aggregation explain information.
34
32
  #
35
33
  # @since 2.0.5
34
+ # @api private
36
35
  EXPLAIN_LEGACY = 'serverPipeline'.freeze
37
36
 
38
37
  # Get the cursor id for the result.
@@ -48,6 +47,7 @@ module Mongo
48
47
  # @return [ Integer ] The cursor id.
49
48
  #
50
49
  # @since 2.0.0
50
+ # @api private
51
51
  def cursor_id
52
52
  cursor_document ? cursor_document[CURSOR_ID] : 0
53
53
  end
@@ -62,8 +62,8 @@ module Mongo
62
62
  end
63
63
 
64
64
  # Get the documents for the aggregation result. This is either the
65
- # first document's 'result' field, or if a cursor option was selected,
66
- # it is the 'firstBatch' field in the 'cursor' field of the first
65
+ # first document's 'result' field, or if a cursor option was selected,
66
+ # it is the 'firstBatch' field in the 'cursor' field of the first
67
67
  # document returned. Otherwise, it is an explain document.
68
68
  #
69
69
  # @example Get the documents.
@@ -72,10 +72,11 @@ module Mongo
72
72
  # @return [ Array<BSON::Document> ] The documents.
73
73
  #
74
74
  # @since 2.0.0
75
+ # @api public
75
76
  def documents
76
- docs = reply.documents[0][RESULT]
77
+ docs = reply.documents[0][RESULT]
77
78
  docs ||= cursor_document[FIRST_BATCH] if cursor_document
78
- docs ||= explain_document
79
+ docs ||= explain_document
79
80
  docs
80
81
  end
81
82
 
@@ -27,11 +27,6 @@ module Mongo
27
27
 
28
28
  private
29
29
 
30
- def get_result(connection, client, options = {})
31
- # This is a Mongo::Operation::CollectionsInfo::Result
32
- Result.new(*dispatch_message(connection, client), db_name)
33
- end
34
-
35
30
  def selector(connection)
36
31
  {}
37
32
  end
@@ -20,23 +20,9 @@ module Mongo
20
20
  # collection.
21
21
  #
22
22
  # @since 2.1.0
23
+ # @api semiprivate
23
24
  class Result < Operation::Result
24
25
 
25
- # Initialize a new result.
26
- #
27
- # @param [ Array<Protocol::Message> | nil ] replies The wire protocol replies, if any.
28
- # @param [ Server::Description ] connection_description
29
- # Server description of the server that performed the operation that
30
- # this result is for.
31
- # @param [ String ] database_name The name of the database that the
32
- # query was sent to.
33
- #
34
- # @api private
35
- def initialize(replies, connection_description, database_name)
36
- super(replies, connection_description)
37
- @database_name = database_name
38
- end
39
-
40
26
  # Get the namespace for the cursor.
41
27
  #
42
28
  # @example Get the namespace.
@@ -45,8 +31,9 @@ module Mongo
45
31
  # @return [ String ] The namespace.
46
32
  #
47
33
  # @since 2.1.0
34
+ # @api private
48
35
  def namespace
49
- "#{@database_name}.#{Database::NAMESPACES}"
36
+ Database::NAMESPACES
50
37
  end
51
38
  end
52
39
  end
@@ -19,6 +19,7 @@ module Mongo
19
19
  # Defines custom behavior of results for a delete when part of a bulk write.
20
20
  #
21
21
  # @since 2.0.0
22
+ # @api semiprivate
22
23
  class BulkResult < Operation::Result
23
24
  include Aggregatable
24
25
 
@@ -30,6 +31,7 @@ module Mongo
30
31
  # @return [ Integer ] The number of documents deleted.
31
32
  #
32
33
  # @since 2.0.0
34
+ # @api public
33
35
  def n_removed
34
36
  return 0 unless acknowledged?
35
37
  @replies.reduce(0) do |n, reply|
@@ -19,6 +19,7 @@ module Mongo
19
19
  # Defines custom behavior of results for a delete.
20
20
  #
21
21
  # @since 2.0.0
22
+ # @api semiprivate
22
23
  class Result < Operation::Result
23
24
 
24
25
  # Get the number of documents deleted.
@@ -29,10 +30,12 @@ module Mongo
29
30
  # @return [ Integer ] The deleted count.
30
31
  #
31
32
  # @since 2.0.0
33
+ # @api public
32
34
  def deleted_count
33
35
  n
34
36
  end
35
37
 
38
+ # @api public
36
39
  def bulk_result
37
40
  BulkResult.new(@replies, connection_description)
38
41
  end
@@ -30,6 +30,10 @@ module Mongo
30
30
 
31
31
  private
32
32
 
33
+ def selector(connection)
34
+ super.merge(spec[:explain])
35
+ end
36
+
33
37
  def message(connection)
34
38
  Protocol::Query.new(db_name, Database::COMMAND, command(connection), options(connection))
35
39
  end
@@ -29,6 +29,10 @@ module Mongo
29
29
 
30
30
  private
31
31
 
32
+ def selector(connection)
33
+ super.merge(spec[:explain])
34
+ end
35
+
32
36
  def message(connection)
33
37
  Protocol::Query.new(db_name, coll_name, command(connection), options(connection))
34
38
  end
@@ -25,6 +25,12 @@ module Mongo
25
25
  include CausalConsistencySupported
26
26
  include ExecutableTransactionLabel
27
27
  include PolymorphicResult
28
+
29
+ private
30
+
31
+ def selector(connection)
32
+ super.merge(spec[:explain])
33
+ end
28
34
  end
29
35
  end
30
36
  end
@@ -19,6 +19,7 @@ module Mongo
19
19
  # Defines custom behavior of results in find command with explain.
20
20
  #
21
21
  # @since 2.5.0
22
+ # @api semiprivate
22
23
  class Result < Operation::Result
23
24
 
24
25
  # Get the cursor id.
@@ -29,6 +30,7 @@ module Mongo
29
30
  # @return [ 0 ] Always 0 because explain doesn't return a cursor.
30
31
  #
31
32
  # @since 2.5.0
33
+ # @api private
32
34
  def cursor_id
33
35
  0
34
36
  end
@@ -41,6 +43,7 @@ module Mongo
41
43
  # @return [ Array<BSON::Document> ] The documents.
42
44
  #
43
45
  # @since 2.5.0
46
+ # @api public
44
47
  def documents
45
48
  reply.documents
46
49
  end
@@ -20,6 +20,7 @@ module Mongo
20
20
  # Defines custom behavior of results for a query.
21
21
  #
22
22
  # @since 2.1.0
23
+ # @api semiprivate
23
24
  class Result < Operation::Result
24
25
  include Operation::Result::UseLegacyErrorParser
25
26
 
@@ -31,6 +32,7 @@ module Mongo
31
32
  # @return [ true, false ] If the query was successful.
32
33
  #
33
34
  # @since 2.0.0
35
+ # @api public
34
36
  def successful?
35
37
  !query_failure?
36
38
  end