mongo 2.13.0.rc1 → 2.13.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/mongo/address.rb +1 -1
- data/lib/mongo/auth/aws/request.rb +27 -3
- data/lib/mongo/client.rb +48 -2
- data/lib/mongo/collection.rb +21 -12
- data/lib/mongo/database/view.rb +1 -1
- data/lib/mongo/database.rb +14 -2
- data/lib/mongo/error/invalid_server_auth_host.rb +22 -0
- data/lib/mongo/error/operation_failure.rb +5 -5
- data/lib/mongo/error.rb +2 -0
- data/lib/mongo/grid/fs_bucket.rb +37 -37
- data/lib/mongo/index/view.rb +3 -0
- data/lib/mongo/operation/collections_info/command.rb +5 -0
- data/lib/mongo/operation/collections_info/result.rb +16 -1
- data/lib/mongo/operation/parallel_scan/command.rb +1 -2
- data/lib/mongo/operation/shared/read_preference_supported.rb +38 -36
- data/lib/mongo/operation/shared/sessions_supported.rb +3 -2
- data/lib/mongo/protocol/message.rb +11 -2
- data/lib/mongo/protocol/msg.rb +22 -3
- data/lib/mongo/protocol/query.rb +47 -11
- data/lib/mongo/server/app_metadata.rb +27 -3
- data/lib/mongo/server/connection_base.rb +35 -11
- data/lib/mongo/server_selector/secondary_preferred.rb +2 -7
- data/lib/mongo/version.rb +1 -1
- data/spec/integration/bson_symbol_spec.rb +4 -2
- data/spec/integration/bulk_write_spec.rb +19 -0
- data/spec/integration/client_authentication_options_spec.rb +37 -0
- data/spec/integration/client_side_encryption/auto_encryption_bulk_writes_spec.rb +9 -5
- data/spec/integration/sdam_error_handling_spec.rb +18 -1
- data/spec/integration/sdam_events_spec.rb +8 -7
- data/spec/integration/secondary_reads_spec.rb +102 -0
- data/spec/integration/size_limit_spec.rb +20 -6
- data/spec/lite_spec_helper.rb +1 -1
- data/spec/mongo/auth/aws/request_region_spec.rb +42 -0
- data/spec/mongo/auth/aws/request_spec.rb +32 -32
- data/spec/mongo/client_construction_spec.rb +123 -0
- data/spec/mongo/client_encryption_spec.rb +16 -10
- data/spec/mongo/crypt/data_key_context_spec.rb +1 -1
- data/spec/mongo/database_spec.rb +64 -0
- data/spec/mongo/index/view_spec.rb +150 -2
- data/spec/mongo/operation/read_preference_legacy_spec.rb +9 -19
- data/spec/mongo/operation/read_preference_op_msg_spec.rb +3 -3
- data/spec/mongo/server/app_metadata_shared.rb +114 -8
- data/spec/mongo/server_selector/secondary_preferred_spec.rb +6 -6
- data/spec/runners/transactions/operation.rb +13 -2
- data/spec/shared/LICENSE +20 -0
- data/spec/shared/bin/get-mongodb-download-url +17 -0
- data/spec/shared/lib/mrss/child_process_helper.rb +80 -0
- data/spec/shared/lib/mrss/cluster_config.rb +221 -0
- data/spec/shared/lib/mrss/constraints.rb +346 -0
- data/spec/shared/lib/mrss/docker_runner.rb +265 -0
- data/spec/shared/lib/mrss/lite_constraints.rb +191 -0
- data/spec/shared/lib/mrss/server_version_registry.rb +115 -0
- data/spec/shared/lib/mrss/spec_organizer.rb +152 -0
- data/spec/shared/lib/mrss/utils.rb +15 -0
- data/spec/shared/share/Dockerfile.erb +231 -0
- data/spec/shared/shlib/distro.sh +73 -0
- data/spec/shared/shlib/server.sh +290 -0
- data/spec/shared/shlib/set_env.sh +128 -0
- data/spec/support/client_registry.rb +8 -4
- data/spec/support/client_registry_macros.rb +14 -5
- data/spec/support/spec_config.rb +12 -0
- data/spec/support/spec_setup.rb +48 -38
- data.tar.gz.sig +3 -1
- metadata +1005 -974
- metadata.gz.sig +0 -0
- data/spec/integration/size_limit_spec.rb~12e1e9c4f... RUBY-2242 Fix zlib compression (#2021) +0 -98
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41f37eb33cbd1ebf2c916187b4610eefd895885042eeb3949882ce0a8c4ed069
|
4
|
+
data.tar.gz: db734108633f8b5988eaa15de33165182233ba5064f0b805298747256fb578b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27c0c7ca84b6b7983767eb652f6aa5968362d8b42a4adf3eab3ee4a11fe4e74d36096b636436ac5075b31207470a67a8c5ecb00eac7f27a3889966ee30d84db9
|
7
|
+
data.tar.gz: 86c9fb09b3fb9c9512db2e7caed2f21ac2d53ee75f671d1cbcc92b89afa0d471cc1217552c3971ee9641f90b4c710692ab885c454f8701371726623e16114604
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/mongo/address.rb
CHANGED
@@ -286,7 +286,7 @@ module Mongo
|
|
286
286
|
rescue IOError, SystemCallError => e
|
287
287
|
raise Error::SocketError, "#{e.class}: #{e} (for #{self})"
|
288
288
|
rescue OpenSSL::SSL::SSLError => e
|
289
|
-
raise Error::SocketError, "#{e.class}: #{e} (for #{self})
|
289
|
+
raise Error::SocketError, "#{e.class}: #{e} (for #{self})"
|
290
290
|
end
|
291
291
|
end
|
292
292
|
end
|
@@ -61,9 +61,13 @@ module Mongo
|
|
61
61
|
%i(access_key_id secret_access_key host server_nonce).each do |arg|
|
62
62
|
value = instance_variable_get("@#{arg}")
|
63
63
|
if value.nil? || value.empty?
|
64
|
-
raise
|
64
|
+
raise Error::InvalidServerAuthResponse, "Value for '#{arg}' is required"
|
65
65
|
end
|
66
66
|
end
|
67
|
+
|
68
|
+
if host && host.length > 255
|
69
|
+
raise Error::InvalidServerAuthHost, "Value for 'host' is too long: #{@host}"
|
70
|
+
end
|
67
71
|
end
|
68
72
|
|
69
73
|
# @return [ String ] access_key_id The access key id.
|
@@ -98,8 +102,28 @@ module Mongo
|
|
98
102
|
|
99
103
|
# @return [ String ] region The region of the host, derived from the host.
|
100
104
|
def region
|
101
|
-
#
|
102
|
-
'
|
105
|
+
# Common case
|
106
|
+
if host == 'sts.amazonaws.com'
|
107
|
+
return 'us-east-1'
|
108
|
+
end
|
109
|
+
|
110
|
+
if host.start_with?('.')
|
111
|
+
raise Error::InvalidServerAuthHost, "Host begins with a period: #{host}"
|
112
|
+
end
|
113
|
+
if host.end_with?('.')
|
114
|
+
raise Error::InvalidServerAuthHost, "Host ends with a period: #{host}"
|
115
|
+
end
|
116
|
+
|
117
|
+
parts = host.split('.')
|
118
|
+
if parts.any? { |part| part.empty? }
|
119
|
+
raise Error::InvalidServerAuthHost, "Host has an empty component: #{host}"
|
120
|
+
end
|
121
|
+
|
122
|
+
if parts.length == 1
|
123
|
+
'us-east-1'
|
124
|
+
else
|
125
|
+
parts[1]
|
126
|
+
end
|
103
127
|
end
|
104
128
|
|
105
129
|
# Returns the scope of the request, per the AWS signature V4 specification.
|
data/lib/mongo/client.rb
CHANGED
@@ -104,6 +104,7 @@ module Mongo
|
|
104
104
|
:truncate_logs,
|
105
105
|
:user,
|
106
106
|
:wait_queue_timeout,
|
107
|
+
:wrapping_libraries,
|
107
108
|
:write,
|
108
109
|
:write_concern,
|
109
110
|
:zlib_compression_level,
|
@@ -375,6 +376,10 @@ module Mongo
|
|
375
376
|
# @option options [ String ] :user The user name.
|
376
377
|
# @option options [ Float ] :wait_queue_timeout The time to wait, in
|
377
378
|
# seconds, in the connection pool for a connection to be checked in.
|
379
|
+
# @option options [ Array<Hash> ] :wrapping_libraries Information about
|
380
|
+
# libraries such as ODMs that are wrapping the driver, to be added to
|
381
|
+
# metadata sent to the server. Specify the lower level libraries first.
|
382
|
+
# Allowed hash keys: :name, :version, :platform.
|
378
383
|
# @option options [ Hash ] :write Deprecated. Equivalent to :write_concern
|
379
384
|
# option.
|
380
385
|
# @option options [ Hash ] :write_concern The write concern options.
|
@@ -461,7 +466,18 @@ module Mongo
|
|
461
466
|
# construction
|
462
467
|
sdam_proc = options.delete(:sdam_proc)
|
463
468
|
|
464
|
-
|
469
|
+
# For gssapi service_name, the default option is given in a hash
|
470
|
+
# (one level down from the top level).
|
471
|
+
merged_options = default_options(options)
|
472
|
+
options.each do |k, v|
|
473
|
+
default_v = merged_options[k]
|
474
|
+
if Hash === default_v
|
475
|
+
v = default_v.merge(v)
|
476
|
+
end
|
477
|
+
merged_options[k] = v
|
478
|
+
end
|
479
|
+
options = merged_options
|
480
|
+
|
465
481
|
@options = validate_new_options!(options)
|
466
482
|
=begin WriteConcern object support
|
467
483
|
if @options[:write_concern].is_a?(WriteConcern::Base)
|
@@ -627,7 +643,7 @@ module Mongo
|
|
627
643
|
#
|
628
644
|
# @return [ BSON::Document ] The user-defined read preference.
|
629
645
|
# The document may have the following fields:
|
630
|
-
# - *:
|
646
|
+
# - *:mode* -- read preference specified as a symbol; valid values are
|
631
647
|
# *:primary*, *:primary_preferred*, *:secondary*, *:secondary_preferred*
|
632
648
|
# and *:nearest*.
|
633
649
|
# - *:tag_sets* -- an array of hashes.
|
@@ -1160,6 +1176,36 @@ module Mongo
|
|
1160
1176
|
raise ArgumentError, ":bg_error_backtrace option value must be true, false, nil or a positive integer: #{value}"
|
1161
1177
|
end
|
1162
1178
|
end
|
1179
|
+
|
1180
|
+
if libraries = options[:wrapping_libraries]
|
1181
|
+
unless Array === libraries
|
1182
|
+
raise ArgumentError, ":wrapping_libraries must be an array of hashes: #{libraries}"
|
1183
|
+
end
|
1184
|
+
|
1185
|
+
libraries = libraries.map do |library|
|
1186
|
+
Utils.shallow_symbolize_keys(library)
|
1187
|
+
end
|
1188
|
+
|
1189
|
+
libraries.each do |library|
|
1190
|
+
unless Hash === library
|
1191
|
+
raise ArgumentError, ":wrapping_libraries element is not a hash: #{library}"
|
1192
|
+
end
|
1193
|
+
|
1194
|
+
if library.empty?
|
1195
|
+
raise ArgumentError, ":wrapping_libraries element is empty"
|
1196
|
+
end
|
1197
|
+
|
1198
|
+
unless (library.keys - %i(name platform version)).empty?
|
1199
|
+
raise ArgumentError, ":wrapping_libraries element has invalid keys (allowed keys: :name, :platform, :version): #{library}"
|
1200
|
+
end
|
1201
|
+
|
1202
|
+
library.each do |key, value|
|
1203
|
+
if value.include?('|')
|
1204
|
+
raise ArgumentError, ":wrapping_libraries element value cannot include '|': #{value}"
|
1205
|
+
end
|
1206
|
+
end
|
1207
|
+
end
|
1208
|
+
end
|
1163
1209
|
end
|
1164
1210
|
|
1165
1211
|
# Validates all authentication-related options after they are set on the client
|
data/lib/mongo/collection.rb
CHANGED
@@ -278,8 +278,12 @@ module Mongo
|
|
278
278
|
}).execute(next_primary(nil, session), client: client)
|
279
279
|
end
|
280
280
|
rescue Error::OperationFailure => ex
|
281
|
-
|
282
|
-
|
281
|
+
# NamespaceNotFound
|
282
|
+
if ex.code == 26 || ex.code.nil? && ex.message =~ /ns not found/
|
283
|
+
false
|
284
|
+
else
|
285
|
+
raise
|
286
|
+
end
|
283
287
|
end
|
284
288
|
|
285
289
|
# Find documents in the collection.
|
@@ -400,7 +404,7 @@ module Mongo
|
|
400
404
|
View::ChangeStream.new(View.new(self, {}, options), pipeline, nil, options)
|
401
405
|
end
|
402
406
|
|
403
|
-
# Gets
|
407
|
+
# Gets an estimated number of matching documents in the collection.
|
404
408
|
#
|
405
409
|
# @example Get the count.
|
406
410
|
# collection.count(name: 1)
|
@@ -429,11 +433,13 @@ module Mongo
|
|
429
433
|
View.new(self, filter || {}, options).count(options)
|
430
434
|
end
|
431
435
|
|
432
|
-
# Gets the number of
|
433
|
-
# method, this will return the exact number of documents matching
|
436
|
+
# Gets the number of documents matching the query. Unlike the deprecated
|
437
|
+
# #count method, this will return the exact number of documents matching
|
438
|
+
# the filter (or exact number of documents in the collection, if no filter
|
439
|
+
# is provided) rather than an estimate.
|
434
440
|
#
|
435
|
-
#
|
436
|
-
#
|
441
|
+
# Use #estimated_document_count to retrieve an estimate of the number
|
442
|
+
# of documents in the collection using the collection metadata.
|
437
443
|
#
|
438
444
|
# @param [ Hash ] filter A filter for matching documents.
|
439
445
|
# @param [ Hash ] options Options for the operation.
|
@@ -454,15 +460,16 @@ module Mongo
|
|
454
460
|
View.new(self, filter, options).count_documents(options)
|
455
461
|
end
|
456
462
|
|
457
|
-
# Gets an estimate of the
|
463
|
+
# Gets an estimate of the number of documents in the collection using the
|
464
|
+
# collection metadata.
|
458
465
|
#
|
459
|
-
#
|
460
|
-
#
|
466
|
+
# Use #count_documents to retrieve the exact number of documents in the
|
467
|
+
# collection, or to count documents matching a filter.
|
461
468
|
#
|
462
469
|
# @param [ Hash ] options Options for the operation.
|
463
470
|
#
|
464
|
-
# @option opts :max_time_ms [ Integer ] The maximum amount of time to allow
|
465
|
-
# run.
|
471
|
+
# @option opts :max_time_ms [ Integer ] The maximum amount of time to allow
|
472
|
+
# the command to run for on the server.
|
466
473
|
# @option opts [ Hash ] :read The read preference options.
|
467
474
|
#
|
468
475
|
# @return [ Integer ] The document count.
|
@@ -566,6 +573,8 @@ module Mongo
|
|
566
573
|
# @param [ Array<Hash> ] documents The documents to insert.
|
567
574
|
# @param [ Hash ] options The insert options.
|
568
575
|
#
|
576
|
+
# @option options [ true | false ] :ordered Whether the operations
|
577
|
+
# should be executed in order.
|
569
578
|
# @option options [ Session ] :session The session to use for the operation.
|
570
579
|
#
|
571
580
|
# @return [ Result ] The database response wrapper.
|
data/lib/mongo/database/view.rb
CHANGED
@@ -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)
|
data/lib/mongo/database.rb
CHANGED
@@ -315,8 +315,20 @@ module Mongo
|
|
315
315
|
|
316
316
|
# Get the Grid "filesystem" for this database.
|
317
317
|
#
|
318
|
-
# @
|
319
|
-
#
|
318
|
+
# @param [ Hash ] options The GridFS options.
|
319
|
+
#
|
320
|
+
# @option options [ String ] :bucket_name The prefix for the files and chunks
|
321
|
+
# collections.
|
322
|
+
# @option options [ Integer ] :chunk_size Override the default chunk
|
323
|
+
# size.
|
324
|
+
# @option options [ String ] :fs_name The prefix for the files and chunks
|
325
|
+
# collections.
|
326
|
+
# @option options [ String ] :read The read preference.
|
327
|
+
# @option options [ Session ] :session The session to use.
|
328
|
+
# @option options [ Hash ] :write Deprecated. Equivalent to :write_concern
|
329
|
+
# option.
|
330
|
+
# @option options [ Hash ] :write_concern The write concern options.
|
331
|
+
# Can be :w => Integer|String, :fsync => Boolean, :j => Boolean.
|
320
332
|
#
|
321
333
|
# @return [ Grid::FSBucket ] The GridFS for the database.
|
322
334
|
#
|
@@ -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
|
+
# Raised when the server returned an invalid Host value in AWS auth.
|
19
|
+
class InvalidServerAuthHost < InvalidServerAuthResponse
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -97,7 +97,8 @@ module Mongo
|
|
97
97
|
# @since 2.1.1
|
98
98
|
# @deprecated
|
99
99
|
def retryable?
|
100
|
-
write_retryable? ||
|
100
|
+
write_retryable? ||
|
101
|
+
code.nil? && RETRY_MESSAGES.any?{ |m| message.include?(m) }
|
101
102
|
end
|
102
103
|
|
103
104
|
# Whether the error is a retryable error according to the modern retryable
|
@@ -110,11 +111,11 @@ module Mongo
|
|
110
111
|
#
|
111
112
|
# @since 2.4.2
|
112
113
|
def write_retryable?
|
113
|
-
|
114
|
-
|
114
|
+
write_retryable_code? ||
|
115
|
+
code.nil? && WRITE_RETRY_MESSAGES.any? { |m| message.include?(m) }
|
115
116
|
end
|
116
117
|
|
117
|
-
def write_retryable_code?
|
118
|
+
private def write_retryable_code?
|
118
119
|
if code
|
119
120
|
WRITE_RETRY_ERRORS.any? { |e| e[:code] == code }
|
120
121
|
else
|
@@ -122,7 +123,6 @@ module Mongo
|
|
122
123
|
false
|
123
124
|
end
|
124
125
|
end
|
125
|
-
private :write_retryable_code?
|
126
126
|
|
127
127
|
# Error codes and code names that should result in a failing getMore
|
128
128
|
# command on a change stream NOT being resumed.
|
data/lib/mongo/error.rb
CHANGED
@@ -190,6 +190,8 @@ require 'mongo/error/invalid_application_name'
|
|
190
190
|
require 'mongo/error/invalid_nonce'
|
191
191
|
require 'mongo/error/invalid_replacement_document'
|
192
192
|
require 'mongo/error/invalid_server_auth_response'
|
193
|
+
# Subclass of InvalidServerAuthResponse
|
194
|
+
require 'mongo/error/invalid_server_auth_host'
|
193
195
|
require 'mongo/error/invalid_server_preference'
|
194
196
|
require 'mongo/error/invalid_session'
|
195
197
|
require 'mongo/error/invalid_signature'
|
data/lib/mongo/grid/fs_bucket.rb
CHANGED
@@ -36,6 +36,43 @@ module Mongo
|
|
36
36
|
# @since 2.1.0
|
37
37
|
FILES_INDEX = { filename: 1, uploadDate: 1 }.freeze
|
38
38
|
|
39
|
+
# Create the GridFS.
|
40
|
+
#
|
41
|
+
# @example Create the GridFS.
|
42
|
+
# Grid::FSBucket.new(database)
|
43
|
+
#
|
44
|
+
# @param [ Database ] database The database the files reside in.
|
45
|
+
# @param [ Hash ] options The GridFS options.
|
46
|
+
#
|
47
|
+
# @option options [ String ] :bucket_name The prefix for the files and chunks
|
48
|
+
# collections.
|
49
|
+
# @option options [ Integer ] :chunk_size Override the default chunk
|
50
|
+
# size.
|
51
|
+
# @option options [ String ] :fs_name The prefix for the files and chunks
|
52
|
+
# collections.
|
53
|
+
# @option options [ String ] :read The read preference.
|
54
|
+
# @option options [ Session ] :session The session to use.
|
55
|
+
# @option options [ Hash ] :write Deprecated. Equivalent to :write_concern
|
56
|
+
# option.
|
57
|
+
# @option options [ Hash ] :write_concern The write concern options.
|
58
|
+
# Can be :w => Integer|String, :fsync => Boolean, :j => Boolean.
|
59
|
+
#
|
60
|
+
# @since 2.0.0
|
61
|
+
def initialize(database, options = {})
|
62
|
+
@database = database
|
63
|
+
@options = options.dup
|
64
|
+
=begin WriteConcern object support
|
65
|
+
if @options[:write_concern].is_a?(WriteConcern::Base)
|
66
|
+
# Cache the instance so that we do not needlessly reconstruct it.
|
67
|
+
@write_concern = @options[:write_concern]
|
68
|
+
@options[:write_concern] = @write_concern.options
|
69
|
+
end
|
70
|
+
=end
|
71
|
+
@options.freeze
|
72
|
+
@chunks_collection = database[chunks_name]
|
73
|
+
@files_collection = database[files_name]
|
74
|
+
end
|
75
|
+
|
39
76
|
# @return [ Collection ] chunks_collection The chunks collection.
|
40
77
|
#
|
41
78
|
# @since 2.0.0
|
@@ -133,43 +170,6 @@ module Mongo
|
|
133
170
|
file.id
|
134
171
|
end
|
135
172
|
|
136
|
-
# Create the GridFS.
|
137
|
-
#
|
138
|
-
# @example Create the GridFS.
|
139
|
-
# Grid::FSBucket.new(database)
|
140
|
-
#
|
141
|
-
# @param [ Database ] database The database the files reside in.
|
142
|
-
# @param [ Hash ] options The GridFS options.
|
143
|
-
#
|
144
|
-
# @option options [ String ] :fs_name The prefix for the files and chunks
|
145
|
-
# collections.
|
146
|
-
# @option options [ String ] :bucket_name The prefix for the files and chunks
|
147
|
-
# collections.
|
148
|
-
# @option options [ Integer ] :chunk_size Override the default chunk
|
149
|
-
# size.
|
150
|
-
# @option options [ String ] :read The read preference.
|
151
|
-
# @option options [ Session ] :session The session to use.
|
152
|
-
# @option options [ Hash ] :write Deprecated. Equivalent to :write_concern
|
153
|
-
# option.
|
154
|
-
# @option options [ Hash ] :write_concern The write concern options.
|
155
|
-
# Can be :w => Integer|String, :fsync => Boolean, :j => Boolean.
|
156
|
-
#
|
157
|
-
# @since 2.0.0
|
158
|
-
def initialize(database, options = {})
|
159
|
-
@database = database
|
160
|
-
@options = options.dup
|
161
|
-
=begin WriteConcern object support
|
162
|
-
if @options[:write_concern].is_a?(WriteConcern::Base)
|
163
|
-
# Cache the instance so that we do not needlessly reconstruct it.
|
164
|
-
@write_concern = @options[:write_concern]
|
165
|
-
@options[:write_concern] = @write_concern.options
|
166
|
-
end
|
167
|
-
=end
|
168
|
-
@options.freeze
|
169
|
-
@chunks_collection = database[chunks_name]
|
170
|
-
@files_collection = database[files_name]
|
171
|
-
end
|
172
|
-
|
173
173
|
# Get the prefix for the GridFS
|
174
174
|
#
|
175
175
|
# @example Get the prefix.
|
data/lib/mongo/index/view.rb
CHANGED
@@ -120,6 +120,9 @@ module Mongo
|
|
120
120
|
# a geo index.
|
121
121
|
# @option options [ Hash ] :partial_filter_expression Specify a filter for a partial
|
122
122
|
# index.
|
123
|
+
# @option options [ Boolean ] :hidden When :hidden is true, this index will
|
124
|
+
# exist on the collection but not be used by the query planner when
|
125
|
+
# executing operations.
|
123
126
|
# @option options [ String | Integer ] :commit_quorum Specify how many
|
124
127
|
# data-bearing members of a replica set, including the primary, must
|
125
128
|
# complete the index builds successfully before the primary marks
|
@@ -22,6 +22,21 @@ module Mongo
|
|
22
22
|
# @since 2.1.0
|
23
23
|
class Result < Operation::Result
|
24
24
|
|
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
|
+
|
25
40
|
# Get the namespace for the cursor.
|
26
41
|
#
|
27
42
|
# @example Get the namespace.
|
@@ -31,7 +46,7 @@ module Mongo
|
|
31
46
|
#
|
32
47
|
# @since 2.1.0
|
33
48
|
def namespace
|
34
|
-
Database::NAMESPACES
|
49
|
+
"#{@database_name}.#{Database::NAMESPACES}"
|
35
50
|
end
|
36
51
|
end
|
37
52
|
end
|