File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -36,17 +36,20 @@ def count_documents(
3636 kwargs ["hint" ] = hint
3737 if collation is not None :
3838 kwargs ["collation" ] = collation
39- kwargs ["session" ] = connection ._get_session ()
4039
4140 # count_documents appeared in pymongo 3.7
4241 if PYMONGO_VERSION >= (3 , 7 ):
4342 try :
4443 if not filter and set (kwargs ) <= {"max_time_ms" }:
4544 # when no filter is provided, estimated_document_count
4645 # is a lot faster as it uses the collection metadata
47- return collection .estimated_document_count (** kwargs )
46+ return collection .estimated_document_count (
47+ session = connection ._get_session (), ** kwargs
48+ )
4849 else :
49- return collection .count_documents (filter = filter , ** kwargs )
50+ return collection .count_documents (
51+ filter = filter , session = connection ._get_session (), ** kwargs
52+ )
5053 except OperationFailure as err :
5154 if PYMONGO_VERSION >= (4 ,):
5255 raise
You can’t perform that action at this time.
0 commit comments