From: Denis Laxalde Date: Sat, 7 Jan 2023 07:31:41 +0000 (+0100) Subject: refactor: introduce BaseCursor._set_results() X-Git-Tag: pool-3.2.0~125^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06416219667b0286ec7001d93f4e36a2837aa8ed;p=thirdparty%2Fpsycopg.git refactor: introduce BaseCursor._set_results() Similar to _set_results_from_pipeline(), this applies to the non-pipeline case and reduce code repetition. --- diff --git a/psycopg/psycopg/cursor.py b/psycopg/psycopg/cursor.py index 8379c589a..30dcb9774 100644 --- a/psycopg/psycopg/cursor.py +++ b/psycopg/psycopg/cursor.py @@ -201,8 +201,7 @@ class BaseCursor(Generic[ConnectionType, Row]): else: assert results is not None self._check_results(results) - self._results = results - self._select_current_result(0) + self._set_results(results) self._last_query = query @@ -413,8 +412,7 @@ class BaseCursor(Generic[ConnectionType, Row]): raise e.ProgrammingError("COPY cannot be mixed with other operations") self._check_copy_result(results[0]) - self._results = results - self._select_current_result(0) + self._set_results(results) def _execute_send( self, @@ -529,6 +527,10 @@ class BaseCursor(Generic[ConnectionType, Row]): self._make_row = self._make_row_maker() + def _set_results(self, results: List["PGresult"]) -> None: + self._results = results + self._select_current_result(0) + def _set_results_from_pipeline(self, results: List["PGresult"]) -> None: self._check_results(results) first_batch = not self._results