We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bfdaa99 commit 6407218Copy full SHA for 6407218
lib/mongoid/association/referenced/has_and_belongs_to_many.rb
@@ -263,8 +263,12 @@ def with_ordering(criteria)
263
264
def query_criteria(id_list)
265
crit = relation_class.criteria
266
- crit = crit.apply_scope(scope)
267
- crit = crit.all_of(primary_key => {"$in" => id_list || []})
+ crit = if id_list
+ crit = crit.apply_scope(scope)
268
+ crit.all_of(primary_key => { "$in" => id_list })
269
+ else
270
+ crit.none
271
+ end
272
with_ordering(crit)
273
end
274
spec/mongoid/association/referenced/has_and_belongs_to_many/buildable_spec.rb
@@ -111,7 +111,7 @@
111
112
113
let(:criteria) do
114
- Preference.all_of("_id" => { "$in" => [] })
+ Preference.none
115
116
117
it "a criteria object" do
0 commit comments