to_db_fields fix (#1553)
This commit is contained in:
		| @@ -197,14 +197,18 @@ class OnlyExcludeAllTest(unittest.TestCase): | ||||
|             title = StringField() | ||||
|             text = StringField() | ||||
|  | ||||
|         class VariousData(EmbeddedDocument): | ||||
|             some = BooleanField() | ||||
|  | ||||
|         class BlogPost(Document): | ||||
|             content = StringField() | ||||
|             author = EmbeddedDocumentField(User) | ||||
|             comments = ListField(EmbeddedDocumentField(Comment)) | ||||
|             various = MapField(field=EmbeddedDocumentField(VariousData)) | ||||
|  | ||||
|         BlogPost.drop_collection() | ||||
|  | ||||
|         post = BlogPost(content='Had a good coffee today...') | ||||
|         post = BlogPost(content='Had a good coffee today...', various={'test_dynamic':{'some': True}}) | ||||
|         post.author = User(name='Test User') | ||||
|         post.comments = [Comment(title='I aggree', text='Great post!'), Comment(title='Coffee', text='I hate coffee')] | ||||
|         post.save() | ||||
| @@ -215,6 +219,9 @@ class OnlyExcludeAllTest(unittest.TestCase): | ||||
|         self.assertEqual(obj.author.name, 'Test User') | ||||
|         self.assertEqual(obj.comments, []) | ||||
|  | ||||
|         obj = BlogPost.objects.only('various.test_dynamic.some').get() | ||||
|         self.assertEqual(obj.various["test_dynamic"].some, True) | ||||
|  | ||||
|         obj = BlogPost.objects.only('content', 'comments.title',).get() | ||||
|         self.assertEqual(obj.content, 'Had a good coffee today...') | ||||
|         self.assertEqual(obj.author, None) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user