diff --git a/dbms/src/test/java/org/polypheny/db/cypher/clause/write/DmlUpdateTest.java b/dbms/src/test/java/org/polypheny/db/cypher/clause/write/DmlUpdateTest.java index cb55a02e80..7ef05310c2 100644 --- a/dbms/src/test/java/org/polypheny/db/cypher/clause/write/DmlUpdateTest.java +++ b/dbms/src/test/java/org/polypheny/db/cypher/clause/write/DmlUpdateTest.java @@ -21,6 +21,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.polypheny.db.cypher.CypherTestTemplate; +import org.polypheny.db.cypher.helper.TestLiteral; import org.polypheny.db.cypher.helper.TestNode; import org.polypheny.db.util.Pair; import org.polypheny.db.webui.models.results.GraphResult; @@ -86,17 +87,50 @@ assert containsRows( res, true, true, public void updateVariablesIncrementTest() { execute( SINGLE_NODE_PERSON_1 ); execute( "MATCH (a:Person {name: 'Max'})\n" - + "SET a = { age: 13, job: 'Developer'} " ); + + "SET a = { name : 'Max' , age: 13, job: 'Developer'} " ); GraphResult res = matchAndReturnAllNodes(); assert containsRows( res, true, true, Row.of( TestNode.from( List.of( "Person" ), + Pair.of( "name", "Max" ), Pair.of( "age", 13 ), Pair.of( "job", "Developer" ) ) ) ); } + @Test + public void updateVariablesDecrementTest() { + execute( SINGLE_NODE_PERSON_COMPLEX_1 ); + execute( "MATCH (p {name: 'Ann'})\n" + + "SET p = {name: 'Ann Smith'}" ); + + GraphResult res = matchAndReturnAllNodes(); + containsNodes( res, true, + TestNode.from( List.of( "Person" ), + Pair.of( "name", "'Ann Smith" ) ) ); + + } + + + @Test + public void updateVariablesIncrementAndDecrementTest() { + execute( SINGLE_NODE_PERSON_COMPLEX_1 ); + execute( "MATCH (p {name: 'Ann'})\n" + + "SET p = {name: 'Peter Smith', position: 'Entrepreneur'}\n" + + "RETURN p.name, p.age, p.position" ); + + GraphResult res = matchAndReturnAllNodes(); + assert containsRows( res, true, true, + Row.of( TestNode.from( + List.of( "Person" ), + Pair.of( "name", "Peter Smith" ), + Pair.of( "position", "Entrepreneur" ) ) ) ); + + + } + + @Test @Disabled // Extension of Cypher implementation required public void updatePropertyReturnTest() { @@ -126,10 +160,50 @@ public void updateRelationshipNewPropertyTest() { public void updateCaseWhenTest() { execute( SINGLE_NODE_PERSON_COMPLEX_1 ); execute( "MATCH (n {name: 'Ann'})\n" - + "SET (CASE WHEN n.age = 45 THEN n END).worksIn = 'Malmo'\n" - + "RETURN n.name, n.worksIn" ); + + "SET (CASE WHEN n.age = 45 THEN n END).worksIn = 'Malmo" ); + GraphResult res = matchAndReturnAllNodes(); + containsNodes( res, true, + TestNode.from( List.of( "Person" ), + Pair.of( "name", "Ann" ), + Pair.of( "worksIn", "Malmo" ) ) ); + execute( "MATCH (n {name: 'Ann'})\n" + + "SET (CASE WHEN n.age = 45 THEN n END).name = 'Max" + + "RETURN n.name, n.age" ); + + containsNodes( res, true, + TestNode.from( List.of( "Person" ), + Pair.of( "name", "Max" ), + Pair.of( "age", 45 ) ) ); } + + @Test + public void updatePropertyWithNullTest() { + execute( SINGLE_NODE_PERSON_COMPLEX_1 ); + execute( "MATCH (n {name: 'Ann'})\n" + + "SET n.name = null\n" ); + + GraphResult res = matchAndReturnAllNodes(); + containsNodes( res, true, + TestNode.from( List.of( "Person" ), + Pair.of( "age", 54 ) ) ); + } + + + @Test + public void updateMultiplePropertiesWithOneSetTest() { + execute( SINGLE_NODE_PERSON_1 ); + execute( "MATCH (n {name: 'Max'})\n" + + "SET n.position = 'Developer', n.surname = 'Taylor'" ); + GraphResult res = matchAndReturnAllNodes(); + containsNodes( res, true, + TestNode.from( List.of( "Person" ), + Pair.of( "name", "Max" ), + Pair.of( "position", "Developer" ), + Pair.of( "surname", "Taylor " ) ) ); + } + + }