I have a simple class:
class Article include Mongoid::Document end
Given this query:
Article.in(id: ['55794bd9416472d4e8050000']) => #<Mongoid::Criteria selector: {"_id"=>{"$in"=>[BSON::ObjectId('55794bd9416472d4e8050000')]}} options: {} class: Article embedded: false>
If I double the in, I don't have the selector anymore:
Article.in(id: ['55794bd9416472d4e8050000']).in(id: ['55794bd9416472d4e8050000']) => #<Mongoid::Criteria selector: {"_id"=>{"$in"=>[]}} options: {} class: Article embedded: false>
Whereas if I pass an ObjectId to the second in, the selector is correct:
Article.in(id: ['55794bd9416472d4e8050000']).in(id: [BSON::ObjectId('55794bd9416472d4e8050000')]) => #<Mongoid::Criteria selector: {"_id"=>{"$in"=>[BSON::ObjectId('55794bd9416472d4e8050000')]}} options: {} class: Article embedded: false>
This should work with both syntax. I've dug a little and found that the ObjectId evolve occurs after the merge of the in values (old_val & new_val).