[SERVER-16198] Collection name shouldn't start or end with whitespace Created: 17/Nov/14  Updated: 17/Jan/23  Resolved: 22/May/15

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Adinoyi Omuya Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-5002 Change prohibited character sets in d... Closed
Related
Backwards Compatibility: Major Change
Participants:

 Description   

It seems odd that we allow collection names to start or end with whitespace characters.



 Comments   
Comment by Gianfranco Palumbo [ 16/Mar/15 ]

Collection names can also be a single whitespace character:

> db.getCollection(" ").insert({a:1})
WriteResult({ "nInserted" : 1 })
 
> db.getCollection(" ").find()
{ "_id" : ObjectId("55070ed5af00f033bbcd7206"), "a" : 1 }
 
> db.getCollection(" ").stats()
{
	"ns" : "test. ",
	"count" : 1,
	"size" : 48,
	"avgObjSize" : 48,
	"numExtents" : 1,
	"storageSize" : 8192,
	"lastExtentSize" : 8192,
	"paddingFactor" : 1,
	"paddingFactorNote" : "paddingFactor is unused and unmaintained in 3.0. It remains hard coded to 1.0 for compatibility only.",
	"userFlags" : 1,
	"capped" : false,
	"nindexes" : 1,
	"totalIndexSize" : 8176,
	"indexSizes" : {
		"_id_" : 8176
	},
	"ok" : 1
}
 
> db.version()
3.0.0

Sometimes MMS or other applications can error when they're trying to use these collections or pull operations from the oplog.

Generated at Thu Feb 08 03:40:16 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.