MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / visit_select

Method visit_select

lib/sqlalchemy/sql/compiler.py:4973–5194  ·  view source on GitHub ↗
(
        self,
        select_stmt,
        asfrom=False,
        insert_into=False,
        fromhints=None,
        compound_index=None,
        select_wraps_for=None,
        lateral=False,
        from_linter=None,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

4971 """
4972
4973 def visit_select(
4974 self,
4975 select_stmt,
4976 asfrom=False,
4977 insert_into=False,
4978 fromhints=None,
4979 compound_index=None,
4980 select_wraps_for=None,
4981 lateral=False,
4982 from_linter=None,
4983 **kwargs,
4984 ):
4985 assert select_wraps_for is None, (
4986 "SQLAlchemy 1.4 requires use of "
4987 "the translate_select_structure hook for structural "
4988 "translations of SELECT objects"
4989 )
4990 if self._collect_params:
4991 self._add_to_params(select_stmt)
4992
4993 # initial setup of SELECT. the compile_state_factory may now
4994 # be creating a totally different SELECT from the one that was
4995 # passed in. for ORM use this will convert from an ORM-state
4996 # SELECT to a regular "Core" SELECT. other composed operations
4997 # such as computation of joins will be performed.
4998
4999 kwargs["within_columns_clause"] = False
5000
5001 compile_state = select_stmt._compile_state_factory(
5002 select_stmt, self, **kwargs
5003 )
5004 kwargs["ambiguous_table_name_map"] = (
5005 compile_state._ambiguous_table_name_map
5006 )
5007
5008 select_stmt = compile_state.statement
5009
5010 toplevel = not self.stack
5011
5012 if toplevel and not self.compile_state:
5013 self.compile_state = compile_state
5014
5015 is_embedded_select = compound_index is not None or insert_into
5016
5017 # translate step for Oracle, SQL Server which often need to
5018 # restructure the SELECT to allow for LIMIT/OFFSET and possibly
5019 # other conditions
5020 if self.translate_select_structure:
5021 new_select_stmt = self.translate_select_structure(
5022 select_stmt, asfrom=asfrom, **kwargs
5023 )
5024
5025 # if SELECT was restructured, maintain a link to the originals
5026 # and assemble a new compile state
5027 if new_select_stmt is not select_stmt:
5028 compile_state_wraps_for = compile_state
5029 select_wraps_for = select_stmt
5030 select_stmt = new_select_stmt

Callers

nothing calls this directly

Calls 15

_add_to_paramsMethod · 0.95
_setup_select_stackMethod · 0.95
_setup_select_hintsMethod · 0.95
_generate_prefixesMethod · 0.95
get_select_precolumnsMethod · 0.95
_label_select_columnMethod · 0.95
_compose_select_bodyMethod · 0.95
_render_cte_clauseMethod · 0.95
ResultColumnsEntryClass · 0.85

Tested by

no test coverage detected