[PyMongo] max_wire_version for listCollections command

60 views
Skip to first unread message

Colin B

unread,
Aug 27, 2018, 6:06:16 PM8/27/18
to mongodb-user
Hi,

Using MongoDB documentation I cannot find the minimum wire version for listCollections command.

Looking at PyMongo code it appears that listCollections command is only sent if max wire version is higher than 2.

def _list_collections(self, sock_info, slave_okay, session=None, **kwargs):
   
"""Internal listCollections helper."""

    coll = self["$cmd"]
   
if sock_info.max_wire_version > 2:
       
cmd = SON([("listCollections", 1),
                   
("cursor", {})])


I would like to know the reason for this restriction.

When I tried the command against Microsoft Azure Cosmos DB (Mongo), having a max wire version set to 2, it returns the collection names so I am not sure what the issue is.

It can also be an error on Microsoft implementation of the MongoDB API (would not be the first time) but I'd rather be sure before entering any issue.

Thanks again,

Bernie Hackett

unread,
Aug 28, 2018, 11:04:23 AM8/28/18
to mongodb-user
> When I tried the command against Microsoft Azure Cosmos DB (Mongo)

CosmosDB is _not_ MongoDB. It is a completely different database with a MongoDB wire protocol interface of some sort sitting in front of it. We don't support it in our drivers and you are likely to find a lot of incompatibilities. 

Bernie Hackett

unread,
Aug 28, 2018, 11:11:02 AM8/28/18
to mongodb-user
To answer your original question, wire version 2 matches the server release that introduced the listCollections command (3.0)

Colin B

unread,
Aug 28, 2018, 1:56:21 PM8/28/18
to mongodb-user
Thanks a lot for your answer,

If I understand you properly, if the server version is 3.2.0 (what Microsoft is sending when using CosmosDB), then maxWireVersion should be higher than 2 (what Microsoft is sending when using CosmosDB)?
Reply all
Reply to author
Forward
0 new messages