-
Type: Bug
-
Resolution: Duplicate
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Ruby Drivers
Mongoid 9 introduced a regression where passing lambdas to store_in options raises an error when trying to persist a document. This is explicitly mentioned in the docs as a feature (https://www.mongodb.com/docs/mongoid/current/reference/persistence-configuration/#document-storage).
Sample code
# file: store_in_proc_issue.rb require "bundler/inline" gemfile do source "https://rubygems.org" # Include desired version when testing # gem "mongoid", "~> 8.0" # gem "mongoid", "~> 9.0" end Mongoid.configure do |config| config.clients.default = { hosts: ["localhost:27017"], database: "foo", } end class Foo include Mongoid::Document store_in database: ->{ "foo" }, client: ->{ :bar } end puts "Mongoid: #{Mongoid::VERSION}" puts Foo.create
=>
Mongoid: 8.1.5 #<Foo:0x00000001255bf240>
Mongoid: 9.0.1 :bar :bar :bar /mongo-2.20.1/lib/mongo/operation/result.rb:364:in `raise_operation_failure': [73:InvalidNamespace]: '.' is an invalid character in the database name: #<Proc:0x000000012499b928 mongoid_proc_issue.rb:21 (lambda)> (on localhost:27017, legacy retry, attempt 1) (Mongo::Error::OperationFailure)
I'm pretty sure the mongo backtrace is a red herring and the issue stems from mongoid.
- duplicates
-
MONGOID-5819 Mongoid 9.x incompatibility with store_in procs
- Closed