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

Mongoid save in identity map incomplete records

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.1.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      When using mongoid's identity map, and doing request that have a "only" or "without" statement, you end up having incomplete records in the identity_map. Here is some code example if you have a User collection with a username field:

      User.only(:_id).first                                                                                                                                                                    
      #=> #<User _id: joe, _type: nil, created_at: nil, updated_at: nil, username: nil>
      User.find('joe').username                                                                                                                                              
      #=> nil
      Mongoid::IdentityMap.clear                                                                                                                                                               
      #=> {}
      User.find('joe').username                                                                                                                                              
      => "joe"
      

      I have some code in preplay/mongoid@6235e72bcaeb62e55d01f33dedf224c999ec5c30 with a test and a fix and I can do a pull request if you think the way of fixing this bug is valid.

            Assignee:
            Unassigned Unassigned
            Reporter:
            slemiere slemiere
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: