MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _rewind

Method _rewind

lib/sqlalchemy/engine/cursor.py:2078–2111  ·  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. NOTE: this method has not effect then an

(self, rows: Any)

Source from the content-addressed store, hash-verified

2076 return clone
2077
2078 def _rewind(self, rows: Any) -> Self:
2079 """rewind this result back to the given rowset.
2080
2081 this is used internally for the case where an :class:`.Insert`
2082 construct combines the use of
2083 :meth:`.Insert.return_defaults` along with the
2084 "supplemental columns" feature.
2085
2086 NOTE: this method has not effect then an unique filter is applied
2087 to the result, meaning that no row will be returned.
2088
2089 """
2090
2091 if self._echo:
2092 self.context.connection._log_debug(
2093 "CursorResult rewound %d row(s)", len(rows)
2094 )
2095
2096 # the rows given are expected to be Row objects, so we
2097 # have to clear out processors which have already run on these
2098 # rows
2099 self._metadata = cast(
2100 CursorResultMetaData, self._metadata
2101 )._remove_processors_and_tuple_filter()
2102
2103 self.cursor_strategy = FullyBufferedCursorFetchStrategy(
2104 None,
2105 # TODO: if these are Row objects, can we save on not having to
2106 # re-make new Row objects out of them a second time? is that
2107 # what's actually happening right now? maybe look into this
2108 initial_buffer=rows,
2109 )
2110 self._reset_memoizations()
2111 return self
2112
2113 @property
2114 def returned_defaults(self) -> Optional[Row[Unpack[TupleAny]]]:

Callers 3

test_generative_casesMethod · 0.80

Calls 5

_reset_memoizationsMethod · 0.80
castFunction · 0.50
_log_debugMethod · 0.45

Tested by 2

test_generative_casesMethod · 0.64