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

Bugfix: Reset alias after assigning it to UidCountAlias #3837

Merged
merged 1 commit into from
Aug 20, 2019
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
4 changes: 4 additions & 0 deletions gql/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2879,6 +2879,10 @@ func godeep(it *lex.ItemIterator, gq *GraphQuery) error {
gq.Var = varName
if alias != "" {
gq.UidCountAlias = alias
// This is a count(uid) node.
// Reset the alias here after assigning to UidCountAlias, so that siblings
// of this node don't get it.
alias = ""
}
it.Next()
it.Next()
Expand Down
15 changes: 15 additions & 0 deletions query/query0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2266,6 +2266,21 @@ func TestDateTimeQuery(t *testing.T) {
processQueryNoErr(t, query))
}

func TestCountUidWithAlias(t *testing.T) {
query := `
{
me(func: uid(1, 23, 24, 25, 31)) {
countUid: count(uid)
name
}
}
`
js := processQueryNoErr(t, query)
require.JSONEq(t,
`{"data":{"me":[{"countUid":5},{"name":"Michonne"},{"name":"Rick Grimes"},{"name":"Glenn Rhee"},{"name":"Daryl Dixon"},{"name":"Andrea"}]}}`,
js)
}

var client *dgo.Dgraph

func TestMain(m *testing.M) {
Expand Down