Skip to content

Commit

Permalink
Support GRAPH statement (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
apstndb authored Aug 2, 2024
1 parent 9a93cfa commit a0ff8ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.+$`)
Expand Down
15 changes: 15 additions & 0 deletions statement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit a0ff8ae

Please sign in to comment.