MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / primary_key_from_instance

Method primary_key_from_instance

lib/sqlalchemy/orm/mapper.py:3497–3511  ·  view source on GitHub ↗

Return the list of primary key values for the given instance. 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:`~sqlalchemy.orm.exc.ObjectDeleted

(self, instance: _O)

Source from the content-addressed store, hash-verified

3495 )
3496
3497 def primary_key_from_instance(self, instance: _O) -> Tuple[Any, ...]:
3498 """Return the list of primary key values for the given
3499 instance.
3500
3501 If the instance's state is expired, calling this method
3502 will result in a database check to see if the object has been deleted.
3503 If the row no longer exists,
3504 :class:`~sqlalchemy.orm.exc.ObjectDeletedError` is raised.
3505
3506 """
3507 state = attributes.instance_state(instance)
3508 identity_key = self._identity_key_from_state(
3509 state, PassiveFlag.PASSIVE_OFF
3510 )
3511 return identity_key[1]
3512
3513 @HasMemoized.memoized_attribute
3514 def _persistent_sortkey_fn(self):

Callers 2

Calls 1

Tested by 1