MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / object_mapper

Function object_mapper

lib/sqlalchemy/orm/base.py:384–400  ·  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

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

Callers 9

_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
mergeMethod · 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