mongodb/mongo-ruby-driver — pull request #198 by nelhage (2013-05-15 22:11:20+00:00)
Title: mongos expects read preferences to be strings, not symbols.

This should actually fix RUBY-542. Without this, using read
preferences with a mongos cluster that's backed by replica sets will
error with

wrong type for field (mode) 14 != 2

This is raised by _extraReadPref in dbclient_rs.cpp, when it does:

const string mode = prefDoc["mode"].String();

BSON type 14 (0xE) is the (deprecated) Symbol type, and type 2 is
String, so this indicates that mongos is getting a symbol when it
expects a string.

The sharding tests passed either way because they don't actually
construct replica sets for the shards, and _extractReadPref is only
used by DBClientReplicaSet. Thus, the $readPreference field passed to
mongos is completely ignored by the test mongoS, and not even parsed.

Passes `test:sharded_cluster` on 1.8, 1.9, 2.0, and jruby.