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

Useless request during a build for a has_one relation in Mongoid 3

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

      Region has_one slug.

      foo = Region.new
      foo.build_slug
      MOPED: 127.0.0.1:27017 QUERY database=cms_engine_test collection=regions selector={"$query"=>

      {"_id"=>"50d1b0ed5b9e05c34300000d"}, "$orderby"=>{:_id=>1}} flags=[:slave_ok] limit=-1 skip=0 fields=nil (1.9884ms)
      foo.build_slug
      MOPED: 127.0.0.1:27017 QUERY database=cms_engine_test collection=regions selector={"$query"=>{"_id"=>"50d1b0ed5b9e05c34300000d"}

      , "$orderby"=>{:_id=>1}} flags=[:slave_ok] limit=-1 skip=0 fields=nil (0.2720ms)

      If the region is already saved, then there is no such request.

      The same happens during assignments:

      e = Slug.new
      foo.slug = e
      MOPED: 127.0.0.1:27017 QUERY database=cms_engine_test collection=regions selector={"$query"=>

      {"_id"=>"50d1b0ed5b9e05c34300000d"}

      , "$orderby"=>{:_id=>1}} flags=[:slave_ok] limit=-1 skip=0 fields=nil (0.5631ms)

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

              Created:
              Updated:
              Resolved: