-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
Currently when $all criteria are combined the parameters are unioned, such that the combination is effectively an OR of the pieces rather than an AND:
irb(main):007:0> Band.all(foo:[2]).all(foo:[1]) => #<Mongoid::Criteria selector: {"foo"=>{"$all"=>[2, 1]}} options: {} class: Band embedded: false>
Because of this, all can alter the meaning of existing conditions in the criteria. In the below example where is changed to be respected only some of the time:
irb(main):016:0> Band.where(foo:3).all(foo:[2]) => #<Mongoid::Criteria selector: {"foo"=>{"$all"=>[3, 2]}} options: {} class: Band embedded: false>
Similarly to 4697, both conditions should be added as $all requirements (and the resulting query would be unsatisfiable in these examples).
- duplicates
-
MONGOID-4808 Require that Criteria strategies are explicitly requested, use $and behavior by default for all/in/nin
- Closed
- related to
-
MONGOID-4697 Implement Arel-style "and", "or" and "not" combination of scopes
- Closed