-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
Ruby 2.0 introduces the named parameters feature.
When it's used in conjuction with varargs parameters, Ruby tries to
call the #to_hash method in the arguments given when invoking the
method.
Mongoid::Criteria doesn't implement #to_hash, but it has a #method_missing
that invokes entries, which fetches data from Mongodb. When this
is performed with a huge database, it causes Mongodb to hang
for a long time.
Sample code that triggers the problem:
class HugeCollection include Mongoid::Document end def a(*args, named_parameter: nil); end a(HugeCollection.all) # hangs forever
A simpler way of showing the issue is:
HugeCollection.all.anything_that_doesnt_exist # hangs forever