Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3367: Test to check return type of apoc.any.rebind with a Path #3848

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion extended/src/test/java/apoc/nodes/NodesExtendedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,28 @@ public void rebind() {
final List<Path> rebindList = (List<Path>) row.get("rebind");
assertEquals(2, rebindList.size());
final Path firstPath = rebindList.get(0);
assertPath(firstPath, List.of("Foo", "Bar"), List.of("MY_REL"));
assertFooBarPath(firstPath);
final Path secondPath = rebindList.get(1);
assertPath(secondPath, List.of("Bar", "Baz"), List.of("ANOTHER_REL"));
});

// check via `valueType()` that, even if the return type is Object,
// the output of a rebound Path is also a Path (i.e.: `PATH NOT NULL`)
TestUtil.testCall(db, """
CREATE path=(a:Foo)-[r1:MY_REL]->(b:Bar)\s
WITH apoc.any.rebind(path) AS rebind
RETURN rebind, valueType(rebind) as valueType""",
(row) -> {
final String valueType = (String) row.get("valueType");
assertEquals("PATH NOT NULL", valueType);

final Path pathRebind = (Path) row.get("rebind");
assertFooBarPath(pathRebind);
});
}

private void assertFooBarPath(Path pathRebind) {
assertPath(pathRebind, List.of("Foo", "Bar"), List.of("MY_REL"));
}

private void assertPath(Path rebind, List<String> labels, List<String> relTypes) {
Expand Down
Loading