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

Method _rewind

lib/sqlalchemy/engine/cursor.py:1965–1995  ·  view source on GitHub ↗

rewind this result back to the given rowset. this is used internally for the case where an :class:`.Insert` construct combines the use of :meth:`.Insert.return_defaults` along with the "supplemental columns" feature.

(self, rows: Any)

Source from the content-addressed store, hash-verified

1963 return clone
1964
1965 def _rewind(self, rows: Any) -> Self:
1966 """rewind this result back to the given rowset.
1967
1968 this is used internally for the case where an :class:`.Insert`
1969 construct combines the use of
1970 :meth:`.Insert.return_defaults` along with the
1971 "supplemental columns" feature.
1972
1973 """
1974
1975 if self._echo:
1976 self.context.connection._log_debug(
1977 "CursorResult rewound %d row(s)", len(rows)
1978 )
1979
1980 # the rows given are expected to be Row objects, so we
1981 # have to clear out processors which have already run on these
1982 # rows
1983 self._metadata = cast(
1984 CursorResultMetaData, self._metadata
1985 )._remove_processors()
1986
1987 self.cursor_strategy = FullyBufferedCursorFetchStrategy(
1988 None,
1989 # TODO: if these are Row objects, can we save on not having to
1990 # re-make new Row objects out of them a second time? is that
1991 # what's actually happening right now? maybe look into this
1992 initial_buffer=rows,
1993 )
1994 self._reset_memoizations()
1995 return self
1996
1997 @property
1998 def returned_defaults(self) -> Optional[Row[Any]]:

Callers 1

Calls 5

castFunction · 0.85
_remove_processorsMethod · 0.80
_reset_memoizationsMethod · 0.80
_log_debugMethod · 0.45

Tested by

no test coverage detected