Skip to content

Commit d526acc

Browse files
authored
fix: correctly classify select statements that begin with brackets (#351)
Co-authored-by: larkee <[email protected]>
1 parent 7d5a6e1 commit d526acc

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

google/cloud/spanner_dbapi/parse_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
STMT_INSERT = "INSERT"
146146

147147
# Heuristic for identifying statements that don't need to be run as updates.
148-
RE_NON_UPDATE = re.compile(r"^\s*(SELECT)", re.IGNORECASE)
148+
RE_NON_UPDATE = re.compile(r"^\W*(SELECT)", re.IGNORECASE)
149149

150150
RE_WITH = re.compile(r"^\s*(WITH)", re.IGNORECASE)
151151

tests/unit/spanner_dbapi/test_parse_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def test_classify_stmt(self):
3333
cases = (
3434
("SELECT 1", STMT_NON_UPDATING),
3535
("SELECT s.SongName FROM Songs AS s", STMT_NON_UPDATING),
36+
("(SELECT s.SongName FROM Songs AS s)", STMT_NON_UPDATING),
3637
(
3738
"WITH sq AS (SELECT SchoolID FROM Roster) SELECT * from sq",
3839
STMT_NON_UPDATING,

0 commit comments

Comments
 (0)