Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: support GRAPH and pipe syntax in dbapi
Recognize GRAPH and pipe syntax queries as valid queries
in dbapi.
  • Loading branch information
olavloite committed Jan 7, 2025
commit aeacda9c46424ef50281bac8f73da14254556615
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
Loading