Skip to content

Commit 959bb9c

Browse files
authored
feat: support GRAPH and pipe syntax in dbapi (#1285)
Recognize GRAPH and pipe syntax queries as valid queries in dbapi.
1 parent 7acf6dd commit 959bb9c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

google/cloud/spanner_dbapi/parse_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
STMT_INSERT = "INSERT"
156156

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

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

tests/unit/spanner_dbapi/test_parse_utils.py

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ def test_classify_stmt(self):
3939
"WITH sq AS (SELECT SchoolID FROM Roster) SELECT * from sq",
4040
StatementType.QUERY,
4141
),
42+
(
43+
"GRAPH FinGraph MATCH (n) RETURN LABELS(n) AS label, n.id",
44+
StatementType.QUERY,
45+
),
46+
("FROM Produce |> WHERE item != 'bananas'", StatementType.QUERY),
4247
(
4348
"CREATE TABLE django_content_type (id STRING(64) NOT NULL, name STRING(100) "
4449
"NOT NULL, app_label STRING(100) NOT NULL, model STRING(100) NOT NULL) PRIMARY KEY(id)",

0 commit comments

Comments
 (0)