-
Type: Bug
-
Resolution: Duplicate
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
In the Collection#with method, only 4 options are allowed to get changed:
CHANGEABLE_OPTIONS = [ :read, :read_concern, :write, :write_concern ]
Now, write is a deprecated option that is equivalent to write_concern, and I think whoever wrote these options believed that read is a deprecated option equivalent to read_concern. Unfortunately, it seems that this is not true. I have found that whenever read is used, the mode option is used, which is a read_preference option. Additionally I found the following docstring:
# @option options [ Hash ] :read The read preference options. The hash # may have the following items: # - *:mode* -- read preference specified as a symbol; valid values are # *:primary*, *:primary_preferred*, *:secondary*, *:secondary_preferred* # and *:nearest*. # - *:tag_sets* -- an array of hashes. # - *:local_threshold*.
which pretty explicitly states that read is a read preference option.
Additionally this code snipped implies that read and read_preference are equivalent: https://github.com/mongodb/mongo-ruby-driver/blob/master/lib/mongo/collection.rb#L168-L170
The docstring for #with also says the following:
Provides a new collection with either a new read preference or new write concern merged over the existing read preference / write concern.
So the CHANGEABLE_OPTIONS are clearly wrong, and the read_concern should be replaced with read_preference.