Permalink
Browse files

Allow read preferences in URI with no replica set.

[ RUBY-563 ]
  • Loading branch information...
1 parent 533f411 commit 1a413d96bb3cd2d6fac3eddf55f1d770d2abc255 @durran durran committed with TylerBrock Mar 11, 2013
Showing with 6 additions and 6 deletions.
  1. +1 −1 lib/mongo/util/uri_parser.rb
  2. +5 −5 test/functional/uri_test.rb
@@ -220,7 +220,7 @@ def connection_options
opts[:pool_size] = @pool_size
end
- if @readpreference && replicaset?
+ if @readpreference
opts[:read] = @readpreference
end
@@ -165,14 +165,14 @@ def test_read_preference_connection_options
assert_equal :nearest, parser.connection_options[:read]
end
- def test_read_preference_connection_options_prefers_preference_over_slaveok
- parser = Mongo::URIParser.new("mongodb://localhost:27018?replicaset=test&readPreference=nearest&slaveok=true")
+ def test_read_preference_connection_options_with_no_replica_set
+ parser = Mongo::URIParser.new("mongodb://localhost:27018?readPreference=nearest")
assert_equal :nearest, parser.connection_options[:read]
end
- def test_read_preference_when_no_replica_set
- parser = Mongo::URIParser.new("mongodb://localhost:27018?readPreference=nearest")
- assert_nil parser.connection_options[:read]
+ def test_read_preference_connection_options_prefers_preference_over_slaveok
+ parser = Mongo::URIParser.new("mongodb://localhost:27018?replicaset=test&readPreference=nearest&slaveok=true")
+ assert_equal :nearest, parser.connection_options[:read]
end
def test_connection_when_sharded_with_no_options

0 comments on commit 1a413d9

Please sign in to comment.