From: Fedor Kobak <56638067+fedorkobak@users.noreply.github.com> Date: Sun, 4 May 2025 10:52:23 +0000 (+0300) Subject: docs: use "result set" consistently X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=efa7db38c5c6b80a72ea3dc39bc7e300e73b57ff;p=thirdparty%2Fpsycopg.git docs: use "result set" consistently fix `statusmessage` docs to reflect the fact that it refers to the current result, not the last one, as it was in psycopg2. Improve docs consistency about other attributes which might be affected by current result. See #1062. --- diff --git a/docs/api/cursors.rst b/docs/api/cursors.rst index 64af11e4f..e1f6d0b02 100644 --- a/docs/api/cursors.rst +++ b/docs/api/cursors.rst @@ -232,7 +232,7 @@ The `!Cursor` class .. rubric:: Methods to retrieve results - Fetch methods are only available if the last operation produced results, + Fetch methods are only available if the current result set contains results, e.g. a :sql:`SELECT` or a command with :sql:`RETURNING`. They will raise an exception if used with operations that don't return result, such as an :sql:`INSERT` with no :sql:`RETURNING` or an :sql:`ALTER TABLE`. @@ -244,7 +244,7 @@ The `!Cursor` class for record in cursor: ... - syntax will iterate on the records in the current recordset. + syntax will iterate on the records in the current result set. .. autoattribute:: row_factory @@ -263,10 +263,9 @@ The `!Cursor` class .. attribute:: pgresult :type: Optional[psycopg.pq.PGresult] - The result returned by the last query and currently exposed by the - cursor, if available, else `!None`. + Representation of the current result set, if available, else `!None`. - It can be used to obtain low level info about the last query result + It can be used to obtain low level info about the current result set and to access to features not currently wrapped by Psycopg. diff --git a/psycopg/psycopg/_cursor_base.py b/psycopg/psycopg/_cursor_base.py index 89c636632..7fa31125c 100644 --- a/psycopg/psycopg/_cursor_base.py +++ b/psycopg/psycopg/_cursor_base.py @@ -127,12 +127,15 @@ class BaseCursor(Generic[ConnectionType, Row]): @property def rowcount(self) -> int: - """Number of records affected by the precedent operation.""" + """ + Number of records affected by the operation that produced + the current result set. + """ return self._rowcount @property def rownumber(self) -> int | None: - """Index of the next row to fetch in the current result. + """Index of the next row to fetch in the current result set. `!None` if there is no result to fetch. """ @@ -164,7 +167,7 @@ class BaseCursor(Generic[ConnectionType, Row]): @property def statusmessage(self) -> str | None: """ - The command status tag from the last SQL command executed. + The status tag of the current result set. `!None` if the cursor doesn't have a result available. """ diff --git a/psycopg/psycopg/cursor.py b/psycopg/psycopg/cursor.py index fb2df08eb..25449e384 100644 --- a/psycopg/psycopg/cursor.py +++ b/psycopg/psycopg/cursor.py @@ -179,9 +179,9 @@ class Cursor(BaseCursor["Connection[Any]", Row]): def fetchone(self) -> Row | None: """ - Return the next record from the current recordset. + Return the next record from the current result set. - Return `!None` the recordset is finished. + Return `!None` the result set is finished. :rtype: Row | None, with Row defined by `row_factory` """ @@ -193,7 +193,7 @@ class Cursor(BaseCursor["Connection[Any]", Row]): def fetchmany(self, size: int = 0) -> list[Row]: """ - Return the next `!size` records from the current recordset. + Return the next `!size` records from the current result set. `!size` default to `!self.arraysize` if not specified. @@ -213,7 +213,7 @@ class Cursor(BaseCursor["Connection[Any]", Row]): def fetchall(self) -> list[Row]: """ - Return all the remaining records from the current recordset. + Return all the remaining records from the current result set. :rtype: Sequence[Row], with Row defined by `row_factory` """ diff --git a/psycopg/psycopg/cursor_async.py b/psycopg/psycopg/cursor_async.py index 4c6bdc55f..0601088d9 100644 --- a/psycopg/psycopg/cursor_async.py +++ b/psycopg/psycopg/cursor_async.py @@ -183,9 +183,9 @@ class AsyncCursor(BaseCursor["AsyncConnection[Any]", Row]): async def fetchone(self) -> Row | None: """ - Return the next record from the current recordset. + Return the next record from the current result set. - Return `!None` the recordset is finished. + Return `!None` the result set is finished. :rtype: Row | None, with Row defined by `row_factory` """ @@ -197,7 +197,7 @@ class AsyncCursor(BaseCursor["AsyncConnection[Any]", Row]): async def fetchmany(self, size: int = 0) -> list[Row]: """ - Return the next `!size` records from the current recordset. + Return the next `!size` records from the current result set. `!size` default to `!self.arraysize` if not specified. @@ -217,7 +217,7 @@ class AsyncCursor(BaseCursor["AsyncConnection[Any]", Row]): async def fetchall(self) -> list[Row]: """ - Return all the remaining records from the current recordset. + Return all the remaining records from the current result set. :rtype: Sequence[Row], with Row defined by `row_factory` """