Skip to content

Commit 996618a

Browse files
committed
Fix wording of an exception message in QuerySet.insert
1 parent 1f02d5f commit 996618a

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

mongoengine/queryset/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def insert(self, doc_or_docs, load_bulk=True,
335335
% str(self._document))
336336
raise OperationError(msg)
337337
if doc.pk and not doc._created:
338-
msg = 'Some documents have ObjectIds use doc.update() instead'
338+
msg = 'Some documents have ObjectIds, use doc.update() instead'
339339
raise OperationError(msg)
340340

341341
signal_kwargs = signal_kwargs or {}

tests/queryset/queryset.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,13 +898,19 @@ class Blog(Document):
898898
with self.assertRaises(OperationError) as cm:
899899
blog = Blog.objects.first()
900900
Blog.objects.insert(blog)
901-
self.assertEqual(str(cm.exception), 'Some documents have ObjectIds use doc.update() instead')
901+
self.assertEqual(
902+
str(cm.exception),
903+
'Some documents have ObjectIds, use doc.update() instead'
904+
)
902905

903906
# test inserting a query set
904907
with self.assertRaises(OperationError) as cm:
905908
blogs_qs = Blog.objects
906909
Blog.objects.insert(blogs_qs)
907-
self.assertEqual(str(cm.exception), 'Some documents have ObjectIds use doc.update() instead')
910+
self.assertEqual(
911+
str(cm.exception),
912+
'Some documents have ObjectIds, use doc.update() instead'
913+
)
908914

909915
# insert 1 new doc
910916
new_post = Blog(title="code123", id=ObjectId())

0 commit comments

Comments
 (0)