-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 7.0.2
-
Component/s: Query
Let's say we have a "seats" collection and seats can optionally belong to a user. If we query all the seats and eager load the users, but none of the seats actually belong to a user, Mongoid will still query the database for users where the id is
{"$in"=>[nil]}. I see something like this in the logs: {"find"=>"users", "filter"=>{"_id"=>{"$in"=>[nil]}}...
This change will skip the trip to the db if all the foreign keys are nil.
Submitted PR: https://github.com/mongodb/mongoid/pull/4621
- links to