mongo 2.16.1 → 2.16.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b986d77f7607888a777a2a303a26a19d049d8caeca842afa9fc7623853a2dd2
4
- data.tar.gz: 588242ff13c6444dc448bbc6a3a426364853ec126462053d8b1bbca696451939
3
+ metadata.gz: 2708181386dc2ec2ea46e5ffe3f96967c3ea1e23dfd6f0d6d6ef15fbbde3877a
4
+ data.tar.gz: 017f64d2a62cc0215b6234cef24c8f0be74f75ed5fa688d32155047dbd56a7e0
5
5
  SHA512:
6
- metadata.gz: 343a0bdc5f04ffe468eb927e08d70dc58a2f08f7c88d8c530e4404eedb9ed218312b7860321351a05a345cf7b47189c2b28eb85e8dc362aba47b013c0ab62237
7
- data.tar.gz: d70cb255d44299be00c02921964d5eeff8534dbce108ddf0d72f3fb80244db20b861e224bbb51527ae2edc93f16cc0170fe9f999e4fc960015ef16a1fd849c22
6
+ metadata.gz: 2488655223e41488f275a7c8d1cd8b4c416a44a92c31cba63ab3fca21b27ec8f545b5feaa953aefb50035dbc68fe47db4f3aebb97fcb1de4e0e5fc6e3b186014
7
+ data.tar.gz: 671ae924600e906df4a2c209b7c491be445ef5c7c7030f6869fa991c53bd49a7cb728a718c8667b5c948022fb2912d45af437c1cf5b82f8b7ec0f0c849916045
checksums.yaml.gz.sig CHANGED
Binary file
@@ -115,11 +115,14 @@ module Mongo
115
115
  end
116
116
  command.update(view_options)
117
117
  command.update(Utils.slice_hash(options, :collation))
118
+
118
119
  # Read preference isn't simply passed in the command payload
119
- # (it may need to be converted to wire protocol flags)
120
- # so remove it here and hopefully it's handled elsewhere.
121
- # If not, RUBY-2706.
122
- command.delete(:read)
120
+ # (it may need to be converted to wire protocol flags).
121
+ # Ideally it should be removed here, however due to Mongoid 7
122
+ # using this method and requiring :read to be returned from it,
123
+ # we cannot do this just yet - see RUBY-2932.
124
+ #command.delete(:read)
125
+
123
126
  command.merge!(Options::Mapper.transform_documents(options, MAPPINGS))
124
127
  command
125
128
  end
@@ -248,7 +248,20 @@ module Mongo
248
248
  end
249
249
 
250
250
  def initial_query_op(session)
251
- Operation::MapReduce.new(map_reduce_spec(session))
251
+ spec = map_reduce_spec(session)
252
+ # Read preference isn't simply passed in the command payload
253
+ # (it may need to be converted to wire protocol flags).
254
+ # Passing it in command payload produces errors on at least
255
+ # 5.0 mongoses.
256
+ # In the future map_reduce_command should remove :read
257
+ # from its return value, however we cannot do this right now
258
+ # due to Mongoid 7 relying on :read being returned as part of
259
+ # the command - see RUBY-2932.
260
+ # Delete :read here for now because it cannot be sent to mongos this way.
261
+ spec = spec.dup
262
+ spec[:selector] = spec[:selector].dup
263
+ spec[:selector].delete(:read)
264
+ Operation::MapReduce.new(spec)
252
265
  end
253
266
 
254
267
  def valid_server?(server)
data/lib/mongo/version.rb CHANGED
@@ -20,5 +20,5 @@ module Mongo
20
20
  # The current version of the driver.
21
21
  #
22
22
  # @since 2.0.0
23
- VERSION = '2.16.1'.freeze
23
+ VERSION = '2.16.2'.freeze
24
24
  end
@@ -157,6 +157,13 @@ RSpec.configure do |config|
157
157
  end
158
158
 
159
159
  if SpecConfig.instance.active_support?
160
+ require "active_support/version"
161
+ if ActiveSupport.version >= Gem::Version.new(7)
162
+ # ActiveSupport wants us to require ALL of it all of the time.
163
+ # See: https://github.com/rails/rails/issues/43851,
164
+ # https://github.com/rails/rails/issues/43889, etc.
165
+ require 'active_support'
166
+ end
160
167
  require "active_support/time"
161
168
  require 'mongo/active_support'
162
169
  end
@@ -865,4 +865,20 @@ describe Mongo::Collection::View::MapReduce do
865
865
  end
866
866
  end
867
867
  end
868
+
869
+ describe '#map_reduce_spec' do
870
+ context 'when read preference is given' do
871
+ let(:view_options) do
872
+ { read: {mode: :secondary} }
873
+ end
874
+
875
+ context 'selector' do
876
+ # For compatibility with released versions of Mongoid, this method
877
+ # must return read preference under the :read key.
878
+ it 'contains read preference' do
879
+ map_reduce_spec[:selector][:read].should == {'mode' => :secondary}
880
+ end
881
+ end
882
+ end
883
+ end
868
884
  end
data/spec/runners/auth.rb CHANGED
@@ -48,7 +48,7 @@ module Mongo
48
48
  attr_reader :tests
49
49
 
50
50
  def initialize(test_path)
51
- @spec = YAML.load(File.read(test_path))
51
+ @spec = ::Utils.load_spec_yaml_file(test_path)
52
52
  @description = File.basename(test_path)
53
53
  end
54
54
 
@@ -32,7 +32,7 @@ module Mongo
32
32
  #
33
33
  # @since 2.6.0
34
34
  def initialize(test_path)
35
- @spec = YAML.load(File.read(test_path))
35
+ @spec = ::Utils.load_spec_yaml_file(test_path)
36
36
  @description = File.basename(test_path)
37
37
  @spec_tests = @spec['tests']
38
38
  @collection_name = @spec['collection_name']
data/spec/runners/cmap.rb CHANGED
@@ -40,7 +40,7 @@ module Mongo
40
40
  #
41
41
  # @param [ String ] test_path The path to the file.
42
42
  def initialize(test_path)
43
- @test = YAML.load(File.read(test_path))
43
+ @test = ::Utils.load_spec_yaml_file(test_path)
44
44
 
45
45
  @description = @test['description']
46
46
  @pool_options = ::Utils.snakeize_hash(process_options(@test['poolOptions']))
@@ -204,7 +204,7 @@ module Mongo
204
204
  #
205
205
  # @since 2.1.0
206
206
  def initialize(test_path)
207
- @spec = YAML.load(File.read(test_path))
207
+ @spec = ::Utils.load_spec_yaml_file(test_path)
208
208
  @data = @spec['data']
209
209
  @tests = @spec['tests']
210
210
  end
@@ -100,7 +100,7 @@ module Mongo
100
100
  #
101
101
  # @since 2.0.0
102
102
  def initialize(test_path)
103
- @spec = YAML.load(File.read(test_path))
103
+ @spec = ::Utils.load_spec_yaml_file(test_path)
104
104
  @description = File.basename(test_path)
105
105
  end
106
106
 
@@ -12,9 +12,7 @@ module Mongo
12
12
  #
13
13
  # @since 2.0.0
14
14
  def initialize(test_path)
15
- contents = File.read(test_path)
16
-
17
- @spec = YAML.load(contents)
15
+ @spec = ::Utils.load_spec_yaml_file(test_path)
18
16
  @description = File.basename(test_path)
19
17
  @data = BSON::ExtJSON.parse_obj(@spec['data'])
20
18
  @tests = @spec['tests']
@@ -100,7 +100,7 @@ module Mongo
100
100
  #
101
101
  # @since 2.1.0
102
102
  def initialize(test_path)
103
- @spec = YAML.load(File.read(test_path))
103
+ @spec = ::Utils.load_spec_yaml_file(test_path)
104
104
  @description = File.basename(test_path)
105
105
  @data = @spec['data']
106
106
  end
@@ -13,7 +13,7 @@ module ReadWriteConcernDocument
13
13
  #
14
14
  # @since 2.0.0
15
15
  def initialize(test_path)
16
- @spec = YAML.load(File.read(test_path))
16
+ @spec = ::Utils.load_spec_yaml_file(test_path)
17
17
  @description = File.basename(test_path)
18
18
  end
19
19
 
data/spec/runners/sdam.rb CHANGED
@@ -77,7 +77,7 @@ module Mongo
77
77
  #
78
78
  # @since 2.0.0
79
79
  def initialize(test_path)
80
- @test = YAML.load(File.read(test_path))
80
+ @test = ::Utils.load_spec_yaml_file(test_path)
81
81
  @description = @test['description']
82
82
  @uri_string = @test['uri']
83
83
  @uri = URI.new(uri_string)
@@ -64,7 +64,7 @@ module Mongo
64
64
  #
65
65
  # @since 2.0.0
66
66
  def initialize(test_path)
67
- @test = YAML.load(File.read(test_path))
67
+ @test = ::Utils.load_spec_yaml_file(test_path)
68
68
  @description = "#{@test['topology_description']['type']}: #{File.basename(test_path)}"
69
69
  @heartbeat_frequency = @test['heartbeatFrequencyMS'] / 1000 if @test['heartbeatFrequencyMS']
70
70
  @read_preference = @test['read_preference']
@@ -28,7 +28,7 @@ module Mongo
28
28
  #
29
29
  # @since 2.0.0
30
30
  def initialize(test_path)
31
- @test = YAML.load(File.read(test_path))
31
+ @test = ::Utils.load_spec_yaml_file(test_path)
32
32
  @description = "#{File.basename(test_path)}: avg_rtt_ms: #{@test['avg_rtt_ms']}, new_rtt_ms: #{@test['new_rtt_ms']}," +
33
33
  " new_avg_rtt: #{@test['new_avg_rtt']}"
34
34
  @average_rtt = @test['avg_rtt_ms'] == 'NULL' ? nil : @test['avg_rtt_ms'].to_f / 1000
@@ -6,7 +6,7 @@ module Unified
6
6
  class TestGroup
7
7
  def initialize(path, **opts)
8
8
  if String === path
9
- data = YAML.load(File.read(path))
9
+ data = ::Utils.load_spec_yaml_file(path)
10
10
  else
11
11
  data = path
12
12
  end
@@ -15,7 +15,7 @@ describe 'DNS Seedlist Discovery' do
15
15
 
16
16
  SEED_LIST_DISCOVERY_TESTS.each do |test_path|
17
17
 
18
- spec = YAML.load(File.read(test_path))
18
+ spec = ::Utils.load_spec_yaml_file(test_path)
19
19
 
20
20
  test = Mongo::ConnectionString::Test.new(spec)
21
21
 
@@ -595,4 +595,35 @@ module Utils
595
595
  end
596
596
  end
597
597
  end
598
+
599
+ module_function def load_spec_yaml_file(path)
600
+ permitted_classes = [
601
+ BigDecimal,
602
+ Date,
603
+ Time,
604
+ Range,
605
+ Regexp,
606
+ Symbol,
607
+ BSON::Binary,
608
+ BSON::Code,
609
+ BSON::CodeWithScope,
610
+ BSON::DbPointer,
611
+ BSON::Decimal128,
612
+ BSON::Int32,
613
+ BSON::Int64,
614
+ BSON::MaxKey,
615
+ BSON::MinKey,
616
+ BSON::ObjectId,
617
+ BSON::Regexp::Raw,
618
+ BSON::Symbol::Raw,
619
+ BSON::Timestamp,
620
+ BSON::Undefined,
621
+ ]
622
+ if RUBY_VERSION < '2.6'
623
+ YAML.safe_load(File.read(path), permitted_classes, [], true)
624
+ else
625
+ # Here we have Ruby 2.6+ that supports the new syntax of `safe_load``.
626
+ YAML.safe_load(File.read(path), permitted_classes: permitted_classes, aliases: true)
627
+ end
628
+ end
598
629
  end
data.tar.gz.sig CHANGED
Binary file