This repository was archived by the owner on Mar 31, 2026. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
google/cloud/spanner_dbapi Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -217,7 +217,7 @@ def _rerun_previous_statements(self):
217217 for statement in self ._statements :
218218 res_iter , retried_checksum = self .run_statement (statement , retried = True )
219219 # executing all the completed statements
220- if statement != self ._statements [- 1 ]:
220+ if statement != self ._statements [- 1 ] and not self . read_only :
221221 for res in res_iter :
222222 retried_checksum .consume_result (res )
223223
@@ -229,11 +229,13 @@ def _rerun_previous_statements(self):
229229 while len (retried_checksum ) < len (statement .checksum ):
230230 try :
231231 res = next (iter (res_iter ))
232- retried_checksum .consume_result (res )
232+ if not self .read_only :
233+ retried_checksum .consume_result (res )
233234 except StopIteration :
234235 break
235236
236- _compare_checksums (statement .checksum , retried_checksum )
237+ if not self .read_only :
238+ _compare_checksums (statement .checksum , retried_checksum )
237239
238240 def transaction_checkout (self ):
239241 """Get a Cloud Spanner transaction.
Original file line number Diff line number Diff line change @@ -272,7 +272,7 @@ def fetchone(self):
272272
273273 try :
274274 res = next (self )
275- if not self .connection .autocommit :
275+ if not self .connection .autocommit and not self . connection . read_only :
276276 self ._checksum .consume_result (res )
277277 return res
278278 except StopIteration :
@@ -290,7 +290,7 @@ def fetchall(self):
290290 res = []
291291 try :
292292 for row in self :
293- if not self .connection .autocommit :
293+ if not self .connection .autocommit and not self . connection . read_only :
294294 self ._checksum .consume_result (row )
295295 res .append (row )
296296 except Aborted :
@@ -319,7 +319,7 @@ def fetchmany(self, size=None):
319319 for i in range (size ):
320320 try :
321321 res = next (self )
322- if not self .connection .autocommit :
322+ if not self .connection .autocommit and not self . connection . read_only :
323323 self ._checksum .consume_result (res )
324324 items .append (res )
325325 except StopIteration :
You can’t perform that action at this time.
0 commit comments