Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-955

printjson(...) will elide results if there are too many

    • Needed
    • Hide

      printjson will print the whole input in the Shell BSON format (i.e.

      { _id: ObjectId("abc...") }

      ) ignoring inspectDepth config option

      Show
      printjson will print the whole input in the Shell BSON format (i.e. { _id: ObjectId("abc...") } ) ignoring inspectDepth config option
    • Iteration Octopus

      Problem Statement/Rationale

      What is going wrong?
      Using printjson in mongosh will elide results after some point

        { _id: ObjectId("611a70f8f594232ec6f1147f"), a: 96 },
        { _id: ObjectId("611a70f8f594232ec6f11480"), a: 97 },
        { _id: ObjectId("611a70f8f594232ec6f11481"), a: 98 },
        { _id: ObjectId("611a70f8f594232ec6f11482"), a: 99 },
        ... 100 more items
      ]
      

      Steps to Reproduce

      How could an engineer replicate the issue you’re reporting?

      database = db.getSiblingDB("test")
      coll = database.getCollection("test_col")
      
      coll.drop()
      
      for (let i = 0; i < 200; i++) {
        coll.insertOne({a:i})
      }
      
      results = coll.find().toArray()
      
      printjson(results)
      

      Expected Results

      What do you expect to happen?
      printjson should print all 200 items.

      Actual Results

      What do you observe is happening?
      printjson only prints 100 items and truncates the rest.

      Additional Notes

      Any additional information that may be useful to include.
      print(JSON.stringify(results)) will print all items but remove the wrapping ObjectId(...)

      {"_id":"611a7117ba03c5c77dfa664b","a":101}
      

      print(EJSON.stringify(results)) will print all items but will replace ObjectId with an key value pair "$oid": <ObjectId>

      {"_id":{"$oid":"611a7117ba03c5c77dfa6678"},"a":146}
      

            Assignee:
            sergey.petushkov@mongodb.com Sergey Petushkov
            Reporter:
            edwin.zhou@mongodb.com Edwin Zhou
            Votes:
            5 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: