Skip to content

Instantly share code, notes, and snippets.

@p-mongo
Created November 16, 2018 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save p-mongo/c6867bad3244a2981ac8bcb486c48768 to your computer and use it in GitHub Desktop.
Save p-mongo/c6867bad3244a2981ac8bcb486c48768 to your computer and use it in GitHub Desktop.
diff --git a/lib/mongoid/persistence_context.rb b/lib/mongoid/persistence_context.rb
index e7c77ed626..9efa479589 100644
--- a/lib/mongoid/persistence_context.rb
+++ b/lib/mongoid/persistence_context.rb
@@ -150,9 +150,15 @@ def __evaluate__(name)
end
def client_options
- @client_options ||= options.select do |k, v|
- Mongo::Client::VALID_OPTIONS.include?(k.to_sym)
- end
+ @client_options ||= begin
+ opts = options.select do |k, v|
+ Mongo::Client::VALID_OPTIONS.include?(k.to_sym)
+ end
+ if opts[:read].is_a?(Symbol)
+ opts[:read] = {mode: opts[:read]}
+ end
+ opts
+ end
end
def database_name_option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment