MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / object_state

Function object_state

lib/sqlalchemy/orm/base.py:407–428  ·  view source on GitHub ↗

Given an object, return the :class:`.InstanceState` associated with the object. Raises :class:`sqlalchemy.orm.exc.UnmappedInstanceError` if no mapping is configured. Equivalent functionality is available via the :func:`_sa.inspect` function as:: inspect(instance)

(instance: _T)

Source from the content-addressed store, hash-verified

405
406
407def object_state(instance: _T) -> InstanceState[_T]:
408 """Given an object, return the :class:`.InstanceState`
409 associated with the object.
410
411 Raises :class:`sqlalchemy.orm.exc.UnmappedInstanceError`
412 if no mapping is configured.
413
414 Equivalent functionality is available via the :func:`_sa.inspect`
415 function as::
416
417 inspect(instance)
418
419 Using the inspection system will raise
420 :class:`sqlalchemy.exc.NoInspectionAvailable` if the instance is
421 not part of a mapping.
422
423 """
424 state = _inspect_mapped_object(instance)
425 if state is None:
426 raise exc.UnmappedInstanceError(instance)
427 else:
428 return state
429
430
431@inspection._inspects(object)

Callers 6

object_mapperFunction · 0.85
deleteMethod · 0.85
delete_allMethod · 0.85
mergeMethod · 0.85
merge_allMethod · 0.85
is_modifiedMethod · 0.85

Calls 1

_inspect_mapped_objectFunction · 0.85

Tested by

no test coverage detected