根据关于 Explicit Merging ("Queryable#in - defaults to intersect") 的mongoid 文档,我希望得到以下查询:
Contact.in(id: ['a', 'b']).in(id: ['b', 'c'])
导致这样的事情:
=> #<Mongoid::Criteria
selector: {"_id"=>{"$in"=>["b"]}}
options: {}
class: Contact
embedded: false>
但相反,我得到了所有可以想象的情况的覆盖:
[1] pry(main)> Contact.in(id: ['a', 'b']).in(id: ['b', 'c'])
=> #<Mongoid::Criteria
selector: {"_id"=>{"$in"=>["b", "c"]}}
options: {}
class: Contact
embedded: false>
[2] pry(main)> Contact.in(id: ['a', 'b']).intersect.in(id: ['b', 'c'])
=> #<Mongoid::Criteria
selector: {"_id"=>{"$in"=>["b", "c"]}}
options: {}
class: Contact
embedded: false>
[3] pry(main)> Contact.in(id: ['a', 'b']).union.in(id: ['b', 'c'])
=> #<Mongoid::Criteria
selector: {"_id"=>{"$in"=>["b", "c"]}}
options: {}
class: Contact
embedded: false>
难道我做错了什么?