diff --git a/google/cloud/spanner_dbapi/parse_utils.py b/google/cloud/spanner_dbapi/parse_utils.py index 1744874764..aa0e12d75d 100644 --- a/google/cloud/spanner_dbapi/parse_utils.py +++ b/google/cloud/spanner_dbapi/parse_utils.py @@ -145,7 +145,7 @@ STMT_INSERT = "INSERT" # Heuristic for identifying statements that don't need to be run as updates. -RE_NON_UPDATE = re.compile(r"^\s*(SELECT)", re.IGNORECASE) +RE_NON_UPDATE = re.compile(r"^\W*(SELECT)", re.IGNORECASE) RE_WITH = re.compile(r"^\s*(WITH)", re.IGNORECASE) diff --git a/tests/unit/spanner_dbapi/test_parse_utils.py b/tests/unit/spanner_dbapi/test_parse_utils.py index 11239d730e..4de429076e 100644 --- a/tests/unit/spanner_dbapi/test_parse_utils.py +++ b/tests/unit/spanner_dbapi/test_parse_utils.py @@ -33,6 +33,7 @@ def test_classify_stmt(self): cases = ( ("SELECT 1", STMT_NON_UPDATING), ("SELECT s.SongName FROM Songs AS s", STMT_NON_UPDATING), + ("(SELECT s.SongName FROM Songs AS s)", STMT_NON_UPDATING), ( "WITH sq AS (SELECT SchoolID FROM Roster) SELECT * from sq", STMT_NON_UPDATING,