Skip to content

Commit

Permalink
Merge pull request #1271 from maitbayev/master
Browse files Browse the repository at this point in the history
Fixes unicode bug in EmbeddedDocumentListField
  • Loading branch information
thedrow committed Apr 17, 2016
2 parents 2e406d2 + 1092023 commit 43d48b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mongoengine/base/datastructures.py
Expand Up @@ -211,7 +211,7 @@ class EmbeddedDocumentList(BaseList):
def __match_all(cls, i, kwargs):
items = kwargs.items()
return all([
getattr(i, k) == v or str(getattr(i, k)) == v for k, v in items
getattr(i, k) == v or unicode(getattr(i, k)) == v for k, v in items
])

@classmethod
Expand Down
11 changes: 11 additions & 0 deletions tests/fields/fields.py
Expand Up @@ -4046,6 +4046,17 @@ def test_single_keyword_update(self):
# modified
self.assertEqual(number, 2)

def test_unicode(self):
"""
Tests that unicode strings handled correctly
"""
post = self.BlogPost(comments=[
self.Comments(author='user1', message=u'сообщение'),
self.Comments(author='user2', message=u'хабарлама')
]).save()
self.assertEqual(post.comments.get(message=u'сообщение').author,
'user1')

def test_save(self):
"""
Tests the save method of a List of Embedded Documents.
Expand Down

0 comments on commit 43d48b3

Please sign in to comment.