Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-24048

Value missing in case of Duplicate Field Name Insertion

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Trivial - P5
    • Resolution: Works as Designed
    • Affects Version/s: 3.3.4
    • Fix Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      Step1- db.myCol.insert(

      {visitor_id:1,name:"hello",name:"hello1"}

      )
      Step2- db.myCol.find(

      {visitor_id:1}

      )

      Show
      Step1- db.myCol.insert( {visitor_id:1,name:"hello",name:"hello1"} ) Step2- db.myCol.find( {visitor_id:1} )

      Description

      I have inserted a document with duplicate field name. While find, it is not giving both field. it is giving the last field only. This may mislead to the developers. If it is not giving the both fields then it should not allow to insert duplicate fields.

      db.myCol.insert(

      {visitor_id:1,name:"hello",name:"hello1"}

      )
      Query1-
      db.myCol.find(

      {visitor_id:1}

      )
      result--

      { "_id" : ObjectId("572a2b7052c7b442f853c135"), "visitor_id" : 1, "name" : "hello1" }

      Query2-db.myCol.find(

      {visitor_id:1,name:"hello"}

      )
      result--
      None
      Query3- db.myCol.find(

      {visitor_id:1,name:"hello1"}

      )
      result--

      { "_id" : ObjectId("572a2b7052c7b442f853c135"),"visitor_id" : 1, "name" : "hello1" }

      So in either of the query only last field(from duplicate) appears. Why is it not showing both the fields?

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: