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

Step aliases used inside a union are being dropped #416

Closed
allenhadden opened this issue Jun 26, 2021 · 0 comments
Closed

Step aliases used inside a union are being dropped #416

allenhadden opened this issue Jun 26, 2021 · 0 comments
Labels

Comments

@allenhadden
Copy link

allenhadden commented Jun 26, 2021

This test illustrates the problem:

    @Test
    public void testAliasesWithinUnion() {
        Vertex a = this.sqlgGraph.addVertex(T.label, "A", "name", "A");
        Vertex b = this.sqlgGraph.addVertex(T.label, "B", "name", "B");

        a.addEdge("edge", b);

        // First, confirm that a simple traversal using an alias works properly.  This works as
        // expected (the failure is below with the union where the exact traversal is used inside the union).
        List<Vertex> noUnionItems = this.sqlgGraph.traversal()
                .V()
                .hasLabel("A")
                .as("alias1")
                .out()
                .<Vertex>select("alias1")
                .toList();

        Assert.assertEquals(1, noUnionItems.size());
        Assert.assertEquals(a, noUnionItems.get(0));

        // This one doesn't work even though the exact same traversal is used inside the union.  Debugging
        // the code shows that it cannot find the "alias1" label in the SelectOneStep (in the map method).
        List<Vertex> unionItems = this.sqlgGraph.traversal()
                .V()
                .limit(1)       // Normally an inject would be used here, but see #415
                .<Vertex>union(
                        __.V().hasLabel("A").as("alias1").out().select("alias1")
                )
                .toList();

        // This fails because unionItems contains 0 results.
        Assert.assertEquals(1, unionItems.size());
    }
@allenhadden allenhadden changed the title Step aliases used inside a union is being dropped Step aliases used inside a union are being dropped Jun 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants