process Options argument in terms of execution options. e.g.:: ( load_options, execution_options, ) = QueryContext.default_load_options.from_execution_options( "_sa_orm_load_options", {"populate_existi
(
cls,
key: str,
attrs: set[str],
exec_options: Mapping[str, Any],
statement_exec_options: Mapping[str, Any],
)
| 1008 | |
| 1009 | @classmethod |
| 1010 | def from_execution_options( |
| 1011 | cls, |
| 1012 | key: str, |
| 1013 | attrs: set[str], |
| 1014 | exec_options: Mapping[str, Any], |
| 1015 | statement_exec_options: Mapping[str, Any], |
| 1016 | ) -> Tuple["Options", Mapping[str, Any]]: |
| 1017 | """process Options argument in terms of execution options. |
| 1018 | |
| 1019 | |
| 1020 | e.g.:: |
| 1021 | |
| 1022 | ( |
| 1023 | load_options, |
| 1024 | execution_options, |
| 1025 | ) = QueryContext.default_load_options.from_execution_options( |
| 1026 | "_sa_orm_load_options", |
| 1027 | {"populate_existing", "autoflush", "yield_per"}, |
| 1028 | execution_options, |
| 1029 | statement._execution_options, |
| 1030 | ) |
| 1031 | |
| 1032 | get back the Options and refresh "_sa_orm_load_options" in the |
| 1033 | exec options dict w/ the Options as well |
| 1034 | |
| 1035 | """ |
| 1036 | |
| 1037 | # common case is that no options we are looking for are |
| 1038 | # in either dictionary, so cancel for that first |
| 1039 | check_argnames = attrs.intersection( |
| 1040 | set(exec_options).union(statement_exec_options) |
| 1041 | ) |
| 1042 | |
| 1043 | existing_options = exec_options.get(key, cls) |
| 1044 | |
| 1045 | if check_argnames: |
| 1046 | result = {} |
| 1047 | for argname in check_argnames: |
| 1048 | local = "_" + argname |
| 1049 | if argname in exec_options: |
| 1050 | result[local] = exec_options[argname] |
| 1051 | elif argname in statement_exec_options: |
| 1052 | result[local] = statement_exec_options[argname] |
| 1053 | |
| 1054 | new_options = existing_options + result |
| 1055 | exec_options = util.EMPTY_DICT.merge_with( |
| 1056 | exec_options, {key: new_options} |
| 1057 | ) |
| 1058 | return new_options, exec_options |
| 1059 | |
| 1060 | else: |
| 1061 | return existing_options, exec_options |
| 1062 | |
| 1063 | if TYPE_CHECKING: |
| 1064 |
no test coverage detected