PYTHON-1786 Send comment with Cursor.count and Cursor.distinct
This commit is contained in:
parent
c55a66235d
commit
4169a04821
@ -77,6 +77,11 @@ Changes in Version 3.8.0.dev0
|
||||
the :class:`~bson.codec_options.TypeCodec` and
|
||||
:class:`~bson.codec_options.TypeRegistry` APIs. For more information, see
|
||||
the :doc:`custom type example <examples/custom_type>`.
|
||||
- :meth:`pymongo.cursor.Cursor.distinct` and
|
||||
:meth:`pymongo.cursor.Cursor.count` now send the Cursor's
|
||||
:meth:`~pymongo.cursor.Cursor.comment` as the "comment" top-level
|
||||
command option instead of "$comment". Also, note that "comment" must be a
|
||||
string.
|
||||
|
||||
|
||||
Issues Resolved
|
||||
|
||||
@ -1373,9 +1373,10 @@ class Collection(common.BaseObject):
|
||||
exclusive upper bound for all keys of a specific index in order.
|
||||
Pass this as an alternative to calling
|
||||
:meth:`~pymongo.cursor.Cursor.max` on the cursor.
|
||||
- `comment` (optional): A string or document. Pass this as an
|
||||
alternative to calling :meth:`~pymongo.cursor.Cursor.comment` on the
|
||||
cursor.
|
||||
- `comment` (optional): A string to attach to the query to help
|
||||
interpret and trace the operation in the server logs and in profile
|
||||
data. Pass this as an alternative to calling
|
||||
:meth:`~pymongo.cursor.Cursor.comment` on the cursor.
|
||||
- `modifiers` (optional): **DEPRECATED** - A dict specifying
|
||||
additional MongoDB query modifiers. Use the keyword arguments listed
|
||||
above instead.
|
||||
|
||||
@ -754,7 +754,7 @@ class Cursor(object):
|
||||
if self.__max_time_ms is not None:
|
||||
cmd["maxTimeMS"] = self.__max_time_ms
|
||||
if self.__comment:
|
||||
cmd["$comment"] = self.__comment
|
||||
cmd["comment"] = self.__comment
|
||||
|
||||
if self.__hint is not None:
|
||||
cmd["hint"] = self.__hint
|
||||
@ -791,7 +791,7 @@ class Cursor(object):
|
||||
if self.__max_time_ms is not None:
|
||||
options['maxTimeMS'] = self.__max_time_ms
|
||||
if self.__comment:
|
||||
options['$comment'] = self.__comment
|
||||
options['comment'] = self.__comment
|
||||
if self.__collation is not None:
|
||||
options['collation'] = self.__collation
|
||||
|
||||
@ -862,7 +862,8 @@ class Cursor(object):
|
||||
http://docs.mongodb.org/manual/reference/operator/comment/
|
||||
|
||||
:Parameters:
|
||||
- `comment`: A string or document
|
||||
- `comment`: A string to attach to the query to help interpret and
|
||||
trace the operation in the server logs and in profile data.
|
||||
|
||||
.. versionadded:: 2.7
|
||||
"""
|
||||
|
||||
@ -1218,12 +1218,8 @@ class TestCursor(IntegrationTest):
|
||||
self.assertTrue(c1.alive)
|
||||
|
||||
@client_context.require_no_mongos
|
||||
@client_context.require_version_max(4, 1, 8)
|
||||
@ignore_deprecations
|
||||
def test_comment(self):
|
||||
if client_context.auth_enabled:
|
||||
raise SkipTest("SERVER-4754 - This test uses profiling.")
|
||||
|
||||
# MongoDB 3.1.5 changed the ns for commands.
|
||||
regex = {'$regex': r'pymongo_test.(\$cmd|test)'}
|
||||
|
||||
@ -1247,14 +1243,14 @@ class TestCursor(IntegrationTest):
|
||||
op = self.db.system.profile.find({'ns': regex,
|
||||
'op': 'command',
|
||||
'command.count': 'test',
|
||||
'command.$comment': 'foo'})
|
||||
'command.comment': 'foo'})
|
||||
self.assertEqual(op.count(), 1)
|
||||
|
||||
self.db.test.find().comment('foo').distinct('type')
|
||||
op = self.db.system.profile.find({'ns': regex,
|
||||
'op': 'command',
|
||||
'command.distinct': 'test',
|
||||
'command.$comment': 'foo'})
|
||||
'command.comment': 'foo'})
|
||||
self.assertEqual(op.count(), 1)
|
||||
finally:
|
||||
self.db.set_profiling_level(OFF)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user