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

Method _iter

lib/sqlalchemy/orm/dynamic.py:150–173  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

148 self.sess = session
149
150 def _iter(self) -> Union[result.ScalarResult[_T], result.Result[_T]]:
151 sess = self.session
152 if sess is None:
153 state = attributes.instance_state(self.instance)
154 if state.detached:
155 util.warn(
156 "Instance %s is detached, dynamic relationship cannot "
157 "return a correct result. This warning will become "
158 "a DetachedInstanceError in a future release."
159 % (orm_util.state_str(state))
160 )
161
162 return result.IteratorResult(
163 result.SimpleResultMetaData([self.attr.class_.__name__]),
164 iter(
165 self.attr._get_collection_history(
166 attributes.instance_state(self.instance),
167 PassiveFlag.PASSIVE_NO_INITIALIZE,
168 ).added_items
169 ),
170 _source_supports_scalars=True,
171 ).scalars()
172 else:
173 return self._generate(sess)._iter()
174
175 if TYPE_CHECKING:
176

Callers

nothing calls this directly

Calls 4

_generateMethod · 0.95
warnMethod · 0.45
scalarsMethod · 0.45

Tested by

no test coverage detected