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

Mongoid save in identity map incomplete records

    XMLWordPrintable

    Details

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

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: