rafsun42 opened a new issue, #122:
URL: https://github.com/apache/age-website/issues/122
A SET clause syntax (`SET a = {..}`) is implemented and merged recently
(https://github.com/apache/age/pull/468). It may be useful to add it in the
documentation.
The following code from the test files shows how the syntax is used. It is
similar to
https://neo4j.com/docs/cypher-manual/current/clauses/set/#set-copying-properties-between-nodes-and-relationships.
```sql
...
SELECT * FROM cypher('cypher_set_1', $$ CREATE (a:Andy {name:'Andy', age:36,
hungry:true}) $$) AS (a agtype);
SELECT * FROM cypher('cypher_set_1', $$ CREATE (a:Peter {name:'Peter',
age:34}) $$) AS (a agtype);
SELECT * FROM cypher('cypher_set_1', $$ CREATE (a:Kevin {name:'Kevin',
age:32, hungry:false}) $$) AS (a agtype);
SELECT * FROM cypher('cypher_set_1', $$ CREATE (a:Matt {name:'Matt',
city:'Toronto'}) $$) AS (a agtype);
SELECT * FROM cypher('cypher_set_1', $$ CREATE (a:Juan {name:'Juan',
role:'admin'}) $$) AS (a agtype);
-- test copying properties between entities
SELECT * FROM cypher('cypher_set_1', $$
MATCH (at {name: 'Andy'}), (pn {name: 'Peter'})
SET at = properties(pn)
RETURN at, pn
$$) AS (at agtype, pn agtype);
SELECT * FROM cypher('cypher_set_1', $$
MATCH (at {name: 'Kevin'}), (pn {name: 'Matt'})
SET at = pn
RETURN at, pn
$$) AS (at agtype, pn agtype);
-- test replacing all properties using a map and =
SELECT * FROM cypher('cypher_set_1', $$
MATCH (m {name: 'Matt'})
SET m = {name: 'Peter Smith', position: 'Entrepreneur', city:NULL}
RETURN m
$$) AS (m agtype);
-- test removing all properties using an empty map and =
SELECT * FROM cypher('cypher_set_1', $$
MATCH (p {name: 'Juan'})
SET p = {}
RETURN p
$$) AS (p agtype);
-- test assigning non-map to an enitity
SELECT * FROM cypher('cypher_set_1', $$
MATCH (p {name: 'Peter'})
SET p = "Peter"
RETURN p
$$) AS (p agtype);
SELECT * FROM cypher('cypher_set_1', $$
MATCH (p {name: 'Peter'})
SET p = sqrt(4)
RETURN p
$$) AS (p agtype);
...
```
Aside from that, two other SET syntaxes are being worked on. I will post
update in this issue.
Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]