MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / object_mapper

Function object_mapper

lib/sqlalchemy/orm/base.py:388–404  ·  view source on GitHub ↗

Given an object, return the primary Mapper associated with the object instance. Raises :class:`sqlalchemy.orm.exc.UnmappedInstanceError` if no mapping is configured. This function is available via the inspection system as:: inspect(instance).mapper Using the inspectio

(instance: _T)

Source from the content-addressed store, hash-verified

386
387
388def object_mapper(instance: _T) -> Mapper[_T]:
389 """Given an object, return the primary Mapper associated with the object
390 instance.
391
392 Raises :class:`sqlalchemy.orm.exc.UnmappedInstanceError`
393 if no mapping is configured.
394
395 This function is available via the inspection system as::
396
397 inspect(instance).mapper
398
399 Using the inspection system will raise
400 :class:`sqlalchemy.exc.NoInspectionAvailable` if the instance is
401 not part of a mapping.
402
403 """
404 return object_state(instance).mapper
405
406
407def object_state(instance: _T) -> InstanceState[_T]:

Callers 8

_assert_not_orphanMethod · 0.90
_assert_is_orphanMethod · 0.90
set_identityMethod · 0.90
create_versionFunction · 0.90
identity_keyFunction · 0.85
refreshMethod · 0.85
__init__Method · 0.85
with_parentMethod · 0.85

Calls 1

object_stateFunction · 0.85

Tested by 3

_assert_not_orphanMethod · 0.72
_assert_is_orphanMethod · 0.72
set_identityMethod · 0.72