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

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

      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.

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

              Created:
              Updated:
              Resolved: