-
Type:
Bug
-
Resolution: Done
-
Priority:
Major - P3
-
Affects Version/s: 2.4.1
-
Component/s: None
-
None
-
Environment:mac/linux, mongo 2.4.1/mongoid 6.0.3/5.1.2
-
None
-
None
-
None
-
None
-
None
-
None
-
None
I believe there is an inconsistency between what you expect for the :connect and what is indicated in the doc for mongoid.
In (mongo ruby) topology.rb, you have
OPTIONS = {
replica_set: ReplicaSet,
sharded: Sharded,
direct: Single
}.freeze
and
def initial(seeds, monitoring, options)
if options.has_key?(:connect)
OPTIONS.fetch(options[:connect]).new(options, monitoring, seeds)
elsif options.has_key?(:replica_set)
ReplicaSet.new(options, monitoring, options)
else
Unknown.new(options, monitoring, seeds)
end
end
On the other side, mongoid doc says that the yaml file can/should contain
...
# Force the driver to connect in a specific way instead of auto-
# discovering. Can be one of: :direct, :replica_set, :sharded. Set to :
# when connecting to hidden members of a replica set.
connect: :direct
...
The issue is that :direct can/will be loaded as a string (after check, it probably depends on your YAML parser, but I haven't found any recommendations), and so will never be found in OPTIONS.
Using HashWithIndifferentAccess means that you will get a connect (Symbol), but will not load its value (:direct) as a symbol. Symbolizing the value found will ensure that it's tested as a symbol. Having a default option for fetch might be also a nice touch, unsure though.
- is related to
-
RUBY-1307 Force symbolized config keys
-
- Closed
-