-
Type: Bug
-
Resolution: Duplicate
-
Priority: Minor - P4
-
None
-
Affects Version/s: 7.1.0
-
Component/s: Query
-
None
In Mongoid 7.1 passing an explicit nil to where is not allowed. When this is done, the following message is produced:
irb(main):002:0> Band.where(nil)
Traceback (most recent call last):
2: from (irb):1
1: from (irb):2:in `rescue in irb_binding'
Mongoid::Errors::CriteriaArgumentRequired ()
message:
Calling Criteria methods with nil arguments is not allowed.
summary:
Arguments to Criteria methods cannot be nil, and most Criteria methods require at least one argument. Only logical operations (and, or, nor and not), `all' and `where' can be called without arguments. The method that was called with nil argument was: where.
resolution:
Invoke Criteria methods with non-nil arguments or omit the respective invocations.
This message says that argument-less where is allowed as a special case, but it is not:
irb(main):003:0> Band.where Traceback (most recent call last): 2: from (irb):2 1: from (irb):3:in `rescue in irb_binding' ArgumentError (wrong number of arguments (given 0, expected 1))
There are two functions called `where` in the code base, and the one in Criteria has required an argument in 7.0 also thus this is not a compatibility break. However the exception message appears to suggest an API that does not exist and this should be remedied.
- duplicates
-
MONGOID-4804 Support argument-less where
- Closed
- related to
-
MONGOID-4854 Backward compatibility problem with Criteria::Queryable::Selectable#where with nil argument
- Closed