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

Method __call__

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

__getattribute__Method · 0.45

Tested by

no test coverage detected