Skip to content

Commit e6dffe0

Browse files
committed
Support Return Clause after Create Clause
Create Clause passes information to the next clause from the previous clause Create Clause supports variables Create Rescan method for CREATE clause. It will throw an error
1 parent a418c9a commit e6dffe0

File tree

8 files changed

+773
-110
lines changed

8 files changed

+773
-110
lines changed

regress/expected/cypher_create.out

Lines changed: 189 additions & 10 deletions
Large diffs are not rendered by default.

regress/sql/cypher_create.sql

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,75 @@ SELECT * FROM cypher('cypher_create', $$
102102
CREATE (a)-[:e_var {name: a.name + ' -> new node'}]->(:n_other_node)
103103
$$) as (a agtype);
104104

105+
SELECT * FROM cypher('cypher_create', $$
106+
MATCH (a:n_var)
107+
WHERE a.name = 'Node A'
108+
CREATE (a)-[b:e_var]->()
109+
$$) as (a agtype);
110+
111+
SELECT * FROM cypher('cypher_create', $$
112+
CREATE (a)-[:b_var]->()
113+
RETURN a, id(a)
114+
$$) as (a agtype, b agtype);
115+
116+
SELECT * FROM cypher('cypher_create', $$
117+
CREATE ()-[b:e_var]->()
118+
RETURN b, id(b)
119+
$$) as (a agtype, b agtype);
120+
121+
SELECT * FROM cypher('cypher_create', $$
122+
CREATE (a)-[b:e_var {id: 0}]->()
123+
RETURN a, b, b.id, b.id + 1
124+
$$) as (a agtype, b agtype, c agtype, d agtype);
125+
126+
SELECT * FROM cypher('cypher_create', $$
127+
MATCH (a:n_var)
128+
CREATE (a)-[b:e_var]->(a)
129+
RETURN a, b
130+
$$) as (a agtype, b agtype);
131+
132+
SELECT * FROM cypher('cypher_create', $$
133+
MATCH (a:n_var)
134+
CREATE (a)-[b:e_var]->(c)
135+
RETURN a, b, c
136+
$$) as (a agtype, b agtype, c agtype);
137+
138+
SELECT * FROM cypher('cypher_create', $$
139+
CREATE (a)-[:e_var]->()
140+
RETURN a
141+
$$) as (b agtype);
142+
143+
SELECT * FROM cypher('cypher_create', $$
144+
CREATE ()-[b:e_var]->()
145+
RETURN b
146+
$$) as (b agtype);
147+
148+
SELECT * FROM cypher('cypher_create', $$
149+
CREATE p=()-[:e_var]->()
150+
RETURN p
151+
$$) as (b agtype);
152+
153+
SELECT * FROM cypher('cypher_create', $$
154+
CREATE p=(a {id:0})-[:e_var]->(a)
155+
RETURN p
156+
$$) as (b agtype);
157+
158+
SELECT * FROM cypher('cypher_create', $$
159+
MATCH (a:n_var)
160+
CREATE p=(a)-[:e_var]->(a)
161+
RETURN p
162+
$$) as (b agtype);
163+
164+
SELECT * FROM cypher('cypher_create', $$
165+
CREATE p=(a)-[:e_var]->(), (a)-[b:e_var]->(a)
166+
RETURN p, b
167+
$$) as (a agtype, b agtype);
168+
105169
SELECT * FROM cypher('cypher_create', $$
106170
MATCH (a:n_var)
107171
WHERE a.name = 'Node Z'
108-
CREATE (a)-[:e_var {name: a.name + ' -> doesn''t exist'}]->(:n_other_node)
172+
CREATE (a)-[:e_var {name: a.name + ' -> doesnt exist'}]->(:n_other_node)
173+
RETURN a
109174
$$) as (a agtype);
110175

111176
SELECT * FROM cypher_create.n_var;
@@ -135,11 +200,27 @@ SELECT * FROM cypher('cypher_create', $$
135200
$$) as (a agtype);
136201

137202
SELECT * FROM cypher('cypher_create', $$
138-
MATCH (a:n_var)
203+
MATCH (a:n_var)-[b]-()
139204
WHERE a.name = 'Node A'
140205
CREATE (a)-[b:e_var]->()
141206
$$) as (a agtype);
142207

208+
-- Not a valid path
209+
SELECT * FROM cypher('cypher_create', $$
210+
CREATE p=(a)
211+
RETURN p
212+
$$) as (a agtype);
213+
214+
--CREATE with joins
215+
SELECT *
216+
FROM cypher('cypher_create', $$
217+
CREATE (a)
218+
RETURN a
219+
$$) as q(a agtype),
220+
cypher('cypher_create', $$
221+
CREATE (b)
222+
RETURN b
223+
$$) as t(b agtype);
143224

144225
-- column definition list for CREATE clause must contain a single agtype
145226
-- attribute

0 commit comments

Comments
 (0)