-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Query
-
None
Mongoid currently allows most Criteria methods to take no arguments, as well as nil arguments which are ignored. This means the following scope ends up with no conditions:
irb(main):009:0> Band.in.all.gt.ne.and.not.lte
=> #<Mongoid::Criteria
selector: {}
options: {}
class: Band
embedded: false>
... and allows for the following interesting call which also ends up a no-op:
irb(main):013:0> Band.ne(nil)
=> #<Mongoid::Criteria
selector: {}
options: {}
class: Band
embedded: false>
This ticket proposes to:
1. Require that most Criteria methods are provided arguments, such that Band.in raises an error.
2. Require that all arguments are not nil, such that Band.in(nil) raises an error.
Some operators will continue providing argument-free versions - Band.all and Band.not in particular since these are established use cases (first one is the classic no-op and the second one negates the following condition which wasn't provided yet). Band.all(nil) will become an error though.