When chaining two where criteria on the same field, former ones will be ignored, which should be a bug.
For example, User.where(role: 1).where(role: 2) now generates selector: {"role"=>2}, but the expected result should be selector: {"role"=>{"$in"=>[]}}.
Other examples:
User.where(role: 1).in(role: [2, 3]) generates selector: {"role"=>{"$in"=>[]}}, this is correct. But User.in(role: [2, 3]).where(role: 1) generates selector: {"role"=>1}, which should not be right.
When chaining two
where
criteria on the same field, former ones will be ignored, which should be a bug.For example,
User.where(role: 1).where(role: 2)
now generatesselector: {"role"=>2}
, but the expected result should beselector: {"role"=>{"$in"=>[]}}
.Other examples:
User.where(role: 1).in(role: [2, 3])
generatesselector: {"role"=>{"$in"=>[]}}
, this is correct. ButUser.in(role: [2, 3]).where(role: 1)
generatesselector: {"role"=>1}
, which should not be right.User.in(role: [1, 2]).in(role: [2, 3])
can correctly generateselector: {"role"=>{"$in"=>[2]}}
, butUser.where(:role.in => [1, 2]).where(:role.in => [2, 3])
generatesselector: {"role"=>{"$in"=>[2, 3]}}
.See mongoid/mongoid#4002