MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / _bulk_save_mappings

Method _bulk_save_mappings

lib/sqlalchemy/orm/session.py:4727–4768  ·  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

4725 )
4726
4727 def _bulk_save_mappings(
4728 self,
4729 mapper: _EntityBindKey[_O],
4730 mappings: Union[Iterable[InstanceState[_O]], Iterable[Dict[str, Any]]],
4731 *,
4732 isupdate: bool,
4733 isstates: bool,
4734 return_defaults: bool,
4735 update_changed_only: bool,
4736 render_nulls: bool,
4737 ) -> None:
4738 mapper = _class_to_mapper(mapper)
4739
4740 try:
4741 self._flushing = True
4742
4743 transaction = self._autobegin_t()._begin()
4744 try:
4745 if isupdate:
4746 bulk_persistence._bulk_update(
4747 mapper,
4748 mappings,
4749 transaction,
4750 isstates=isstates,
4751 update_changed_only=update_changed_only,
4752 )
4753 else:
4754 bulk_persistence._bulk_insert(
4755 mapper,
4756 mappings,
4757 transaction,
4758 isstates=isstates,
4759 return_defaults=return_defaults,
4760 render_nulls=render_nulls,
4761 )
4762 transaction.commit()
4763
4764 except:
4765 with util.safe_reraise():
4766 transaction.rollback(_capture_exception=True)
4767 finally:
4768 self._flushing = False
4769
4770 def is_modified(
4771 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