@@ -1263,12 +1263,141 @@ $$) as (a agtype);
12631263---
12641264(0 rows)
12651265
1266+ ---
1267+ --- Issue 1630 MERGE using array not working in some cases
1268+ --
1269+ SELECT * FROM create_graph('issue_1630');
1270+ NOTICE: graph "issue_1630" has been created
1271+ create_graph
1272+ --------------
1273+
1274+ (1 row)
1275+
1276+ SELECT * FROM cypher('issue_1630', $$ MATCH (u) RETURN (u) $$) AS (u agtype);
1277+ u
1278+ ---
1279+ (0 rows)
1280+
1281+ -- will it create it?
1282+ SELECT * FROM cypher('issue_1630',
1283+ $$ WITH ['jon', 'snow'] AS cols
1284+ MERGE (v:PERSION {first: cols[0], last: cols[1]})
1285+ RETURN v $$) AS (v agtype);
1286+ v
1287+ -----------------------------------------------------------------------------------------------------
1288+ {"id": 844424930131969, "label": "PERSION", "properties": {"last": "snow", "first": "jon"}}::vertex
1289+ (1 row)
1290+
1291+ -- will it retrieve it, if it exists?
1292+ SELECT * FROM cypher('issue_1630',
1293+ $$ WITH ['jon', 'snow'] AS cols
1294+ MERGE (v:PERSION {first: cols[0], last: cols[1]})
1295+ RETURN v $$) AS (v agtype);
1296+ v
1297+ -----------------------------------------------------------------------------------------------------
1298+ {"id": 844424930131969, "label": "PERSION", "properties": {"last": "snow", "first": "jon"}}::vertex
1299+ (1 row)
1300+
1301+ SELECT * FROM cypher('issue_1630', $$ MATCH (u) RETURN (u) $$) AS (u agtype);
1302+ u
1303+ -----------------------------------------------------------------------------------------------------
1304+ {"id": 844424930131969, "label": "PERSION", "properties": {"last": "snow", "first": "jon"}}::vertex
1305+ (1 row)
1306+
1307+ -- a whole array
1308+ SELECT * FROM cypher('issue_1630',
1309+ $$ WITH ['jon', 'snow'] AS cols
1310+ MERGE (v:PERSION {namea: cols})
1311+ RETURN v $$) AS (v agtype);
1312+ v
1313+ -----------------------------------------------------------------------------------------------
1314+ {"id": 844424930131970, "label": "PERSION", "properties": {"namea": ["jon", "snow"]}}::vertex
1315+ (1 row)
1316+
1317+ -- a whole object
1318+ SELECT * FROM cypher('issue_1630',
1319+ $$ WITH {first: 'jon', last: 'snow'} AS cols
1320+ MERGE (v:PERSION {nameo: cols})
1321+ RETURN v $$) AS (v agtype);
1322+ v
1323+ ----------------------------------------------------------------------------------------------------------------
1324+ {"id": 844424930131971, "label": "PERSION", "properties": {"nameo": {"last": "snow", "first": "jon"}}}::vertex
1325+ (1 row)
1326+
1327+ -- delete them to start over
1328+ SELECT * FROM cypher('issue_1630', $$ MATCH (u) DELETE(u) $$) AS (u agtype);
1329+ u
1330+ ---
1331+ (0 rows)
1332+
1333+ SELECT * FROM cypher('issue_1630',
1334+ $$ WITH {first: 'jon', last: 'snow'} AS cols
1335+ MERGE (v:PERSION {first: cols.first, last: cols.last})
1336+ RETURN v $$) AS (v agtype);
1337+ v
1338+ -----------------------------------------------------------------------------------------------------
1339+ {"id": 844424930131972, "label": "PERSION", "properties": {"last": "snow", "first": "jon"}}::vertex
1340+ (1 row)
1341+
1342+ -- delete them to start over
1343+ -- check pushing through a few clauses
1344+ SELECT * FROM cypher('issue_1630', $$ MATCH (u) DELETE(u) $$) AS (u agtype);
1345+ u
1346+ ---
1347+ (0 rows)
1348+
1349+ SELECT * FROM cypher('issue_1630',
1350+ $$ WITH {first: 'jon', last: 'snow'} AS jonsnow
1351+ WITH jonsnow AS name
1352+ WITH name AS cols
1353+ MERGE (v:PERSION {first: cols.first, last: cols.last})
1354+ RETURN v $$) AS (v agtype);
1355+ v
1356+ -----------------------------------------------------------------------------------------------------
1357+ {"id": 844424930131973, "label": "PERSION", "properties": {"last": "snow", "first": "jon"}}::vertex
1358+ (1 row)
1359+
1360+ -- will it retrieve the one created?
1361+ SELECT * FROM cypher('issue_1630',
1362+ $$ WITH {first: 'jon', last: 'snow'} AS jonsnow
1363+ WITH jonsnow AS name
1364+ WITH name AS cols
1365+ MERGE (v:PERSION {first: cols.first, last: cols.last})
1366+ RETURN v $$) AS (v agtype);
1367+ v
1368+ -----------------------------------------------------------------------------------------------------
1369+ {"id": 844424930131973, "label": "PERSION", "properties": {"last": "snow", "first": "jon"}}::vertex
1370+ (1 row)
1371+
1372+ -- delete them to start over
1373+ -- check pushing through a few clauses and returning both vars
1374+ SELECT * FROM cypher('issue_1630', $$ MATCH (u) DELETE(u) $$) AS (u agtype);
1375+ u
1376+ ---
1377+ (0 rows)
1378+
1379+ SELECT * FROM cypher('issue_1630',
1380+ $$ WITH {first: 'jon', last: 'snow'} AS jonsnow
1381+ WITH jonsnow AS name
1382+ WITH name AS cols
1383+ MERGE (v:PERSION {first: cols.first, last: cols.last})
1384+ RETURN v, cols $$) AS (v agtype, cols agtype);
1385+ v | cols
1386+ -----------------------------------------------------------------------------------------------------+----------------------------------
1387+ {"id": 844424930131974, "label": "PERSION", "properties": {"last": "snow", "first": "jon"}}::vertex | {"last": "snow", "first": "jon"}
1388+ (1 row)
1389+
12661390--clean up
12671391SELECT * FROM cypher('cypher_merge', $$MATCH (n) DETACH DELETE n $$) AS (a agtype);
12681392 a
12691393---
12701394(0 rows)
12711395
1396+ SELECT * FROM cypher('issue_1630', $$MATCH (n) DETACH DELETE n $$) AS (a agtype);
1397+ a
1398+ ---
1399+ (0 rows)
1400+
12721401/*
12731402 * Clean up graph
12741403 */
@@ -1299,3 +1428,14 @@ NOTICE: graph "cypher_merge" has been dropped
12991428
13001429(1 row)
13011430
1431+ SELECT drop_graph('issue_1630', true);
1432+ NOTICE: drop cascades to 3 other objects
1433+ DETAIL: drop cascades to table issue_1630._ag_label_vertex
1434+ drop cascades to table issue_1630._ag_label_edge
1435+ drop cascades to table issue_1630."PERSION"
1436+ NOTICE: graph "issue_1630" has been dropped
1437+ drop_graph
1438+ ------------
1439+
1440+ (1 row)
1441+
0 commit comments