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)
| 3537 | ) |
| 3538 | |
| 3539 | def primary_key_from_instance(self, instance: _O) -> Tuple[Any, ...]: |
| 3540 | """Return the list of primary key values for the given |
| 3541 | instance. |
| 3542 | |
| 3543 | If the instance's state is expired, calling this method |
| 3544 | will result in a database check to see if the object has been deleted. |
| 3545 | If the row no longer exists, |
| 3546 | :class:`~sqlalchemy.orm.exc.ObjectDeletedError` is raised. |
| 3547 | |
| 3548 | """ |
| 3549 | state = attributes.instance_state(instance) |
| 3550 | identity_key = self._identity_key_from_state( |
| 3551 | state, PassiveFlag.PASSIVE_OFF |
| 3552 | ) |
| 3553 | return identity_key[1] |
| 3554 | |
| 3555 | @HasMemoized.memoized_attribute |
| 3556 | def _persistent_sortkey_fn(self): |