[SERVER-56053] Cannot insert or run find commands on a collection "hello" Created: 12/Apr/21  Updated: 15/Apr/21  Resolved: 15/Apr/21

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

Type: Bug Priority: Major - P3
Reporter: Andrew Marshall Assignee: Judah Schvimer
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:

Insert command on a servless instance (Mongo Shell 4.9.0)

breaking-serverless-1-shard-00-01(mongos-4.9.0-rc0)[mongos] testing> show collections
breaking-serverless-1-shard-00-01(mongos-4.9.0-rc0)[mongos] testing> db["hello"].insertOne({})
uncaught exception: TypeError: db.hello.insertOne is not a function :
@(shell):1:1

Insert command on a local instance (Mongo Shell 4.2)

MacBook-Pro-130(mongod-4.2.1) testing> show collections
MacBook-Pro-130(mongod-4.2.1) testing> db["hello"].insertOne({})
{
  "acknowledged": true,
  "insertedId": ObjectId("6074a28f20a52b4a6c924d97")
}

Participants:

 Description   
  • Unable to run find command or insert command on a "hello" collection


 Comments   
Comment by Judah Schvimer [ 15/Apr/21 ]

Closing "Won't Fix" per Product Team recommendation.

Comment by Daniel Gottlieb (Inactive) [ 13/Apr/21 ]

You raise good points. I know we're going in the direction where the classic is shell is for server development while mongosh is for external use. judah.schvimer, I can't recall who owns the mongo shell. Do you know the right product person to raise andrew.marshall's questions with?

Comment by Andrew Marshall [ 13/Apr/21 ]

Sounds good, if this seems unnecessary to fix feel free to close this out.

Just curious, if any customers have shell scripts that run with a collection name of "hello" will this break them? Might be a small backwards compatability issue.

Comment by Daniel Gottlieb (Inactive) [ 13/Apr/21 ]

Hey andrew.marshall, I think this is an expected (if not exactly intended) result from changing the isMaster command to hello.

Demonstrating isMaster behaves the same way:

test> db.isMaster.insert({})
uncaught exception: TypeError: db.isMaster.insert is not a function :
@(shell):1:1

Reproducing the problem and verifying that db.getCollection("hello") is a suitable workaround:

test> db["hello"].insert({})
uncaught exception: TypeError: db.hello.insert is not a function :
@(shell):1:1
test> db.getCollection("hello").insert({})
WriteResult({ "nInserted" : 1 })
test> db.hello.find()
uncaught exception: TypeError: db.hello.find is not a function :
@(shell):1:1
test> db.getCollection("hello").find()
{ "_id" : ObjectId("6075ade2766c0118ae5db524") }
test> db.hello()
{
	"isWritablePrimary" : true,
	"topologyVersion" : {
		"processId" : ObjectId("6075ada18c1b22478f88d61f"),
		"counter" : NumberLong(0)
	},
	"maxBsonObjectSize" : 16777216,
	"maxMessageSizeBytes" : 48000000,
	"maxWriteBatchSize" : 100000,
	"localTime" : ISODate("2021-04-13T14:43:09.237Z"),
	"logicalSessionTimeoutMinutes" : 30,
	"connectionId" : 1,
	"minWireVersion" : 0,
	"maxWireVersion" : 12,
	"readOnly" : false,
	"ok" : 1
}

Generated at Thu Feb 08 05:38:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.