-
Type: Bug
-
Resolution: Duplicate
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
I've met the problem that the later expression is overriding precedent other '$and' expressions if expressions are appeared in the specific oder like this:
# this is OK Band.where(id: 1).where(id: 2).selector => {"_id"=>1, "$and"=>[{"_id"=>2}]} # this is also OK Band.and({year: {'$in' => [2020]}}, {year: {'$in' => [2020]}}).selector => {"year"=>{"$in"=>[2020]}, "$and"=>[{"year"=>{"$in"=>[2020]}}]} # But this is bad, I think Band.where(id: 1).and({year: {'$in' => [2020]}}, {year: {'$in' => [2020]}}).where(id: 2).selector => {"_id"=>1, "year"=>{"$in"=>[2020]}, "$and"=>[{"_id"=>2}]}
This is happening from version 7.1
- duplicates
-
MONGOID-5183 Existing `$and` clause in query is overwritten by `where` condition
- Closed
-
MONGOID-5236 Add Feature Flag: Existing `$and` clause in query is overwritten by `where` condition
- Closed