Value missing in case of Duplicate Field Name Insertion

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Trivial - P5
    • None
    • Affects Version/s: 3.3.4
    • Component/s: Querying
    • None
    • ALL
    • 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} )
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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?

              Assignee:
              Kelsey Schubert
              Reporter:
              pravin dwiwedi
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: