class documentation

class AttributeState: (source)

View In Hierarchy

Provide an inspection interface corresponding to a particular attribute on a particular mapped object. The :class:`.AttributeState` object is accessed via the :attr:`.InstanceState.attrs` collection of a particular :class:`.InstanceState`:: from sqlalchemy import inspect insp = inspect(some_mapped_object) attr_state = insp.attrs.some_attribute

Method __init__ Undocumented
Method load_history Return the current **pre-flush** change history for this attribute, via the :class:`.History` interface.
Class Variable __slots__ Undocumented
Instance Variable key Undocumented
Instance Variable state Undocumented
Property history Return the current **pre-flush** change history for this attribute, via the :class:`.History` interface.
Property loaded_value The current value of this attribute as loaded from the database.
Property value Return the value of this attribute.
def __init__(self, state: InstanceState[Any], key: str): (source)

Undocumented

def load_history(self) -> History: (source)

Return the current **pre-flush** change history for this attribute, via the :class:`.History` interface. This method **will** emit loader callables if the value of the attribute is unloaded. .. note:: The attribute history system tracks changes on a **per flush basis**. Each time the :class:`.Session` is flushed, the history of each attribute is reset to empty. The :class:`.Session` by default autoflushes each time a :class:`_query.Query` is invoked. For options on how to control this, see :ref:`session_flushing`. .. seealso:: :attr:`.AttributeState.history` :func:`.attributes.get_history` - underlying function .. versionadded:: 0.9.0

__slots__: tuple[str, ...] = (source)

Undocumented

Undocumented

Undocumented

Return the current **pre-flush** change history for this attribute, via the :class:`.History` interface. This method will **not** emit loader callables if the value of the attribute is unloaded. .. note:: The attribute history system tracks changes on a **per flush basis**. Each time the :class:`.Session` is flushed, the history of each attribute is reset to empty. The :class:`.Session` by default autoflushes each time a :class:`_query.Query` is invoked. For options on how to control this, see :ref:`session_flushing`. .. seealso:: :meth:`.AttributeState.load_history` - retrieve history using loader callables if the value is not locally present. :func:`.attributes.get_history` - underlying function

@property
loaded_value: Any = (source)

The current value of this attribute as loaded from the database. If the value has not been loaded, or is otherwise not present in the object's dictionary, returns NO_VALUE.

Return the value of this attribute. This operation is equivalent to accessing the object's attribute directly or via ``getattr()``, and will fire off any pending loader callables if needed.