Tests that operations on indexes are properly executed (and reset) in subqueries
(self)
| 1336 | self.env.assertEquals(res.result_set[i-1][1], [i]) |
| 1337 | |
| 1338 | def test22_indexes(self): |
| 1339 | """Tests that operations on indexes are properly executed (and reset) |
| 1340 | in subqueries""" |
| 1341 | |
| 1342 | # clear the db |
| 1343 | self.env.flush() |
| 1344 | graph = Graph(self.env.getConnection(), GRAPH_ID) |
| 1345 | |
| 1346 | # polulate the graph |
| 1347 | query = """UNWIND range(10,20) AS i |
| 1348 | CREATE (n:N {v:tostring(i)})-[:R]->(m:M {v:tostring(i+1)})""" |
| 1349 | graph.query(query) |
| 1350 | create_node_exact_match_index(graph, "N", "v", sync=True) |
| 1351 | |
| 1352 | # use the index in a scan as the lhs of a CallSubquery op, which |
| 1353 | # contains an eager operation |
| 1354 | query = """ |
| 1355 | MATCH (n:N {v:'10'}) |
| 1356 | CALL { |
| 1357 | WITH n |
| 1358 | SET n.v = '11' |
| 1359 | } |
| 1360 | RETURN n.v |
| 1361 | """ |
| 1362 | |
| 1363 | # assert that we indeed utilize the index to find the node |
| 1364 | plan = graph.explain(query) |
| 1365 | index_scan = locate_operation(plan.structured_plan, |
| 1366 | "Node By Index Scan") |
| 1367 | self.env.assertNotEqual(index_scan, None) |
| 1368 | |
| 1369 | res = graph.query(query) |
| 1370 | |
| 1371 | # assert results |
| 1372 | self.env.assertEquals(len(res.result_set), 1) |
| 1373 | self.env.assertEquals(res.result_set[0][0], '11') |
| 1374 | |
| 1375 | def test25_named_paths(self): |
| 1376 | """Tests that named paths are handled correctly, when defined/referred |
nothing calls this directly
no test coverage detected