(
self,
entity: _EntityBindKey[_O],
primary_key_identity: _PKIdentityArgument,
db_load_fn: Callable[..., _O],
*,
options: Optional[Sequence[ExecutableOption]] = None,
populate_existing: bool | None = None,
with_for_update: ForUpdateParameter = None,
identity_token: Optional[Any] = None,
execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT,
bind_arguments: Optional[_BindArguments] = None,
)
| 3880 | return instance |
| 3881 | |
| 3882 | def _get_impl( |
| 3883 | self, |
| 3884 | entity: _EntityBindKey[_O], |
| 3885 | primary_key_identity: _PKIdentityArgument, |
| 3886 | db_load_fn: Callable[..., _O], |
| 3887 | *, |
| 3888 | options: Optional[Sequence[ExecutableOption]] = None, |
| 3889 | populate_existing: bool | None = None, |
| 3890 | with_for_update: ForUpdateParameter = None, |
| 3891 | identity_token: Optional[Any] = None, |
| 3892 | execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT, |
| 3893 | bind_arguments: Optional[_BindArguments] = None, |
| 3894 | ) -> Optional[_O]: |
| 3895 | # set populate_existing value; direct parameter |
| 3896 | # takes precedence over execution_options |
| 3897 | if populate_existing is not None: |
| 3898 | execution_options = { |
| 3899 | **execution_options, # type: ignore[typeddict-item] |
| 3900 | "populate_existing": populate_existing, |
| 3901 | } |
| 3902 | else: |
| 3903 | populate_existing = execution_options.get( |
| 3904 | "populate_existing", False |
| 3905 | ) |
| 3906 | |
| 3907 | # convert composite types to individual args |
| 3908 | if ( |
| 3909 | is_composite_class(primary_key_identity) |
| 3910 | and type(primary_key_identity) |
| 3911 | in descriptor_props._composite_getters |
| 3912 | ): |
| 3913 | getter = descriptor_props._composite_getters[ |
| 3914 | type(primary_key_identity) |
| 3915 | ] |
| 3916 | primary_key_identity = getter(primary_key_identity) |
| 3917 | |
| 3918 | mapper: Optional[Mapper[_O]] = inspect(entity) |
| 3919 | |
| 3920 | if mapper is None or not mapper.is_mapper: |
| 3921 | raise sa_exc.ArgumentError( |
| 3922 | "Expected mapped class or mapper, got: %r" % entity |
| 3923 | ) |
| 3924 | |
| 3925 | is_dict = isinstance(primary_key_identity, dict) |
| 3926 | if not is_dict: |
| 3927 | primary_key_identity = util.to_list( |
| 3928 | primary_key_identity, default=[None] |
| 3929 | ) |
| 3930 | |
| 3931 | if len(primary_key_identity) != len(mapper.primary_key): |
| 3932 | raise sa_exc.InvalidRequestError( |
| 3933 | "Incorrect number of values in identifier to formulate " |
| 3934 | "primary key for session.get(); primary key columns " |
| 3935 | "are %s" % ",".join("'%s'" % c for c in mapper.primary_key) |
| 3936 | ) |
| 3937 | |
| 3938 | if is_dict: |
| 3939 | pk_synonyms = mapper._pk_synonyms |
no test coverage detected