diff --git a/query/query.go b/query/query.go index 288ffc3741c..a9c3c08e9ce 100644 --- a/query/query.go +++ b/query/query.go @@ -1918,7 +1918,7 @@ func ProcessGraph(ctx context.Context, sg, parent *SubGraph, rch chan error) { return } - curVal := types.Val{Tid: types.IntID, Value: int64(len(sg.SrcUIDs.Uids))} + curVal := types.Val{Tid: types.IntID, Value: int64(len(sg.DestUIDs.Uids))} if types.CompareVals(sg.SrcFunc.Name, curVal, dst) { sg.DestUIDs.Uids = sg.SrcUIDs.Uids } else { diff --git a/query/query0_test.go b/query/query0_test.go index 9283b7c1a08..947ac6198b3 100644 --- a/query/query0_test.go +++ b/query/query0_test.go @@ -1752,15 +1752,25 @@ func TestFilterUsingLenFunction(t *testing.T) { { "Eq length should return empty results", `{ - var(func: has(school), first: 3) { - f as uid - } - - me(func: uid(f)) @filter(eq(len(f), 0)) { - count(uid) - } + var(func: has(school), first: 3) { + f as uid + } + me(func: uid(f)) @filter(eq(len(f), 0)) { + uid + name + } + }`, + `{"data": {"me":[]}}`, + }, + { + "Eq length with uid(0) should return results", + `{ + f as var(func: eq(name, "random")) + me(func: uid(0)) @filter(eq(len(f), 0)) { + uid + } }`, - `{"data": {"me":[{"count": 0}]}}`, + `{"data": {"me":[{"uid": "0x0"}]}}`, }, { "Ge length should return results",