From: Daniele Varrazzo Date: Sun, 24 Jul 2022 00:37:56 +0000 (+0100) Subject: refactor(cursor): rename _set_current_result -> _select_current_result X-Git-Tag: 3.1~44^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40500306a33d39f767c2fa602bbb3dde34bc1af1;p=thirdparty%2Fpsycopg.git refactor(cursor): rename _set_current_result -> _select_current_result --- diff --git a/psycopg/psycopg/cursor.py b/psycopg/psycopg/cursor.py index 77ad80788..2444706c0 100644 --- a/psycopg/psycopg/cursor.py +++ b/psycopg/psycopg/cursor.py @@ -168,7 +168,7 @@ class BaseCursor(Generic[ConnectionType, Row]): methods `!fetch*()` will operate on. """ if self._iresult < len(self._results) - 1: - self._set_current_result(self._iresult + 1) + self._select_current_result(self._iresult + 1) return True else: return None @@ -214,7 +214,7 @@ class BaseCursor(Generic[ConnectionType, Row]): assert results is not None self._check_results(results) self._results = results - self._set_current_result(0) + self._select_current_result(0) self._last_query = query @@ -283,7 +283,7 @@ class BaseCursor(Generic[ConnectionType, Row]): nrows += res.command_tuples or 0 if self._results: - self._set_current_result(0) + self._select_current_result(0) # Override rowcount for the first result. Calls to nextset() will change # it to the value of that result only, but we hope nobody will notice. @@ -515,7 +515,9 @@ class BaseCursor(Generic[ConnectionType, Row]): "unexpected result status from query:" f" {pq.ExecStatus(status).name}" ) - def _set_current_result(self, i: int, format: Optional[pq.Format] = None) -> None: + def _select_current_result( + self, i: int, format: Optional[pq.Format] = None + ) -> None: """ Select one of the results in the cursor as the active one. """ @@ -540,14 +542,14 @@ class BaseCursor(Generic[ConnectionType, Row]): # Received from execute() self._results.extend(results) if first_batch: - self._set_current_result(0) + self._select_current_result(0) else: # Received from executemany() if self._execmany_returning: self._results.extend(results) if first_batch: - self._set_current_result(0) + self._select_current_result(0) self._rowcount = 0 # Override rowcount for the first result. Calls to nextset() will diff --git a/psycopg/psycopg/server_cursor.py b/psycopg/psycopg/server_cursor.py index 0e77a6fdd..058cf9327 100644 --- a/psycopg/psycopg/server_cursor.py +++ b/psycopg/psycopg/server_cursor.py @@ -113,7 +113,7 @@ class ServerCursorMixin(BaseCursor[ConnectionType, Row]): results = yield from execute(self._pgconn) self._check_results(results) self._results = results - self._set_current_result(0, format=self._format) + self._select_current_result(0, format=self._format) self._described = True def _close_gen(self) -> PQGen[None]: