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

Neeraj/v20.03 pagination uid #6631

Merged
merged 1 commit into from
Oct 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -1961,6 +1961,11 @@ func ProcessGraph(ctx context.Context, sg, parent *SubGraph, rch chan error) {
return sg.DestUIDs.Uids[i] < sg.DestUIDs.Uids[j]
})
}
if sg.Params.AfterUID > 0 {
i := sort.Search(len(sg.DestUIDs.Uids), func(i int) bool { return sg.DestUIDs.Uids[i] > sg.Params.AfterUID })
sg.DestUIDs.Uids = sg.DestUIDs.Uids[i:]
}

case sg.Attr == "":
// This is when we have uid function in children.
if sg.SrcFunc != nil && sg.SrcFunc.Name == "uid" {
Expand Down
37 changes: 37 additions & 0 deletions query/query1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,43 @@ func TestHasFuncAtRootWithAfter(t *testing.T) {
require.JSONEq(t, `{"data": {"me":[{"friend":[{"count":1}],"name":"Rick Grimes","uid":"0x17"},{"friend":[{"count":1}],"name":"Andrea","uid":"0x1f"}]}}`, js)
}

func TestHasFuncAtRootWithAfterOnUIDs(t *testing.T) {

query := `
{
var(func: has(name)) {
uids as uid
}
me(func: uid(uids), first: 2, after: 0x5) {
uid
}
}
`

js := processQueryNoErr(t, query)
require.JSONEq(t, `{"data": {"me":[{"uid":"0x6"},{"uid":"0x7"}]}}`, js)
}

func TestHasFuncAtRootWithAfterOnUIDsOtherThanRoot(t *testing.T) {

query := `
{
var(func: has(name)) {
uids as uid
}
me(func: uid(0x1, 0x1f)) {
uid
friend(first:2, after:0x5) @filter(uid(uids)) {
uid
}
}
}
`

js := processQueryNoErr(t, query)
require.JSONEq(t, `{"data": {"me":[{"uid":"0x1","friend":[{"uid": "0x17"},{"uid": "0x18"}]},{"uid": "0x1f","friend": [{"uid": "0x18"}]}]}}`, js)
}

func TestHasFuncAtRootFilter(t *testing.T) {

query := `
Expand Down