Skip to content

Commit

Permalink
feat: support GRAPH and pipe syntax in dbapi (#1285)
Browse files Browse the repository at this point in the history
Recognize GRAPH and pipe syntax queries as valid queries
in dbapi.
  • Loading branch information
olavloite authored Jan 7, 2025
1 parent 7acf6dd commit 959bb9c
Show file tree
Hide file tree
Showing 2 changed files with 6 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 @@ -155,7 +155,7 @@
STMT_INSERT = "INSERT"

# Heuristic for identifying statements that don't need to be run as updates.
RE_NON_UPDATE = re.compile(r"^\W*(SELECT)", re.IGNORECASE)
RE_NON_UPDATE = re.compile(r"^\W*(SELECT|GRAPH|FROM)", re.IGNORECASE)

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

Expand Down
5 changes: 5 additions & 0 deletions tests/unit/spanner_dbapi/test_parse_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ def test_classify_stmt(self):
"WITH sq AS (SELECT SchoolID FROM Roster) SELECT * from sq",
StatementType.QUERY,
),
(
"GRAPH FinGraph MATCH (n) RETURN LABELS(n) AS label, n.id",
StatementType.QUERY,
),
("FROM Produce |> WHERE item != 'bananas'", StatementType.QUERY),
(
"CREATE TABLE django_content_type (id STRING(64) NOT NULL, name STRING(100) "
"NOT NULL, app_label STRING(100) NOT NULL, model STRING(100) NOT NULL) PRIMARY KEY(id)",
Expand Down

0 comments on commit 959bb9c

Please sign in to comment.