mongo 2.13.1 → 2.14.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +1 -4
  4. data/lib/mongo.rb +9 -0
  5. data/lib/mongo/address/ipv4.rb +1 -1
  6. data/lib/mongo/address/ipv6.rb +1 -1
  7. data/lib/mongo/bulk_write.rb +17 -0
  8. data/lib/mongo/caching_cursor.rb +74 -0
  9. data/lib/mongo/client.rb +47 -8
  10. data/lib/mongo/cluster.rb +3 -3
  11. data/lib/mongo/cluster/topology/single.rb +1 -1
  12. data/lib/mongo/collection.rb +26 -0
  13. data/lib/mongo/collection/view.rb +24 -20
  14. data/lib/mongo/collection/view/aggregation.rb +25 -4
  15. data/lib/mongo/collection/view/builder/find_command.rb +38 -18
  16. data/lib/mongo/collection/view/explainable.rb +27 -8
  17. data/lib/mongo/collection/view/iterable.rb +72 -12
  18. data/lib/mongo/collection/view/readable.rb +12 -2
  19. data/lib/mongo/collection/view/writable.rb +15 -1
  20. data/lib/mongo/crypt/encryption_io.rb +6 -6
  21. data/lib/mongo/cursor.rb +1 -0
  22. data/lib/mongo/database.rb +6 -0
  23. data/lib/mongo/error.rb +2 -0
  24. data/lib/mongo/error/invalid_read_concern.rb +28 -0
  25. data/lib/mongo/error/server_certificate_revoked.rb +22 -0
  26. data/lib/mongo/error/unsupported_option.rb +14 -12
  27. data/lib/mongo/lint.rb +2 -1
  28. data/lib/mongo/logger.rb +3 -3
  29. data/lib/mongo/operation.rb +2 -0
  30. data/lib/mongo/operation/aggregate/result.rb +9 -8
  31. data/lib/mongo/operation/collections_info/result.rb +2 -0
  32. data/lib/mongo/operation/delete/bulk_result.rb +2 -0
  33. data/lib/mongo/operation/delete/result.rb +3 -0
  34. data/lib/mongo/operation/explain/command.rb +4 -0
  35. data/lib/mongo/operation/explain/legacy.rb +4 -0
  36. data/lib/mongo/operation/explain/op_msg.rb +6 -0
  37. data/lib/mongo/operation/explain/result.rb +3 -0
  38. data/lib/mongo/operation/find/legacy/result.rb +2 -0
  39. data/lib/mongo/operation/find/result.rb +3 -0
  40. data/lib/mongo/operation/get_more/result.rb +3 -0
  41. data/lib/mongo/operation/indexes/result.rb +5 -0
  42. data/lib/mongo/operation/insert/bulk_result.rb +5 -0
  43. data/lib/mongo/operation/insert/result.rb +5 -0
  44. data/lib/mongo/operation/list_collections/result.rb +5 -0
  45. data/lib/mongo/operation/map_reduce/result.rb +10 -0
  46. data/lib/mongo/operation/parallel_scan/result.rb +4 -0
  47. data/lib/mongo/operation/result.rb +35 -6
  48. data/lib/mongo/operation/shared/bypass_document_validation.rb +1 -0
  49. data/lib/mongo/operation/shared/causal_consistency_supported.rb +1 -0
  50. data/lib/mongo/operation/shared/collections_info_or_list_collections.rb +2 -0
  51. data/lib/mongo/operation/shared/executable.rb +1 -0
  52. data/lib/mongo/operation/shared/idable.rb +2 -1
  53. data/lib/mongo/operation/shared/limited.rb +1 -0
  54. data/lib/mongo/operation/shared/object_id_generator.rb +1 -0
  55. data/lib/mongo/operation/shared/result/aggregatable.rb +1 -0
  56. data/lib/mongo/operation/shared/sessions_supported.rb +1 -0
  57. data/lib/mongo/operation/shared/specifiable.rb +1 -0
  58. data/lib/mongo/operation/shared/write.rb +1 -0
  59. data/lib/mongo/operation/shared/write_concern_supported.rb +1 -0
  60. data/lib/mongo/operation/update/legacy/result.rb +7 -0
  61. data/lib/mongo/operation/update/result.rb +8 -0
  62. data/lib/mongo/operation/users_info/result.rb +3 -0
  63. data/lib/mongo/query_cache.rb +242 -0
  64. data/lib/mongo/retryable.rb +8 -1
  65. data/lib/mongo/server.rb +5 -1
  66. data/lib/mongo/server/connection_common.rb +2 -2
  67. data/lib/mongo/server/connection_pool.rb +3 -0
  68. data/lib/mongo/server/monitor.rb +1 -1
  69. data/lib/mongo/server/monitor/connection.rb +3 -3
  70. data/lib/mongo/server/pending_connection.rb +2 -2
  71. data/lib/mongo/server/push_monitor.rb +1 -1
  72. data/lib/mongo/server_selector/base.rb +5 -1
  73. data/lib/mongo/session.rb +3 -0
  74. data/lib/mongo/socket.rb +6 -4
  75. data/lib/mongo/socket/ocsp_cache.rb +97 -0
  76. data/lib/mongo/socket/ocsp_verifier.rb +368 -0
  77. data/lib/mongo/socket/ssl.rb +45 -24
  78. data/lib/mongo/srv/monitor.rb +7 -13
  79. data/lib/mongo/srv/resolver.rb +14 -10
  80. data/lib/mongo/timeout.rb +2 -0
  81. data/lib/mongo/uri.rb +21 -390
  82. data/lib/mongo/uri/options_mapper.rb +582 -0
  83. data/lib/mongo/uri/srv_protocol.rb +3 -2
  84. data/lib/mongo/utils.rb +12 -1
  85. data/lib/mongo/version.rb +1 -1
  86. data/spec/NOTES.aws-auth.md +12 -7
  87. data/spec/README.md +56 -1
  88. data/spec/integration/bulk_write_spec.rb +48 -0
  89. data/spec/integration/client_authentication_options_spec.rb +55 -28
  90. data/spec/integration/connection_pool_populator_spec.rb +3 -1
  91. data/spec/integration/cursor_reaping_spec.rb +53 -17
  92. data/spec/integration/ocsp_connectivity_spec.rb +26 -0
  93. data/spec/integration/ocsp_verifier_cache_spec.rb +188 -0
  94. data/spec/integration/ocsp_verifier_spec.rb +334 -0
  95. data/spec/integration/query_cache_spec.rb +1045 -0
  96. data/spec/integration/query_cache_transactions_spec.rb +179 -0
  97. data/spec/integration/retryable_writes/retryable_writes_40_and_newer_spec.rb +1 -0
  98. data/spec/integration/retryable_writes/shared/performs_legacy_retries.rb +2 -0
  99. data/spec/integration/sdam_error_handling_spec.rb +68 -0
  100. data/spec/integration/server_selection_spec.rb +36 -0
  101. data/spec/integration/srv_monitoring_spec.rb +38 -3
  102. data/spec/integration/srv_spec.rb +56 -0
  103. data/spec/lite_spec_helper.rb +3 -1
  104. data/spec/mongo/address_spec.rb +1 -1
  105. data/spec/mongo/caching_cursor_spec.rb +70 -0
  106. data/spec/mongo/client_construction_spec.rb +54 -1
  107. data/spec/mongo/client_spec.rb +40 -0
  108. data/spec/mongo/cluster/topology/single_spec.rb +14 -5
  109. data/spec/mongo/cluster_spec.rb +3 -0
  110. data/spec/mongo/collection/view/explainable_spec.rb +87 -4
  111. data/spec/mongo/collection/view/map_reduce_spec.rb +2 -0
  112. data/spec/mongo/collection_spec.rb +60 -0
  113. data/spec/mongo/crypt/auto_decryption_context_spec.rb +1 -1
  114. data/spec/mongo/crypt/auto_encryption_context_spec.rb +1 -1
  115. data/spec/mongo/crypt/explicit_decryption_context_spec.rb +1 -1
  116. data/spec/mongo/crypt/explicit_encryption_context_spec.rb +1 -1
  117. data/spec/mongo/database_spec.rb +44 -0
  118. data/spec/mongo/error/no_server_available_spec.rb +1 -1
  119. data/spec/mongo/logger_spec.rb +13 -11
  120. data/spec/mongo/query_cache_spec.rb +279 -0
  121. data/spec/mongo/server/connection_pool_spec.rb +7 -3
  122. data/spec/mongo/server/connection_spec.rb +14 -7
  123. data/spec/mongo/socket/ssl_spec.rb +1 -1
  124. data/spec/mongo/socket_spec.rb +1 -1
  125. data/spec/mongo/uri/srv_protocol_spec.rb +64 -33
  126. data/spec/mongo/uri_option_parsing_spec.rb +11 -11
  127. data/spec/mongo/uri_spec.rb +68 -41
  128. data/spec/mongo/utils_spec.rb +39 -0
  129. data/spec/runners/auth.rb +3 -0
  130. data/spec/runners/connection_string.rb +35 -124
  131. data/spec/spec_tests/cmap_spec.rb +7 -3
  132. data/spec/spec_tests/data/change_streams/change-streams-errors.yml +0 -1
  133. data/spec/spec_tests/data/change_streams/change-streams.yml +0 -1
  134. data/spec/spec_tests/data/cmap/pool-checkout-connection.yml +6 -2
  135. data/spec/spec_tests/data/cmap/pool-create-min-size.yml +3 -0
  136. data/spec/spec_tests/data/connection_string/valid-warnings.yml +24 -0
  137. data/spec/spec_tests/data/sdam_monitoring/discovered_standalone.yml +1 -3
  138. data/spec/spec_tests/data/sdam_monitoring/standalone.yml +2 -2
  139. data/spec/spec_tests/data/sdam_monitoring/standalone_repeated.yml +2 -2
  140. data/spec/spec_tests/data/sdam_monitoring/standalone_suppress_equal_description_changes.yml +2 -2
  141. data/spec/spec_tests/data/sdam_monitoring/standalone_to_rs_with_me_mismatch.yml +2 -2
  142. data/spec/spec_tests/data/uri_options/auth-options.yml +25 -0
  143. data/spec/spec_tests/data/uri_options/compression-options.yml +6 -3
  144. data/spec/spec_tests/data/uri_options/read-preference-options.yml +24 -0
  145. data/spec/spec_tests/data/uri_options/ruby-connection-options.yml +1 -0
  146. data/spec/spec_tests/data/uri_options/tls-options.yml +160 -4
  147. data/spec/spec_tests/dns_seedlist_discovery_spec.rb +9 -1
  148. data/spec/spec_tests/uri_options_spec.rb +31 -33
  149. data/spec/support/certificates/atlas-ocsp-ca.crt +28 -0
  150. data/spec/support/certificates/atlas-ocsp.crt +41 -0
  151. data/spec/support/client_registry_macros.rb +11 -2
  152. data/spec/support/common_shortcuts.rb +45 -0
  153. data/spec/support/constraints.rb +23 -0
  154. data/spec/support/lite_constraints.rb +24 -0
  155. data/spec/support/matchers.rb +16 -0
  156. data/spec/support/ocsp +1 -0
  157. data/spec/support/session_registry.rb +52 -0
  158. data/spec/support/spec_config.rb +22 -0
  159. data/spec/support/utils.rb +19 -1
  160. metadata +38 -3
  161. metadata.gz.sig +0 -0
@@ -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,
@@ -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
 
@@ -20,6 +20,7 @@ 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
26
  # Get the namespace for the cursor.
@@ -30,6 +31,7 @@ module Mongo
30
31
  # @return [ String ] The namespace.
31
32
  #
32
33
  # @since 2.1.0
34
+ # @api private
33
35
  def namespace
34
36
  Database::NAMESPACES
35
37
  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
@@ -19,6 +19,7 @@ module Mongo
19
19
  # Defines custom behavior of results in find command.
20
20
  #
21
21
  # @since 2.2.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 [ Integer ] The cursor id.
30
31
  #
31
32
  # @since 2.2.0
33
+ # @api private
32
34
  def cursor_id
33
35
  cursor_document ? cursor_document[CURSOR_ID] : super
34
36
  end
@@ -41,6 +43,7 @@ module Mongo
41
43
  # @return [ Array<BSON::Document> ] The documents.
42
44
  #
43
45
  # @since 2.2.0
46
+ # @api public
44
47
  def documents
45
48
  cursor_document[FIRST_BATCH]
46
49
  end
@@ -19,6 +19,7 @@ module Mongo
19
19
  # Defines custom behavior of results for the get more command.
20
20
  #
21
21
  # @since 2.2.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 [ Integer ] The cursor id.
30
31
  #
31
32
  # @since 2.2.0
33
+ # @api private
32
34
  def cursor_id
33
35
  cursor_document ? cursor_document[CURSOR_ID] : super
34
36
  end
@@ -50,6 +52,7 @@ module Mongo
50
52
  # @return [ Array<BSON::Document> ] The documents.
51
53
  #
52
54
  # @since 2.2.0
55
+ # @api public
53
56
  def documents
54
57
  cursor_document[NEXT_BATCH]
55
58
  end