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

Method identity_key_from_instance

lib/sqlalchemy/orm/mapper.py:3505–3519  ·  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

3503 )
3504
3505 def identity_key_from_instance(self, instance: _O) -> _IdentityKeyType[_O]:
3506 """Return the identity key for the given instance, based on
3507 its primary key attributes.
3508
3509 If the instance's state is expired, calling this method
3510 will result in a database check to see if the object has been deleted.
3511 If the row no longer exists,
3512 :class:`~sqlalchemy.orm.exc.ObjectDeletedError` is raised.
3513
3514 This value is typically also found on the instance state under the
3515 attribute name `key`.
3516
3517 """
3518 state = attributes.instance_state(instance)
3519 return self._identity_key_from_state(state, PassiveFlag.PASSIVE_OFF)
3520
3521 def _identity_key_from_state(
3522 self,

Callers 2

identity_keyFunction · 0.80

Calls 1

Tested by 1