[SERVER-3879] Mongo allows for creation of collections named the same as functions, it's confusing Created: 15/Sep/11  Updated: 01/Apr/13  Resolved: 01/Apr/13

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

Type: Bug Priority: Minor - P4
Reporter: Kenny Gorman 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-2770 Any collection name on db w/correspon... Closed
is duplicated by SERVER-8906 db.version command overloads any quer... Closed
Operating System: ALL
Participants:

 Description   

> show collections
contact
fs.chunks
group
system.indexes
system.profile
> db.group.stats()
Thu Sep 15 12:38:48 TypeError: db.group.stats is not a function (shell):1
> x=db.getCollection("group")
platform_addressbook.group
> x.stats()
{
	"ns" : "platform_addressbook.group",
	"count" : 15863,
	"size" : 1899448,
	"avgObjSize" : 119.74078043245288,
	"storageSize" : 2531584,
	"numExtents" : 5,
	"nindexes" : 3,
	"lastExtentSize" : 1900544,
	"paddingFactor" : 1.0099999999999996,
	"flags" : 0,
	"totalIndexSize" : 3268608,
	"indexSizes" : {
		"_id_" : 1171456,
		"userId_1_type_1" : 1171456,
		"userId_-1_name_-1" : 925696
	},
	"ok" : 1
}
>
> db.group
function (parmsObj) {
    var ret = this.runCommand({group:this._groupFixParms(parmsObj)});
    if (!ret.ok) {
        throw "group command failed: " + tojson(ret);
    }
    return ret.retval;
}
 



 Comments   
Comment by Eliot Horowitz (Inactive) [ 16/Sep/11 ]

Definitely odd.
Only way around is db.getCollection( "group" )

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