diff --git a/conformance/tests/ot_null.py b/conformance/tests/ot_null.py index 392fd233..e5c1a772 100644 --- a/conformance/tests/ot_null.py +++ b/conformance/tests/ot_null.py @@ -33,9 +33,19 @@ def test_returnNil(man): #print(i) count_1 += 1 - return errors + return errors + +def test_returnNilUnwind(man): + errors = [] + G = man.setGraph("swapi") + + # outNull generates null maps that must be skipped in the unwind step. Was causing segfault before. + for i in G.query().V().outNull("species").unwind('eye_colors'): + if i['data']['eye_colors'] is not None and not isinstance(i['data']['eye_colors'], str): + errors.append("expecting i['eye_colors'] to be string after unwind but got %s instead" % i['eye_colors']) + return errors def test_hasLabelOut(man): errors = [] diff --git a/engine/core/processors.go b/engine/core/processors.go index 12696259..522e51cd 100644 --- a/engine/core/processors.go +++ b/engine/core/processors.go @@ -564,16 +564,19 @@ func (r *Unwind) Process(ctx context.Context, man gdbi.Manager, in gdbi.InPipe, } } else { cur := t.GetCurrent() - o := gdbi.DataElement{ - ID: cur.Get().ID, - Label: cur.Get().Label, - From: cur.Get().From, - To: cur.Get().To, - Data: copy.DeepCopy(cur.Get().Data).(map[string]interface{}), Loaded: true, + // if outnull returns null cur can be empty + if cur.Get() != nil { + o := gdbi.DataElement{ + ID: cur.Get().ID, + Label: cur.Get().Label, + From: cur.Get().From, + To: cur.Get().To, + Data: copy.DeepCopy(cur.Get().Data).(map[string]interface{}), Loaded: true, + } + n := t.AddCurrent(&o) + gdbi.TravelerSetValue(n, r.Field, nil) + out <- n } - n := t.AddCurrent(&o) - gdbi.TravelerSetValue(n, r.Field, nil) - out <- n } } }()