Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2701

Mongoid 3 has_one relation unnecessary request.

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 3.1.0
    • Component/s: None
    • Labels:

      Description

      This bug exists only in Mongoid 3 (testing on 3.0.17). Mongoid 2 doesn't have the bug.

      Route belongs_to AirportRoute
      AirportRoute has_one Route

      >> foo = Route.first
      MOPED: 127.0.0.1:27017 QUERY database=gocheap_development collection=routes selector={"$query"=>{}, "$orderby"=>{:_id=>1}} flags=[:slave_ok] limit=-1 skip=0 batch_size=nil fields=nil (0.6602ms)
      #<Route _id: 50190e164c4c6c958866b1f7 ... >

      >> foo.airport_route
      MOPED: 127.0.0.1:27017 QUERY database=gocheap_development collection=airport_routes selector={"$query"=>

      {"_id"=>"50d85fcabdaa57462e000001"}

      , "$orderby"=>{:_id=>1}} flags=[:slave_ok] limit=-1 skip=0 batch_size=nil fields=nil (0.7024ms)
      MOPED: 127.0.0.1:27017 QUERY database=gocheap_development collection=routes selector={"$query"=>

      {"airport_route_id"=>"50d85fcabdaa57462e000001"}

      , "$orderby"=>{:_id=>1}} flags=[:slave_ok] limit=-1 skip=0 batch_size=nil fields=nil (0.7691ms)
      #<AirportRoute _id: 50d85fcabdaa57462e000001 ... >

      The last query to the routes collection is unnecessary, as we already have the route.

        Attachments

          Activity

            People

            Assignee:
            durran Durran Jordan
            Reporter:
            exoth Yuriy Trofimenko
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: