Skip to content

Commit

Permalink
Merge pull request #296 from bmeg/fix/null-returns
Browse files Browse the repository at this point in the history
Adding test and fix for null edge/vertex returns
  • Loading branch information
kellrott authored Aug 14, 2023
2 parents 0d03f72 + 48173ab commit 44878a8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 17 deletions.
20 changes: 20 additions & 0 deletions conformance/tests/ot_null.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@
"Character:16"
]

def test_returnNil(man):
errors = []

G = man.setGraph("swapi")

#print("query 1")
count_1 = 0
for i in G.query().V().hasLabel("Character").outNull("starships"):
print(i)
count_1 += 1

#print("query 1")
count_1 = 0
for i in G.query().V().hasLabel("Character").outENull("starships"):
print(i)
count_1 += 1

return errors


def test_hasLabelOut(man):
errors = []

Expand Down
42 changes: 25 additions & 17 deletions engine/pipeline/pipes.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,27 +119,35 @@ func Convert(graph gdbi.GraphInterface, dataType gdbi.DataType, markTypes map[st
switch dataType {
case gdbi.VertexData:
ve := t.GetCurrent()
if !ve.Loaded {
//log.Infof("Loading output vertex: %s", ve.ID)
//TODO: doing single vertex queries is slow.
// Need to rework this to do batched queries
ve = graph.GetVertex(ve.ID, true)
}
return &gripql.QueryResult{
Result: &gripql.QueryResult_Vertex{
Vertex: ve.ToVertex(),
},
if ve != nil {
if !ve.Loaded {
//log.Infof("Loading output vertex: %s", ve.ID)
//TODO: doing single vertex queries is slow.
// Need to rework this to do batched queries
ve = graph.GetVertex(ve.ID, true)
}
return &gripql.QueryResult{
Result: &gripql.QueryResult_Vertex{
Vertex: ve.ToVertex(),
},
}
} else {
return &gripql.QueryResult{Result: &gripql.QueryResult_Vertex{}}
}

case gdbi.EdgeData:
ee := t.GetCurrent()
if !ee.Loaded {
ee = graph.GetEdge(ee.ID, true)
}
return &gripql.QueryResult{
Result: &gripql.QueryResult_Edge{
Edge: ee.ToEdge(),
},
if ee != nil {
if !ee.Loaded {
ee = graph.GetEdge(ee.ID, true)
}
return &gripql.QueryResult{
Result: &gripql.QueryResult_Edge{
Edge: ee.ToEdge(),
},
}
} else {
return &gripql.QueryResult{Result: &gripql.QueryResult_Edge{}}
}

case gdbi.CountData:
Expand Down

0 comments on commit 44878a8

Please sign in to comment.