-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed some new compiler warnings
- Loading branch information
Showing
5 changed files
with
410 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,283 @@ | ||
/* | ||
* Copyright 2020 Bitnine Co., Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
LOAD 'age'; | ||
SET search_path TO ag_catalog; | ||
SELECT create_graph('cypher_remove'); | ||
NOTICE: graph "cypher_remove" has been created | ||
create_graph | ||
-------------- | ||
|
||
(1 row) | ||
|
||
--test 1 | ||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_1)$$) AS (a agtype); | ||
a | ||
--- | ||
(0 rows) | ||
|
||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_1 {i: 0, j: 5, a: 0})$$) AS (a agtype); | ||
a | ||
--- | ||
(0 rows) | ||
|
||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_1 {i: 1})$$) AS (a agtype); | ||
a | ||
--- | ||
(0 rows) | ||
|
||
SELECT * FROM cypher('cypher_remove', $$MATCH (n:test_1) REMOVE n.i $$) AS (a agtype); | ||
a | ||
--- | ||
(0 rows) | ||
|
||
SELECT * FROM cypher('cypher_remove', $$MATCH (n:test_1) RETURN n$$) AS (a agtype); | ||
a | ||
------------------------------------------------------------------------------------ | ||
{"id": 844424930131969, "label": "test_1", "properties": {}}::vertex | ||
{"id": 844424930131970, "label": "test_1", "properties": {"a": 0, "j": 5}}::vertex | ||
{"id": 844424930131971, "label": "test_1", "properties": {}}::vertex | ||
(3 rows) | ||
|
||
--test 2 | ||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_2)$$) AS (a agtype); | ||
a | ||
--- | ||
(0 rows) | ||
|
||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_2 {i: 0, j: 5, a: 0})$$) AS (a agtype); | ||
a | ||
--- | ||
(0 rows) | ||
|
||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_2 {i: 1})$$) AS (a agtype); | ||
a | ||
--- | ||
(0 rows) | ||
|
||
SELECT * FROM cypher('cypher_remove', $$MATCH (n:test_2) REMOVE n.j RETURN n$$) AS (a agtype); | ||
a | ||
------------------------------------------------------------------------------------- | ||
{"id": 1125899906842625, "label": "test_2", "properties": {}}::vertex | ||
{"id": 1125899906842626, "label": "test_2", "properties": {"a": 0, "i": 0}}::vertex | ||
{"id": 1125899906842627, "label": "test_2", "properties": {"i": 1}}::vertex | ||
(3 rows) | ||
|
||
SELECT * FROM cypher('cypher_remove', $$MATCH (n:test_2) RETURN n$$) AS (a agtype); | ||
a | ||
------------------------------------------------------------------------------------- | ||
{"id": 1125899906842625, "label": "test_2", "properties": {}}::vertex | ||
{"id": 1125899906842626, "label": "test_2", "properties": {"a": 0, "i": 0}}::vertex | ||
{"id": 1125899906842627, "label": "test_2", "properties": {"i": 1}}::vertex | ||
(3 rows) | ||
|
||
--test 3 Validate Paths are updated | ||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_3 { i : 20 } )-[:test_3_edge {j:20}]->(:test_3 {i:10})$$) AS (a agtype); | ||
a | ||
--- | ||
(0 rows) | ||
|
||
SELECT * FROM cypher('cypher_remove', $$MATCH p=(n)-[:test_3_edge]->() REMOVE n.i RETURN p$$) AS (a agtype); | ||
a | ||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
[{"id": 1407374883553281, "label": "test_3", "properties": {}}::vertex, {"id": 1688849860263937, "label": "test_3_edge", "end_id": 1407374883553282, "start_id": 1407374883553281, "properties": {"j": 20}}::edge, {"id": 1407374883553282, "label": "test_3", "properties": {"i": 10}}::vertex]::path | ||
(1 row) | ||
|
||
--test 4 Edges | ||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_4 { i : 20 } )-[:test_4_edge {j:20}]->(:test_4 {i:10})$$) AS (a agtype); | ||
a | ||
--- | ||
(0 rows) | ||
|
||
SELECT * FROM cypher('cypher_remove', $$MATCH ()-[n]->(:test_4) REMOVE n.i RETURN n$$) AS (a agtype); | ||
a | ||
------------------------------------------------------------------------------------------------------------------------------------------- | ||
{"id": 2251799813685249, "label": "test_4_edge", "end_id": 1970324836974594, "start_id": 1970324836974593, "properties": {"j": 20}}::edge | ||
(1 row) | ||
|
||
SELECT * FROM cypher('cypher_remove', $$MATCH ()-[n]->(:test_4) RETURN n$$) AS (a agtype); | ||
a | ||
------------------------------------------------------------------------------------------------------------------------------------------- | ||
{"id": 2251799813685249, "label": "test_4_edge", "end_id": 1970324836974594, "start_id": 1970324836974593, "properties": {"j": 20}}::edge | ||
(1 row) | ||
|
||
--test 5 two REMOVE clauses | ||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_5 {i: 1, j : 2, k : 3}) $$) AS (a agtype); | ||
a | ||
--- | ||
(0 rows) | ||
|
||
SELECT * FROM cypher('cypher_remove', $$ | ||
MATCH (n:test_5) | ||
REMOVE n.i | ||
REMOVE n.j | ||
RETURN n | ||
$$) AS (a agtype); | ||
a | ||
----------------------------------------------------------------------------- | ||
{"id": 2533274790395905, "label": "test_5", "properties": {"k": 3}}::vertex | ||
(1 row) | ||
|
||
SELECT * FROM cypher('cypher_remove', $$ | ||
MATCH (n:test_5) | ||
RETURN n | ||
$$) AS (a agtype); | ||
a | ||
----------------------------------------------------------------------------- | ||
{"id": 2533274790395905, "label": "test_5", "properties": {"k": 3}}::vertex | ||
(1 row) | ||
|
||
--test 6 Create a loop and see that set can work after create | ||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_6 {j: 5, y: 99})$$) AS (a agtype); | ||
a | ||
--- | ||
(0 rows) | ||
|
||
SELECT * FROM cypher('cypher_remove', $$ | ||
MATCH (n {j: 5}) | ||
CREATE p=(n)-[e:e {j:34}]->(n) | ||
REMOVE n.y | ||
RETURN n, p | ||
$$) AS (a agtype, b agtype); | ||
a | b | ||
------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
{"id": 844424930131970, "label": "test_1", "properties": {"a": 0, "j": 5}}::vertex | [{"id": 844424930131970, "label": "test_1", "properties": {"a": 0, "j": 5}}::vertex, {"id": 3096224743817217, "label": "e", "end_id": 844424930131970, "start_id": 844424930131970, "properties": {"j": 34}}::edge, {"id": 844424930131970, "label": "test_1", "properties": {"a": 0, "j": 5}}::vertex]::path | ||
{"id": 2814749767106561, "label": "test_6", "properties": {"j": 5}}::vertex | [{"id": 2814749767106561, "label": "test_6", "properties": {"j": 5}}::vertex, {"id": 3096224743817218, "label": "e", "end_id": 2814749767106561, "start_id": 2814749767106561, "properties": {"j": 34}}::edge, {"id": 2814749767106561, "label": "test_6", "properties": {"j": 5}}::vertex]::path | ||
(2 rows) | ||
|
||
SELECT * FROM cypher('cypher_remove', $$MATCH (n:test_6) RETURN n$$) AS (a agtype); | ||
a | ||
----------------------------------------------------------------------------- | ||
{"id": 2814749767106561, "label": "test_6", "properties": {"j": 5}}::vertex | ||
(1 row) | ||
|
||
--test 7 Create a loop and see that set can work after create | ||
SELECT * FROM cypher('cypher_remove', $$ | ||
CREATE (:test_7)-[e:e {j:34}]->() | ||
REMOVE e.y | ||
RETURN e | ||
$$) AS (a agtype); | ||
a | ||
-------------------------------------------------------------------------------------------------------------------------------- | ||
{"id": 3096224743817219, "label": "e", "end_id": 281474976710657, "start_id": 3377699720527873, "properties": {"j": 34}}::edge | ||
(1 row) | ||
|
||
SELECT * FROM cypher('cypher_remove', $$MATCH (n:test_7) RETURN n$$) AS (a agtype); | ||
a | ||
----------------------------------------------------------------------- | ||
{"id": 3377699720527873, "label": "test_7", "properties": {}}::vertex | ||
(1 row) | ||
|
||
--test 8 | ||
SELECT * FROM cypher('cypher_remove', $$ | ||
MATCH (n:test_7) | ||
MATCH (n)-[e:e {j:34}]->() | ||
REMOVE n.y | ||
RETURN n | ||
$$) AS (a agtype); | ||
a | ||
----------------------------------------------------------------------- | ||
{"id": 3377699720527873, "label": "test_7", "properties": {}}::vertex | ||
(1 row) | ||
|
||
--Handle Inheritance | ||
SELECT * FROM cypher('cypher_remove', $$CREATE ( {i : 1 })$$) AS (a agtype); | ||
a | ||
--- | ||
(0 rows) | ||
|
||
SELECT * FROM cypher('cypher_remove', $$MATCH (n) REMOVE n.i RETURN n$$) AS (a agtype); | ||
a | ||
------------------------------------------------------------------------------------ | ||
{"id": 281474976710657, "label": "", "properties": {}}::vertex | ||
{"id": 281474976710658, "label": "", "properties": {}}::vertex | ||
{"id": 844424930131969, "label": "test_1", "properties": {}}::vertex | ||
{"id": 844424930131971, "label": "test_1", "properties": {}}::vertex | ||
{"id": 844424930131970, "label": "test_1", "properties": {"a": 0, "j": 5}}::vertex | ||
{"id": 1125899906842625, "label": "test_2", "properties": {}}::vertex | ||
{"id": 1125899906842626, "label": "test_2", "properties": {"a": 0}}::vertex | ||
{"id": 1125899906842627, "label": "test_2", "properties": {}}::vertex | ||
{"id": 1407374883553282, "label": "test_3", "properties": {}}::vertex | ||
{"id": 1407374883553281, "label": "test_3", "properties": {}}::vertex | ||
{"id": 1970324836974593, "label": "test_4", "properties": {}}::vertex | ||
{"id": 1970324836974594, "label": "test_4", "properties": {}}::vertex | ||
{"id": 2533274790395905, "label": "test_5", "properties": {"k": 3}}::vertex | ||
{"id": 2814749767106561, "label": "test_6", "properties": {"j": 5}}::vertex | ||
{"id": 3377699720527873, "label": "test_7", "properties": {}}::vertex | ||
(15 rows) | ||
|
||
SELECT * FROM cypher('cypher_remove', $$MATCH (n) RETURN n$$) AS (a agtype); | ||
a | ||
------------------------------------------------------------------------------------ | ||
{"id": 281474976710657, "label": "", "properties": {}}::vertex | ||
{"id": 281474976710658, "label": "", "properties": {}}::vertex | ||
{"id": 844424930131969, "label": "test_1", "properties": {}}::vertex | ||
{"id": 844424930131971, "label": "test_1", "properties": {}}::vertex | ||
{"id": 844424930131970, "label": "test_1", "properties": {"a": 0, "j": 5}}::vertex | ||
{"id": 1125899906842625, "label": "test_2", "properties": {}}::vertex | ||
{"id": 1125899906842626, "label": "test_2", "properties": {"a": 0}}::vertex | ||
{"id": 1125899906842627, "label": "test_2", "properties": {}}::vertex | ||
{"id": 1407374883553282, "label": "test_3", "properties": {}}::vertex | ||
{"id": 1407374883553281, "label": "test_3", "properties": {}}::vertex | ||
{"id": 1970324836974593, "label": "test_4", "properties": {}}::vertex | ||
{"id": 1970324836974594, "label": "test_4", "properties": {}}::vertex | ||
{"id": 2533274790395905, "label": "test_5", "properties": {"k": 3}}::vertex | ||
{"id": 2814749767106561, "label": "test_6", "properties": {"j": 5}}::vertex | ||
{"id": 3377699720527873, "label": "test_7", "properties": {}}::vertex | ||
(15 rows) | ||
|
||
--Errors | ||
SELECT * FROM cypher('cypher_remove', $$REMOVE n.i$$) AS (a agtype); | ||
ERROR: REMOVE cannot be the first clause in a Cypher query | ||
LINE 1: SELECT * FROM cypher('cypher_remove', $$REMOVE n.i$$) AS (a ... | ||
^ | ||
SELECT * FROM cypher('cypher_remove', $$MATCH (n) REMOVE n.i = NULL$$) AS (a agtype); | ||
ERROR: REMOVE clause must be in the format: REMOVE variable.property_name | ||
LINE 1: SELECT * FROM cypher('cypher_remove', $$MATCH (n) REMOVE n.i... | ||
^ | ||
SELECT * FROM cypher('cypher_remove', $$MATCH (n) REMOVE wrong_var.i$$) AS (a agtype); | ||
ERROR: undefined reference to variable wrong_var in REMOVE clause | ||
LINE 1: SELECT * FROM cypher('cypher_remove', $$MATCH (n) REMOVE wro... | ||
^ | ||
SELECT * FROM cypher('cypher_remove', $$MATCH (n) REMOVE n.i = 3, n.j = 5 $$) AS (a agtype); | ||
ERROR: REMOVE clause does not yet support updating more than one property | ||
LINE 1: SELECT * FROM cypher('cypher_remove', $$MATCH (n) REMOVE n.i... | ||
^ | ||
-- | ||
-- Clean up | ||
-- | ||
SELECT drop_graph('cypher_remove', true); | ||
NOTICE: drop cascades to 12 other objects | ||
DETAIL: drop cascades to table cypher_remove._ag_label_vertex | ||
drop cascades to table cypher_remove._ag_label_edge | ||
drop cascades to table cypher_remove.test_1 | ||
drop cascades to table cypher_remove.test_2 | ||
drop cascades to table cypher_remove.test_3 | ||
drop cascades to table cypher_remove.test_3_edge | ||
drop cascades to table cypher_remove.test_4 | ||
drop cascades to table cypher_remove.test_4_edge | ||
drop cascades to table cypher_remove.test_5 | ||
drop cascades to table cypher_remove.test_6 | ||
drop cascades to table cypher_remove.e | ||
drop cascades to table cypher_remove.test_7 | ||
NOTICE: graph "cypher_remove" has been dropped | ||
drop_graph | ||
------------ | ||
|
||
(1 row) | ||
|
||
-- | ||
-- End | ||
-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
* Copyright 2020 Bitnine Co., Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
LOAD 'age'; | ||
SET search_path TO ag_catalog; | ||
|
||
SELECT create_graph('cypher_remove'); | ||
|
||
|
||
--test 1 | ||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_1)$$) AS (a agtype); | ||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_1 {i: 0, j: 5, a: 0})$$) AS (a agtype); | ||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_1 {i: 1})$$) AS (a agtype); | ||
|
||
SELECT * FROM cypher('cypher_remove', $$MATCH (n:test_1) REMOVE n.i $$) AS (a agtype); | ||
SELECT * FROM cypher('cypher_remove', $$MATCH (n:test_1) RETURN n$$) AS (a agtype); | ||
|
||
--test 2 | ||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_2)$$) AS (a agtype); | ||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_2 {i: 0, j: 5, a: 0})$$) AS (a agtype); | ||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_2 {i: 1})$$) AS (a agtype); | ||
|
||
SELECT * FROM cypher('cypher_remove', $$MATCH (n:test_2) REMOVE n.j RETURN n$$) AS (a agtype); | ||
SELECT * FROM cypher('cypher_remove', $$MATCH (n:test_2) RETURN n$$) AS (a agtype); | ||
|
||
--test 3 Validate Paths are updated | ||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_3 { i : 20 } )-[:test_3_edge {j:20}]->(:test_3 {i:10})$$) AS (a agtype); | ||
|
||
SELECT * FROM cypher('cypher_remove', $$MATCH p=(n)-[:test_3_edge]->() REMOVE n.i RETURN p$$) AS (a agtype); | ||
|
||
--test 4 Edges | ||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_4 { i : 20 } )-[:test_4_edge {j:20}]->(:test_4 {i:10})$$) AS (a agtype); | ||
|
||
SELECT * FROM cypher('cypher_remove', $$MATCH ()-[n]->(:test_4) REMOVE n.i RETURN n$$) AS (a agtype); | ||
SELECT * FROM cypher('cypher_remove', $$MATCH ()-[n]->(:test_4) RETURN n$$) AS (a agtype); | ||
|
||
--test 5 two REMOVE clauses | ||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_5 {i: 1, j : 2, k : 3}) $$) AS (a agtype); | ||
SELECT * FROM cypher('cypher_remove', $$ | ||
MATCH (n:test_5) | ||
REMOVE n.i | ||
REMOVE n.j | ||
RETURN n | ||
$$) AS (a agtype); | ||
|
||
|
||
SELECT * FROM cypher('cypher_remove', $$ | ||
MATCH (n:test_5) | ||
RETURN n | ||
$$) AS (a agtype); | ||
|
||
--test 6 Create a loop and see that set can work after create | ||
SELECT * FROM cypher('cypher_remove', $$CREATE (:test_6 {j: 5, y: 99})$$) AS (a agtype); | ||
SELECT * FROM cypher('cypher_remove', $$ | ||
MATCH (n {j: 5}) | ||
CREATE p=(n)-[e:e {j:34}]->(n) | ||
REMOVE n.y | ||
RETURN n, p | ||
$$) AS (a agtype, b agtype); | ||
SELECT * FROM cypher('cypher_remove', $$MATCH (n:test_6) RETURN n$$) AS (a agtype); | ||
|
||
|
||
--test 7 Create a loop and see that set can work after create | ||
SELECT * FROM cypher('cypher_remove', $$ | ||
CREATE (:test_7)-[e:e {j:34}]->() | ||
REMOVE e.y | ||
RETURN e | ||
$$) AS (a agtype); | ||
SELECT * FROM cypher('cypher_remove', $$MATCH (n:test_7) RETURN n$$) AS (a agtype); | ||
|
||
|
||
|
||
--test 8 | ||
SELECT * FROM cypher('cypher_remove', $$ | ||
MATCH (n:test_7) | ||
MATCH (n)-[e:e {j:34}]->() | ||
REMOVE n.y | ||
RETURN n | ||
$$) AS (a agtype); | ||
|
||
--Handle Inheritance | ||
SELECT * FROM cypher('cypher_remove', $$CREATE ( {i : 1 })$$) AS (a agtype); | ||
SELECT * FROM cypher('cypher_remove', $$MATCH (n) REMOVE n.i RETURN n$$) AS (a agtype); | ||
SELECT * FROM cypher('cypher_remove', $$MATCH (n) RETURN n$$) AS (a agtype); | ||
|
||
|
||
--Errors | ||
SELECT * FROM cypher('cypher_remove', $$REMOVE n.i$$) AS (a agtype); | ||
|
||
SELECT * FROM cypher('cypher_remove', $$MATCH (n) REMOVE n.i = NULL$$) AS (a agtype); | ||
|
||
SELECT * FROM cypher('cypher_remove', $$MATCH (n) REMOVE wrong_var.i$$) AS (a agtype); | ||
|
||
SELECT * FROM cypher('cypher_remove', $$MATCH (n) REMOVE n.i = 3, n.j = 5 $$) AS (a agtype); | ||
-- | ||
-- Clean up | ||
-- | ||
SELECT drop_graph('cypher_remove', true); | ||
|
||
-- | ||
-- End | ||
-- |
Oops, something went wrong.