Details
-
Bug
-
Status: Closed
-
Major - P3
-
Resolution: Duplicate
-
5.0.2
-
None
-
None
-
QO 2021-09-06
Description
Due to the changes in DRIVERS-1437, estimatedDocumentCount no longer works on views on 5.0+. For example:
>>> db = client.test |
>>> db.view.drop()
|
>>> db.create_collection('view', viewOn='coll') |
>>> db.view.count_documents({})
|
0
|
>>> db.view.estimated_document_count()
|
Traceback (most recent call last):
|
File "<stdin>", line 1, in <module> |
File "/Users/shane/git/mongo-python-driver/pymongo/collection.py", line 1495, in estimated_document_count |
return self.__database.client._retryable_read( |
File "/Users/shane/git/mongo-python-driver/pymongo/mongo_client.py", line 1384, in _retryable_read |
return func(session, server, sock_info, slave_ok) |
File "/Users/shane/git/mongo-python-driver/pymongo/collection.py", line 1484, in _cmd |
result = self._aggregate_one_result( |
File "/Users/shane/git/mongo-python-driver/pymongo/collection.py", line 1436, in _aggregate_one_result |
result = self._command( |
File "/Users/shane/git/mongo-python-driver/pymongo/collection.py", line 221, in _command |
return sock_info.command( |
File "/Users/shane/git/mongo-python-driver/pymongo/pool.py", line 718, in command |
return command(self, dbname, spec, slave_ok, |
File "/Users/shane/git/mongo-python-driver/pymongo/network.py", line 158, in command |
helpers._check_command_response(
|
File "/Users/shane/git/mongo-python-driver/pymongo/helpers.py", line 167, in _check_command_response |
raise OperationFailure(errmsg, code, response, max_wire_version) |
pymongo.errors.OperationFailure: PlanExecutor error during aggregation :: caused by :: Namespace test.view is a view, not a collection, full error: {'ok': 0.0, 'errmsg': 'PlanExecutor error during aggregation :: caused by :: Namespace test.view is a view, not a collection', 'code': 166, 'codeName': 'CommandNotSupportedOnView', '$clusterTime': {'clusterTime': Timestamp(1630345764, 1), 'signature': {'hash': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 'keyId': 0}}, 'operationTime': Timestamp(1630345764, 1)} |
Attachments
Issue Links
- causes
-
PYTHON-2885 Namespace xyz is a view, not a collection
-
- Closed
-
- duplicates
-
SERVER-63850 Add the count command to API version 1
-
- Closed
-
- is depended on by
-
PYTHON-2885 Namespace xyz is a view, not a collection
-
- Closed
-
- is related to
-
PYTHON-2853 Document performance implications of using count_documents vs estimated_document_count
-
- Backlog
-
- related to
-
DRIVERS-2184 estimatedDocumentCount should use count command for 5.0.x + not-stable API
-
- Closed
-