Skip to content

Commit

Permalink
mongomock#273 omit $comment when filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
Deo committed Mar 27, 2017
1 parent 6d9884e commit 9970d11
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mongomock/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def filter_applies(search_filter, document):
('$ne' in search or search == {'$exists': False})
and len(iter_key_candidates(key, document)) == 0):
continue
if key == '$comment':
continue

for doc_val in iter_key_candidates(key, document):
if isinstance(search, dict):
Expand Down
5 changes: 5 additions & 0 deletions tests/test__collection_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,11 @@ def test__bulk_write_delete_many(self):
'writeErrors': [], 'upserted': [], 'writeConcernErrors': [],
'nRemoved': 2, 'nInserted': 0})

def test_find_with_comment(self):
self.db.collection.insert_one({'_id': 1})
actual = list(self.db.collection.find({'_id': 1, '$comment': 'test'}))
self.assertEqual([{'_id': 1}], actual)

def test__aggregate_project_array_element_at(self):
self.db.collection.insert_one({'_id': 1, 'arr': [2, 3]})
actual = self.db.collection.aggregate([
Expand Down

0 comments on commit 9970d11

Please sign in to comment.