Return an identity-map key for use in storing/retrieving an item from the identity map. :param row: A :class:`.Row` or :class:`.RowMapping` produced from a result set that selected from the ORM mapped primary key columns. .. versionchanged:: 2.0 :class
(
self,
row: Union[Row[Unpack[TupleAny]], RowMapping],
identity_token: Optional[Any] = None,
adapter: Optional[ORMAdapter] = None,
)
| 3409 | return True |
| 3410 | |
| 3411 | def identity_key_from_row( |
| 3412 | self, |
| 3413 | row: Union[Row[Unpack[TupleAny]], RowMapping], |
| 3414 | identity_token: Optional[Any] = None, |
| 3415 | adapter: Optional[ORMAdapter] = None, |
| 3416 | ) -> _IdentityKeyType[_O]: |
| 3417 | """Return an identity-map key for use in storing/retrieving an |
| 3418 | item from the identity map. |
| 3419 | |
| 3420 | :param row: A :class:`.Row` or :class:`.RowMapping` produced from a |
| 3421 | result set that selected from the ORM mapped primary key columns. |
| 3422 | |
| 3423 | .. versionchanged:: 2.0 |
| 3424 | :class:`.Row` or :class:`.RowMapping` are accepted |
| 3425 | for the "row" argument |
| 3426 | |
| 3427 | """ |
| 3428 | pk_cols: Sequence[ColumnElement[Any]] |
| 3429 | if adapter is not None: |
| 3430 | pk_cols = [adapter.columns[c] for c in self.primary_key] |
| 3431 | else: |
| 3432 | pk_cols = self.primary_key |
| 3433 | |
| 3434 | mapping: RowMapping |
| 3435 | if hasattr(row, "_mapping"): |
| 3436 | mapping = row._mapping |
| 3437 | else: |
| 3438 | mapping = row # type: ignore[assignment] |
| 3439 | |
| 3440 | return ( |
| 3441 | self._identity_class, |
| 3442 | tuple(mapping[column] for column in pk_cols), |
| 3443 | identity_token, |
| 3444 | ) |
| 3445 | |
| 3446 | def identity_key_from_primary_key( |
| 3447 | self, |