From a0ff8aeb68275bb97ba25aa3c6461591dd5467ae Mon Sep 17 00:00:00 2001 From: apstndb <803393+apstndb@users.noreply.github.com> Date: Fri, 2 Aug 2024 21:35:59 +0900 Subject: [PATCH] Support GRAPH statement (#181) --- statement.go | 2 +- statement_test.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/statement.go b/statement.go index 92e70f9..7ff6641 100644 --- a/statement.go +++ b/statement.go @@ -82,7 +82,7 @@ type QueryStats struct { var ( // SQL - selectRe = regexp.MustCompile(`(?is)^(?:WITH|CALL|@{.+|SELECT)\s.+$`) + selectRe = regexp.MustCompile(`(?is)^(?:WITH|CALL|@{.+|SELECT|GRAPH)\s.+$`) // DDL createDatabaseRe = regexp.MustCompile(`(?is)^CREATE\s+DATABASE\s.+$`) diff --git a/statement_test.go b/statement_test.go index 5236fcb..0655649 100644 --- a/statement_test.go +++ b/statement_test.go @@ -507,6 +507,21 @@ func TestBuildStatement(t *testing.T) { input: "EXPLAIN WITH t1 AS (SELECT 1) SELECT * FROM t1", want: &ExplainStatement{Explain: "WITH t1 AS (SELECT 1) SELECT * FROM t1"}, }, + { + desc: "GRAPH statement", + input: "GRAPH FinGraph MATCH (n) RETURN LABELS(n) AS label, n.id", + want: &SelectStatement{Query: "GRAPH FinGraph MATCH (n) RETURN LABELS(n) AS label, n.id"}, + }, + { + desc: "EXPLAIN GRAPH statement", + input: "EXPLAIN GRAPH FinGraph MATCH (n) RETURN LABELS(n) AS label, n.id", + want: &ExplainStatement{Explain: "GRAPH FinGraph MATCH (n) RETURN LABELS(n) AS label, n.id"}, + }, + { + desc: "EXPLAIN ANALYZE GRAPH statement", + input: "EXPLAIN ANALYZE GRAPH FinGraph MATCH (n) RETURN LABELS(n) AS label, n.id", + want: &ExplainAnalyzeStatement{Query: "GRAPH FinGraph MATCH (n) RETURN LABELS(n) AS label, n.id"}, + }, { desc: "DESCRIBE SELECT statement", input: "DESCRIBE SELECT * FROM t1",