Compare commits
1 Commits
queryset-c
...
simpler-in
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea82cb80f6 |
@@ -933,14 +933,6 @@ class BaseQuerySet(object):
|
|||||||
queryset._ordering = queryset._get_order_by(keys)
|
queryset._ordering = queryset._get_order_by(keys)
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
def comment(self, text):
|
|
||||||
"""Add a comment to the query.
|
|
||||||
|
|
||||||
See https://docs.mongodb.com/manual/reference/method/cursor.comment/#cursor.comment
|
|
||||||
for details.
|
|
||||||
"""
|
|
||||||
return self._chainable_method("comment", text)
|
|
||||||
|
|
||||||
def explain(self, format=False):
|
def explain(self, format=False):
|
||||||
"""Return an explain plan record for the
|
"""Return an explain plan record for the
|
||||||
:class:`~mongoengine.queryset.QuerySet`\ 's cursor.
|
:class:`~mongoengine.queryset.QuerySet`\ 's cursor.
|
||||||
|
|||||||
@@ -2,10 +2,8 @@
|
|||||||
import unittest
|
import unittest
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
sys.path[0:0] = [""]
|
|
||||||
|
|
||||||
import pymongo
|
import pymongo
|
||||||
from random import randint
|
|
||||||
|
|
||||||
from nose.plugins.skip import SkipTest
|
from nose.plugins.skip import SkipTest
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@@ -17,11 +15,9 @@ __all__ = ("IndexesTest", )
|
|||||||
|
|
||||||
|
|
||||||
class IndexesTest(unittest.TestCase):
|
class IndexesTest(unittest.TestCase):
|
||||||
_MAX_RAND = 10 ** 10
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.db_name = 'mongoenginetest_IndexesTest_' + str(randint(0, self._MAX_RAND))
|
self.connection = connect(db='mongoenginetest')
|
||||||
self.connection = connect(db=self.db_name)
|
|
||||||
self.db = get_db()
|
self.db = get_db()
|
||||||
|
|
||||||
class Person(Document):
|
class Person(Document):
|
||||||
|
|||||||
@@ -339,6 +339,7 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_update_write_concern(self):
|
def test_update_write_concern(self):
|
||||||
"""Test that passing write_concern works"""
|
"""Test that passing write_concern works"""
|
||||||
|
|
||||||
self.Person.drop_collection()
|
self.Person.drop_collection()
|
||||||
|
|
||||||
write_concern = {"fsync": True}
|
write_concern = {"fsync": True}
|
||||||
@@ -2198,21 +2199,6 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
a.author.name for a in Author.objects.order_by('-author__age')]
|
a.author.name for a in Author.objects.order_by('-author__age')]
|
||||||
self.assertEqual(names, ['User A', 'User B', 'User C'])
|
self.assertEqual(names, ['User A', 'User B', 'User C'])
|
||||||
|
|
||||||
def test_comment(self):
|
|
||||||
"""Make sure adding a comment to the query works."""
|
|
||||||
class User(Document):
|
|
||||||
age = IntField()
|
|
||||||
|
|
||||||
with db_ops_tracker() as q:
|
|
||||||
adult = (User.objects.filter(age__gte=18)
|
|
||||||
.comment('looking for an adult')
|
|
||||||
.first())
|
|
||||||
ops = q.get_ops()
|
|
||||||
self.assertEqual(len(ops), 1)
|
|
||||||
op = ops[0]
|
|
||||||
self.assertEqual(op['query']['$query'], {'age': {'$gte': 18}})
|
|
||||||
self.assertEqual(op['query']['$comment'], 'looking for an adult')
|
|
||||||
|
|
||||||
def test_map_reduce(self):
|
def test_map_reduce(self):
|
||||||
"""Ensure map/reduce is both mapping and reducing.
|
"""Ensure map/reduce is both mapping and reducing.
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user