pietermartin / sqlg

TinkerPop graph over sql
MIT License
246 stars 51 forks source link

optional with select issue #347

Closed pietermartin closed 3 years ago

pietermartin commented 5 years ago
    @Test
    public void testOptionalWithSelect() {
        Vertex car1 = this.sqlgGraph.addVertex(T.label, "Car");
        Vertex car2 = this.sqlgGraph.addVertex(T.label, "Car");
        Vertex person = this.sqlgGraph.addVertex(T.label, "Person");
        car1.addEdge("passenger", person);
        this.sqlgGraph.tx().commit();
        List<Path> paths = this.sqlgGraph.traversal().V().hasLabel("Car").as("cars")
                .optional(
                        __.out("passenger").as("passenger")
                )
                .path()
                .toList();
        for (Path path : paths) {
            for (int i = 0; i < path.objects().size(); i++) {
                Object o = path.objects().get(i);
                Set<String> labels = path.labels().get(i);
                System.out.print(o + " " + labels.toString());
            }
            System.out.println();
        }

        List<Map<String, Vertex>> result = this.sqlgGraph.traversal().V().hasLabel("Car").as("cars")
                .optional(
                        __.out("passenger").as("passenger")
                )
                .<Vertex>select("cars", "passenger")
                .toList();
        System.out.println(result);
    }

This select query returns nothing and TinkerPop something.

pietermartin commented 3 years ago

No longer happens on 2.0.3-SNAPSHOT on branch 2020