MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / get_history

Method get_history

lib/sqlalchemy/orm/descriptor_props.py:707–744  ·  view source on GitHub ↗

Provided for userland code that uses attributes.get_history().

(
        self,
        state: InstanceState[Any],
        dict_: _InstanceDict,
        passive: PassiveFlag = PassiveFlag.PASSIVE_OFF,
    )

Source from the content-addressed store, hash-verified

705 return populate
706
707 def get_history(
708 self,
709 state: InstanceState[Any],
710 dict_: _InstanceDict,
711 passive: PassiveFlag = PassiveFlag.PASSIVE_OFF,
712 ) -> History:
713 """Provided for userland code that uses attributes.get_history()."""
714
715 added: List[Any] = []
716 deleted: List[Any] = []
717
718 has_history = False
719 for prop in self.props:
720 key = prop.key
721 hist = state.manager[key].impl.get_history(state, dict_)
722 if hist.has_changes():
723 has_history = True
724
725 non_deleted = hist.non_deleted()
726 if non_deleted:
727 added.extend(non_deleted)
728 else:
729 added.append(None)
730 if hist.deleted:
731 deleted.extend(hist.deleted)
732 else:
733 deleted.append(None)
734
735 if has_history:
736 return attributes.History(
737 [self._construct_composite(*added)],
738 (),
739 [self._construct_composite(*deleted)],
740 )
741 else:
742 return attributes.History(
743 (), [self._construct_composite(*added)], ()
744 )
745
746 def _comparator_factory(
747 self, mapper: Mapper[Any]

Callers

nothing calls this directly

Calls 6

_construct_compositeMethod · 0.95
has_changesMethod · 0.80
non_deletedMethod · 0.80
get_historyMethod · 0.45
extendMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected