MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _bulk_save_mappings

Method _bulk_save_mappings

lib/sqlalchemy/orm/session.py:4893–4932  ·  view source on GitHub ↗
(
        self,
        mapper: _EntityBindKey[_O],
        mappings: Union[Iterable[InstanceState[_O]], Iterable[Dict[str, Any]]],
        *,
        isupdate: bool,
        isstates: bool,
        return_defaults: bool,
        update_changed_only: bool,
        render_nulls: bool,
    )

Source from the content-addressed store, hash-verified

4891 )
4892
4893 def _bulk_save_mappings(
4894 self,
4895 mapper: _EntityBindKey[_O],
4896 mappings: Union[Iterable[InstanceState[_O]], Iterable[Dict[str, Any]]],
4897 *,
4898 isupdate: bool,
4899 isstates: bool,
4900 return_defaults: bool,
4901 update_changed_only: bool,
4902 render_nulls: bool,
4903 ) -> None:
4904 mapper = _class_to_mapper(mapper)
4905 self._flushing = True
4906
4907 transaction = self._autobegin_t()._begin()
4908 try:
4909 if isupdate:
4910 bulk_persistence._bulk_update(
4911 mapper,
4912 mappings,
4913 transaction,
4914 isstates=isstates,
4915 update_changed_only=update_changed_only,
4916 )
4917 else:
4918 bulk_persistence._bulk_insert(
4919 mapper,
4920 mappings,
4921 transaction,
4922 isstates=isstates,
4923 return_defaults=return_defaults,
4924 render_nulls=render_nulls,
4925 )
4926 transaction.commit()
4927
4928 except:
4929 with util.safe_reraise():
4930 transaction.rollback(_capture_exception=True)
4931 finally:
4932 self._flushing = False
4933
4934 def is_modified(
4935 self, instance: object, include_collections: bool = True

Callers 3

bulk_save_objectsMethod · 0.95
bulk_insert_mappingsMethod · 0.95
bulk_update_mappingsMethod · 0.95

Calls 5

_autobegin_tMethod · 0.95
_class_to_mapperFunction · 0.85
_beginMethod · 0.80
commitMethod · 0.45
rollbackMethod · 0.45

Tested by

no test coverage detected