MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _iter

Method _iter

lib/sqlalchemy/ext/baked.py:370–407  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

368 return self._iter().__iter__()
369
370 def _iter(self):
371 bq = self.bq
372
373 if not self.session.enable_baked_queries or bq._spoiled:
374 return self._as_query()._iter()
375
376 query, statement = bq._bakery.get(
377 bq._effective_key(self.session), (None, None)
378 )
379 if query is None:
380 query, statement = bq._bake(self.session)
381
382 if self._params:
383 q = query.params(self._params)
384 else:
385 q = query
386 for fn in self._post_criteria:
387 q = fn(q)
388
389 params = q._params
390 execution_options = dict(q._execution_options)
391 execution_options.update(
392 {
393 "_sa_orm_load_options": q.load_options,
394 "compiled_cache": bq._bakery,
395 }
396 )
397
398 result = self.session.execute(
399 statement, params, execution_options=execution_options
400 )
401 if result._attributes.get("is_single_entity", False):
402 result = result.scalars()
403
404 if result._attributes.get("filtered", False):
405 result = result.unique()
406
407 return result
408
409 def count(self):
410 """return the 'count'.

Callers 5

__iter__Method · 0.95
oneMethod · 0.95
one_or_noneMethod · 0.95
allMethod · 0.95
firstMethod · 0.45

Calls 9

_as_queryMethod · 0.95
_effective_keyMethod · 0.80
_bakeMethod · 0.80
getMethod · 0.45
paramsMethod · 0.45
updateMethod · 0.45
executeMethod · 0.45
scalarsMethod · 0.45
uniqueMethod · 0.45

Tested by

no test coverage detected