Skip to content
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
2 changes: 1 addition & 1 deletion google/cloud/spanner_dbapi/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def read_only(self, value):
Args:
value (bool): True for ReadOnly mode, False for ReadWrite.
"""
if self._spanner_transaction_started:
if self._read_only != value and self._spanner_transaction_started:
raise ValueError(
"Connection read/write mode can't be changed while a transaction is in progress. "
"Commit or rollback the current transaction and try again."
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/spanner_dbapi/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ def test_read_only_connection(self):
):
connection.read_only = False

# Verify that we can set the value to the same value as it already has.
connection.read_only = True
self.assertTrue(connection.read_only)

connection._spanner_transaction_started = False
connection.read_only = False
self.assertFalse(connection.read_only)
Expand Down
Loading