MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / identity_key_from_instance

Method identity_key_from_instance

lib/sqlalchemy/orm/mapper.py:3463–3477  ·  view source on GitHub ↗

Return the identity key for the given instance, based on its primary key attributes. If the instance's state is expired, calling this method will result in a database check to see if the object has been deleted. If the row no longer exists, :class:`~sqlalchem

(self, instance: _O)

Source from the content-addressed store, hash-verified

3461 )
3462
3463 def identity_key_from_instance(self, instance: _O) -> _IdentityKeyType[_O]:
3464 """Return the identity key for the given instance, based on
3465 its primary key attributes.
3466
3467 If the instance's state is expired, calling this method
3468 will result in a database check to see if the object has been deleted.
3469 If the row no longer exists,
3470 :class:`~sqlalchemy.orm.exc.ObjectDeletedError` is raised.
3471
3472 This value is typically also found on the instance state under the
3473 attribute name `key`.
3474
3475 """
3476 state = attributes.instance_state(instance)
3477 return self._identity_key_from_state(state, PassiveFlag.PASSIVE_OFF)
3478
3479 def _identity_key_from_state(
3480 self,

Callers 1

identity_keyFunction · 0.80

Calls 1

Tested by

no test coverage detected