Skip eager loading query if all keys are nil

XMLWordPrintableJSON

    • None
    • None
    • None
    • None
    • None
    • None

      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

              Assignee:
              Oleg Pudeyev (Inactive)
              Reporter:
              Oleg Pudeyev (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: