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

Function get_history

lib/sqlalchemy/orm/attributes.py:2551–2588  ·  view source on GitHub ↗

Return a :class:`.History` record for the given object and attribute key. This is the **pre-flush** history for a given attribute, which is reset each time the :class:`.Session` flushes changes to the current database transaction. .. note:: Prefer to use the :attr:`.At

(
    obj: object, key: str, passive: PassiveFlag = PASSIVE_OFF
)

Source from the content-addressed store, hash-verified

2549
2550
2551def get_history(
2552 obj: object, key: str, passive: PassiveFlag = PASSIVE_OFF
2553) -> History:
2554 """Return a :class:`.History` record for the given object
2555 and attribute key.
2556
2557 This is the **pre-flush** history for a given attribute, which is
2558 reset each time the :class:`.Session` flushes changes to the
2559 current database transaction.
2560
2561 .. note::
2562
2563 Prefer to use the :attr:`.AttributeState.history` and
2564 :meth:`.AttributeState.load_history` accessors to retrieve the
2565 :class:`.History` for instance attributes.
2566
2567
2568 :param obj: an object whose class is instrumented by the
2569 attributes package.
2570
2571 :param key: string attribute name.
2572
2573 :param passive: indicates loading behavior for the attribute
2574 if the value is not already present. This is a
2575 bitflag attribute, which defaults to the symbol
2576 :attr:`.PASSIVE_OFF` indicating all necessary SQL
2577 should be emitted.
2578
2579 .. seealso::
2580
2581 :attr:`.AttributeState.history`
2582
2583 :meth:`.AttributeState.load_history` - retrieve history
2584 using loader callables if the value is not locally present.
2585
2586 """
2587
2588 return get_state_history(instance_state(obj), key, passive)
2589
2590
2591def get_state_history(

Callers 1

test_get_historyMethod · 0.90

Calls 2

get_state_historyFunction · 0.85
instance_stateFunction · 0.85

Tested by 1

test_get_historyMethod · 0.72