Fix wording of an exception message in QuerySet.insert

This commit is contained in:
Stefan Wojcik 2019-06-12 08:27:22 +02:00
parent 1f02d5fbbd
commit 996618a495
2 changed files with 9 additions and 3 deletions

View File

@ -335,7 +335,7 @@ class BaseQuerySet(object):
% str(self._document))
raise OperationError(msg)
if doc.pk and not doc._created:
msg = 'Some documents have ObjectIds use doc.update() instead'
msg = 'Some documents have ObjectIds, use doc.update() instead'
raise OperationError(msg)
signal_kwargs = signal_kwargs or {}

View File

@ -898,13 +898,19 @@ class QuerySetTest(unittest.TestCase):
with self.assertRaises(OperationError) as cm:
blog = Blog.objects.first()
Blog.objects.insert(blog)
self.assertEqual(str(cm.exception), 'Some documents have ObjectIds use doc.update() instead')
self.assertEqual(
str(cm.exception),
'Some documents have ObjectIds, use doc.update() instead'
)
# test inserting a query set
with self.assertRaises(OperationError) as cm:
blogs_qs = Blog.objects
Blog.objects.insert(blogs_qs)
self.assertEqual(str(cm.exception), 'Some documents have ObjectIds use doc.update() instead')
self.assertEqual(
str(cm.exception),
'Some documents have ObjectIds, use doc.update() instead'
)
# insert 1 new doc
new_post = Blog(title="code123", id=ObjectId())