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

Class LambdaElement

lib/sqlalchemy/sql/lambdas.py:153–423  ·  view source on GitHub ↗

A SQL construct where the state is stored as an un-invoked lambda. The :class:`_sql.LambdaElement` is produced transparently whenever passing lambda expressions into SQL constructs, such as:: stmt = select(table).where(lambda: table.c.col == parameter) The :class:`_sql.LambdaE

Source from the content-addressed store, hash-verified

151
152
153class LambdaElement(elements.ClauseElement):
154 """A SQL construct where the state is stored as an un-invoked lambda.
155
156 The :class:`_sql.LambdaElement` is produced transparently whenever
157 passing lambda expressions into SQL constructs, such as::
158
159 stmt = select(table).where(lambda: table.c.col == parameter)
160
161 The :class:`_sql.LambdaElement` is the base of the
162 :class:`_sql.StatementLambdaElement` which represents a full statement
163 within a lambda.
164
165 .. versionadded:: 1.4
166
167 .. seealso::
168
169 :ref:`engine_lambda_caching`
170
171 """
172
173 __visit_name__ = "lambda_element"
174
175 _is_lambda_element = True
176
177 _traverse_internals = [
178 ("_resolved", visitors.InternalTraversal.dp_clauseelement)
179 ]
180
181 _transforms: Tuple[_CloneCallableType, ...] = ()
182
183 _resolved_bindparams: List[BindParameter[Any]]
184 parent_lambda: Optional[StatementLambdaElement] = None
185 closure_cache_key: Union[Tuple[Any, ...], Literal[CacheConst.NO_CACHE]]
186 role: Type[SQLRole]
187 _rec: Union[AnalyzedFunction, NonAnalyzedFunction]
188 fn: _AnyLambdaType
189 tracker_key: Tuple[CodeType, ...]
190
191 def __repr__(self):
192 return "%s(%r)" % (
193 self.__class__.__name__,
194 self.fn.__code__,
195 )
196
197 def __init__(
198 self,
199 fn: _LambdaType,
200 role: Type[SQLRole],
201 opts: Union[Type[LambdaOptions], LambdaOptions] = LambdaOptions,
202 apply_propagate_attrs: Optional[ClauseElement] = None,
203 ):
204 self.fn = fn
205 self.role = role
206 self.tracker_key = (fn.__code__,)
207 self.opts = opts
208
209 if apply_propagate_attrs is None and (role is roles.StatementRole):
210 apply_propagate_attrs = self

Callers 6

oneMethod · 0.90
twoMethod · 0.90
threeMethod · 0.90
fourMethod · 0.90
fiveMethod · 0.90
sixMethod · 0.90

Calls

no outgoing calls

Tested by 6

oneMethod · 0.72
twoMethod · 0.72
threeMethod · 0.72
fourMethod · 0.72
fiveMethod · 0.72
sixMethod · 0.72