MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / from_execution_options

Method from_execution_options

lib/sqlalchemy/sql/base.py:998–1049  ·  view source on GitHub ↗

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],
    )

Source from the content-addressed store, hash-verified

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

Callers 4

orm_pre_session_execMethod · 0.80
orm_pre_session_execMethod · 0.80
orm_pre_session_execMethod · 0.80
orm_pre_session_execMethod · 0.80

Calls 4

intersectionMethod · 0.45
unionMethod · 0.45
getMethod · 0.45
merge_withMethod · 0.45

Tested by

no test coverage detected