Skip to content
This repository was archived by the owner on Jun 8, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions google/cloud/spanner_dbapi/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

"""Database cursor for Google Cloud Spanner DB API."""

import warnings
from collections import namedtuple

import sqlparse
Expand Down Expand Up @@ -137,15 +136,11 @@ def description(self):
def rowcount(self):
"""The number of rows produced by the last `execute()` call.

:raises: :class:`NotImplemented`.
The property is non-operational and always returns -1. Request
resulting rows are streamed by the `fetch*()` methods and
can't be counted before they are all streamed.
"""
warnings.warn(
"The `rowcount` property is non-operational. Request "
"resulting rows are streamed by the `fetch*()` methods "
"and can't be counted before they are all streamed.",
UserWarning,
stacklevel=2,
)
return -1

@check_not_closed
def callproc(self, procname, args=None):
Expand Down
12 changes: 2 additions & 10 deletions tests/unit/spanner_dbapi/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,11 @@ def test_property_description(self):
self.assertIsNotNone(cursor.description)
self.assertIsInstance(cursor.description[0], ColumnInfo)

@mock.patch("warnings.warn")
def test_property_rowcount(self, warn_mock):
def test_property_rowcount(self):
connection = self._make_connection(self.INSTANCE, self.DATABASE)
cursor = self._make_one(connection)

cursor.rowcount
warn_mock.assert_called_once_with(
"The `rowcount` property is non-operational. Request "
"resulting rows are streamed by the `fetch*()` methods "
"and can't be counted before they are all streamed.",
UserWarning,
stacklevel=2,
)
assert cursor.rowcount == -1

def test_callproc(self):
from google.cloud.spanner_dbapi.exceptions import InterfaceError
Expand Down