MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _setup_select_stack

Method _setup_select_stack

lib/sqlalchemy/sql/compiler.py:5208–5258  ·  view source on GitHub ↗
(
        self, select, compile_state, entry, asfrom, lateral, compound_index
    )

Source from the content-addressed store, hash-verified

5206 return hint_text, byfrom
5207
5208 def _setup_select_stack(
5209 self, select, compile_state, entry, asfrom, lateral, compound_index
5210 ):
5211 correlate_froms = entry["correlate_froms"]
5212 asfrom_froms = entry["asfrom_froms"]
5213
5214 if compound_index == 0:
5215 entry["select_0"] = select
5216 elif compound_index:
5217 select_0 = entry["select_0"]
5218 numcols = len(select_0._all_selected_columns)
5219
5220 if len(compile_state.columns_plus_names) != numcols:
5221 raise exc.CompileError(
5222 "All selectables passed to "
5223 "CompoundSelect must have identical numbers of "
5224 "columns; select #%d has %d columns, select "
5225 "#%d has %d"
5226 % (
5227 1,
5228 numcols,
5229 compound_index + 1,
5230 len(select._all_selected_columns),
5231 )
5232 )
5233
5234 if asfrom and not lateral:
5235 froms = compile_state._get_display_froms(
5236 explicit_correlate_froms=correlate_froms.difference(
5237 asfrom_froms
5238 ),
5239 implicit_correlate_froms=(),
5240 )
5241 else:
5242 froms = compile_state._get_display_froms(
5243 explicit_correlate_froms=correlate_froms,
5244 implicit_correlate_froms=asfrom_froms,
5245 )
5246
5247 new_correlate_froms = set(_from_objects(*froms))
5248 all_correlate_froms = new_correlate_froms.union(correlate_froms)
5249
5250 new_entry: _CompilerStackEntry = {
5251 "asfrom_froms": new_correlate_froms,
5252 "correlate_froms": all_correlate_froms,
5253 "selectable": select,
5254 "compile_state": compile_state,
5255 }
5256 self.stack.append(new_entry)
5257
5258 return froms
5259
5260 def _compose_select_body(
5261 self,

Callers 1

visit_selectMethod · 0.95

Calls 5

_from_objectsFunction · 0.85
_get_display_fromsMethod · 0.80
differenceMethod · 0.45
unionMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected