MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / __call__

Method __call__

lib/sqlalchemy/sql/lambdas.py:1315–1344  ·  view source on GitHub ↗
(self, *arg, **kw)

Source from the content-addressed store, hash-verified

1313 self.track_bound_values = track_bound_values
1314
1315 def __call__(self, *arg, **kw):
1316 elem = object.__getattribute__(self, "_to_evaluate")
1317 value = elem(*arg, **kw)
1318 if (
1319 self._sa_track_bound_values
1320 and coercions._deep_is_literal(value)
1321 and not isinstance(
1322 # TODO: coverage where an ORM option or similar is here
1323 value,
1324 _cache_key.HasCacheKey,
1325 )
1326 ):
1327 name = object.__getattribute__(self, "_name")
1328 raise exc.InvalidRequestError(
1329 "Can't invoke Python callable %s() inside of lambda "
1330 "expression argument at %s; lambda SQL constructs should "
1331 "not invoke functions from closure variables to produce "
1332 "literal values since the "
1333 "lambda SQL system normally extracts bound values without "
1334 "actually "
1335 "invoking the lambda or any functions within it. Call the "
1336 "function outside of the "
1337 "lambda and assign to a local variable that is used in the "
1338 "lambda as a closure variable, or set "
1339 "track_bound_values=False if the return value of this "
1340 "function is used in some other way other than a SQL bound "
1341 "value." % (name, self._sa_fn.__code__)
1342 )
1343 else:
1344 return value
1345
1346 def operate(self, op, *other, **kwargs):
1347 elem = object.__getattribute__(self, "_py_wrapper_literal")()

Callers

nothing calls this directly

Calls 1

__getattribute__Method · 0.45

Tested by

no test coverage detected