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

Value missing in case of Duplicate Field Name Insertion

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Trivial - P5 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} )

      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@mongodb.com Kelsey Schubert
            Reporter:
            2k.pravin@gmail.com pravin dwiwedi
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: