@@ -842,6 +842,19 @@ test("Test limit", async () => {
842842 expect ( results . length ) . toBe ( 50 ) ;
843843} ) ;
844844
845+ test ( "Test limit as last operation" , async ( ) => {
846+ const runner = new Runner (
847+ `
848+ unwind range(1, 10) as i
849+ return i
850+ limit 5
851+ `
852+ ) ;
853+ await runner . run ( ) ;
854+ const results = runner . results ;
855+ expect ( results . length ) . toBe ( 5 ) ;
856+ } ) ;
857+
845858test ( "Test range lookup" , async ( ) => {
846859 const runner = new Runner (
847860 `
@@ -1327,6 +1340,60 @@ test("Test match with referenced to previous variable", async () => {
13271340 expect ( results [ 1 ] ) . toEqual ( { name1 : "Person 2" , name2 : "Person 3" , name3 : "Person 4" } ) ;
13281341} ) ;
13291342
1343+ test ( "Test match with aggregated with and subsequent match" , async ( ) => {
1344+ await new Runner ( `
1345+ CREATE VIRTUAL (:User) AS {
1346+ unwind [
1347+ {id: 1, name: 'Alice'},
1348+ {id: 2, name: 'Bob'},
1349+ {id: 3, name: 'Carol'}
1350+ ] as record
1351+ RETURN record.id as id, record.name as name
1352+ }
1353+ ` ) . run ( ) ;
1354+ await new Runner ( `
1355+ CREATE VIRTUAL (:User)-[:KNOWS]-(:User) AS {
1356+ unwind [
1357+ {left_id: 1, right_id: 2},
1358+ {left_id: 1, right_id: 3}
1359+ ] as record
1360+ RETURN record.left_id as left_id, record.right_id as right_id
1361+ }
1362+ ` ) . run ( ) ;
1363+ await new Runner ( `
1364+ CREATE VIRTUAL (:Project) AS {
1365+ unwind [
1366+ {id: 1, name: 'Project A'},
1367+ {id: 2, name: 'Project B'}
1368+ ] as record
1369+ RETURN record.id as id, record.name as name
1370+ }
1371+ ` ) . run ( ) ;
1372+ await new Runner ( `
1373+ CREATE VIRTUAL (:User)-[:WORKS_ON]-(:Project) AS {
1374+ unwind [
1375+ {left_id: 1, right_id: 1},
1376+ {left_id: 1, right_id: 2}
1377+ ] as record
1378+ RETURN record.left_id as left_id, record.right_id as right_id
1379+ }
1380+ ` ) . run ( ) ;
1381+ const match = new Runner ( `
1382+ MATCH (u:User)-[:KNOWS]->(s:User)
1383+ WITH u, count(s) as acquaintances
1384+ MATCH (u)-[:WORKS_ON]->(p:Project)
1385+ RETURN u.name as name, acquaintances, collect(p.name) as projects
1386+ ` ) ;
1387+ await match . run ( ) ;
1388+ const results = match . results ;
1389+ expect ( results . length ) . toBe ( 1 ) ;
1390+ expect ( results [ 0 ] ) . toEqual ( {
1391+ name : "Alice" ,
1392+ acquaintances : 2 ,
1393+ projects : [ "Project A" , "Project B" ] ,
1394+ } ) ;
1395+ } ) ;
1396+
13301397test ( "Test match and return full node" , async ( ) => {
13311398 await new Runner ( `
13321399 CREATE VIRTUAL (:Person) AS {
0 commit comments