The shell trims whitespace when displaying find results, but the data is correctly inserted and can be queried appropriately:
From here: http://dba.stackexchange.com/questions/27200/preserving-whitespace-in-mongodb-values
Quick test to show it happening:
// insert a string with some leading and trailing spaces mongos> db.test.insert({"name":" adam "}) // now do a find for that string (success) mongos> db.test.find({"name":" adam "}) { "_id" : ObjectId("50814e5c2a17d922cd25974f"), "name" : " adam " } // however, the display is off - only one leading/trailing space shown // just to be sure, search for the output again (no results) mongos> db.test.find({"name":" adam "}) mongos>
- is duplicated by
-
SERVER-6893 Shell tojson() shouldn't compact multiple adjacent spaces to one.
- Closed