From 58ab1862792fa9b981f32f74356e421d57995f0b Mon Sep 17 00:00:00 2001 From: brln Date: Sun, 24 Jul 2016 13:22:52 -0700 Subject: Bulk Save Documentation The session::bulk_save_objects method emphasizes performance, but generates many insert statements when a variety of object types are passed in an unordered list. This was a signification gotcha for me, and seems contrary to the spirit of the method, so short of changing the method to automatically sort the list, it should at least be documented. --- lib/sqlalchemy/orm/session.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py index a7440bf40..a7eedcf34 100644 --- a/lib/sqlalchemy/orm/session.py +++ b/lib/sqlalchemy/orm/session.py @@ -2213,6 +2213,12 @@ class Session(_SessionClassMethods): **before using this method, and fully test and confirm the functionality of all code developed using these systems.** + .. warning:: + + Objects are processed in the order passed. Be sure to group objects + of the same type together (the list is sorted), else they will be + inserted in distinct batches. + :param objects: a list of mapped object instances. The mapped objects are persisted as is, and are **not** associated with the :class:`.Session` afterwards. -- cgit v1.2.1