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

dup/clone method has an unexpected behavior when an 'id' field is present in the document

    XMLWordPrintable

Details

    • Task
    • Status: Closed
    • Resolution: Fixed
    • None
    • 3.1.0
    • None

    Description

      I have a problem duplicating documents. Some of my mongodb documents are containing a field `id{{ different from the real identifier }}_id`.

      {"_id" : ObjectId("4f243f6910d344d6400001cf"), "score" : 1.2, "id" : 290421 }

      When I duplicate documents with both `_id{{ and }}id{{ fields the duplicated record is saved with the value of the }}id{{ in the }}_id` field because of the aliasing resulting in:

      {"_id" : 290421, "score" : 1.2 }

      I don't know if the solution in this pull request is general enough, but it seems to make sense with the created aliasing.

      Sorry about the missing test but I didn't know how exactly create a test case for it.

      Attachments

        Activity

          People

            Unassigned Unassigned
            gicappa gicappa
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: