Skip to content

Commit

Permalink
fix: correctly classify select statements that begin with brackets (#351
Browse files Browse the repository at this point in the history
)

Co-authored-by: larkee <larkee@users.noreply.github.com>
  • Loading branch information
larkee and larkee committed May 19, 2021
1 parent 7d5a6e1 commit d526acc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion google/cloud/spanner_dbapi/parse_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions tests/unit/spanner_dbapi/test_parse_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d526acc

Please sign in to comment.