MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / FromStatement

Class FromStatement

lib/sqlalchemy/orm/context.py:961–1078  ·  view source on GitHub ↗

Core construct that represents a load of ORM objects from various :class:`.ReturnsRows` and other classes including: :class:`.Select`, :class:`.TextClause`, :class:`.TextualSelect`, :class:`.CompoundSelect`, :class`.Insert`, :class:`.Update`, and in theory, :class:`.Delete`.

Source from the content-addressed store, hash-verified

959
960
961class FromStatement(GroupedElement, Generative, TypedReturnsRows[Unpack[_Ts]]):
962 """Core construct that represents a load of ORM objects from various
963 :class:`.ReturnsRows` and other classes including:
964
965 :class:`.Select`, :class:`.TextClause`, :class:`.TextualSelect`,
966 :class:`.CompoundSelect`, :class`.Insert`, :class:`.Update`,
967 and in theory, :class:`.Delete`.
968
969 """
970
971 __visit_name__ = "orm_from_statement"
972
973 _compile_options = _ORMFromStatementCompileState.default_compile_options
974
975 _compile_state_factory = _ORMFromStatementCompileState.create_for_statement
976
977 _for_update_arg = None
978
979 element: Union[ExecutableReturnsRows, TextClause]
980
981 _adapt_on_names: bool
982
983 _traverse_internals = [
984 ("_raw_columns", InternalTraversal.dp_clauseelement_list),
985 ("element", InternalTraversal.dp_clauseelement),
986 ] + ExecutableStatement._executable_traverse_internals
987
988 _cache_key_traversal = _traverse_internals + [
989 ("_compile_options", InternalTraversal.dp_has_cache_key)
990 ]
991
992 is_from_statement = True
993
994 def __init__(
995 self,
996 entities: Iterable[_ColumnsClauseArgument[Any]],
997 element: Union[ExecutableReturnsRows, TextClause],
998 _adapt_on_names: bool = True,
999 ):
1000 self._raw_columns = [
1001 coercions.expect(
1002 roles.ColumnsClauseRole,
1003 ent,
1004 apply_propagate_attrs=self,
1005 post_inspect=True,
1006 )
1007 for ent in util.to_list(entities)
1008 ]
1009 self.element = element
1010 self.is_dml = element.is_dml
1011 self.is_select = element.is_select
1012 self.is_delete = element.is_delete
1013 self.is_insert = element.is_insert
1014 self.is_update = element.is_update
1015 self._label_style = (
1016 element._label_style if is_select_base(element) else None
1017 )
1018 self._adapt_on_names = _adapt_on_names

Callers 4

from_statementMethod · 0.85
_setup_orm_returningMethod · 0.85
_load_scalar_attributesFunction · 0.85
_statement_20Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected