fix(insert_many): list instead of set to maintain order (#18641)
This commit is contained in:
parent
d35aa6c545
commit
aa8957e785
2 changed files with 7 additions and 4 deletions
|
|
@ -206,9 +206,9 @@ def insert_many(docs=None):
|
|||
if len(docs) > 200:
|
||||
frappe.throw(_("Only 200 inserts allowed in one request"))
|
||||
|
||||
out = set()
|
||||
out = []
|
||||
for doc in docs:
|
||||
out.add(insert_doc(doc).name)
|
||||
out.append(insert_doc(doc).name)
|
||||
|
||||
return out
|
||||
|
||||
|
|
|
|||
|
|
@ -227,15 +227,18 @@ class TestClient(FrappeTestCase):
|
|||
"parent": note1.name,
|
||||
"parentfield": "seen_by",
|
||||
},
|
||||
{"doctype": "Note", "title": "not-a-random-title", "content": "test"},
|
||||
{"doctype": "Note", "title": get_random_title(), "content": "test"},
|
||||
{"doctype": "Note", "title": get_random_title(), "content": "test"},
|
||||
{"doctype": "Note", "title": "another-note-title", "content": "test"},
|
||||
]
|
||||
|
||||
# insert all docs
|
||||
docs = insert_many(doc_list)
|
||||
|
||||
# make sure only 1 name is returned for the parent upon insertion of child docs
|
||||
self.assertEqual(len(docs), 3)
|
||||
self.assertEqual(len(docs), 7)
|
||||
self.assertEqual(docs[3], "not-a-random-title")
|
||||
self.assertEqual(docs[6], "another-note-title")
|
||||
self.assertIn(note1.name, docs)
|
||||
|
||||
# cleanup
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue