File tree 2 files changed +18
-7
lines changed
google/cloud/spanner_dbapi
2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change 14
14
15
15
"""Database cursor for Google Cloud Spanner DB-API."""
16
16
17
+ import warnings
18
+ from collections import namedtuple
19
+
17
20
import sqlparse
18
21
19
22
from google .api_core .exceptions import Aborted
23
26
from google .api_core .exceptions import InvalidArgument
24
27
from google .api_core .exceptions import OutOfRange
25
28
26
- from collections import namedtuple
27
-
28
29
from google .cloud import spanner_v1 as spanner
29
30
from google .cloud .spanner_dbapi .checksum import ResultsChecksum
30
31
from google .cloud .spanner_dbapi .exceptions import IntegrityError
@@ -120,10 +121,12 @@ def rowcount(self):
120
121
121
122
:raises: :class:`NotImplemented`.
122
123
"""
123
- raise NotImplementedError (
124
+ warnings . warn (
124
125
"The `rowcount` property is non-operational. Request "
125
126
"resulting rows are streamed by the `fetch*()` methods "
126
- "and can't be counted before they are all streamed."
127
+ "and can't be counted before they are all streamed." ,
128
+ UserWarning ,
129
+ stacklevel = 2 ,
127
130
)
128
131
129
132
def _raise_if_closed (self ):
Original file line number Diff line number Diff line change @@ -61,11 +61,19 @@ def test_property_description(self):
61
61
self .assertIsNotNone (cursor .description )
62
62
self .assertIsInstance (cursor .description [0 ], ColumnInfo )
63
63
64
- def test_property_rowcount (self ):
64
+ @mock .patch ("warnings.warn" )
65
+ def test_property_rowcount (self , warn_mock ):
65
66
connection = self ._make_connection (self .INSTANCE , self .DATABASE )
66
67
cursor = self ._make_one (connection )
67
- with self .assertRaises (NotImplementedError ):
68
- cursor .rowcount
68
+
69
+ cursor .rowcount
70
+ warn_mock .assert_called_once_with (
71
+ "The `rowcount` property is non-operational. Request "
72
+ "resulting rows are streamed by the `fetch*()` methods "
73
+ "and can't be counted before they are all streamed." ,
74
+ UserWarning ,
75
+ stacklevel = 2 ,
76
+ )
69
77
70
78
def test_callproc (self ):
71
79
from google .cloud .spanner_dbapi .exceptions import InterfaceError
You can’t perform that action at this time.
0 commit comments