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

Method _iter

lib/sqlalchemy/orm/query.py:2859–2880  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2857 raise
2858
2859 def _iter(self) -> Union[ScalarResult[_T], Result[_T]]:
2860 # new style execution.
2861 params = self._params
2862
2863 statement = self._statement_20()
2864 result: Union[ScalarResult[_T], Result[_T]] = self.session.execute(
2865 statement,
2866 params,
2867 execution_options={"_sa_orm_load_options": self.load_options},
2868 )
2869
2870 # legacy: automatically set scalars, unique
2871 if result._attributes.get("is_single_entity", False):
2872 result = cast("Result[_T]", result).scalars()
2873
2874 if (
2875 result._attributes.get("filtered", False)
2876 and not self.load_options._yield_per
2877 ):
2878 result = result.unique()
2879
2880 return result
2881
2882 def __str__(self) -> str:
2883 statement = self._statement_20()

Callers 5

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

Calls 6

_statement_20Method · 0.95
castFunction · 0.85
executeMethod · 0.45
getMethod · 0.45
scalarsMethod · 0.45
uniqueMethod · 0.45

Tested by

no test coverage detected