Skip to content

Commit

Permalink
Reset alias after assigning it to UidCountAlias (#3837)
Browse files Browse the repository at this point in the history
This fixes #3814
  • Loading branch information
pawanrawal committed Aug 29, 2019
1 parent 81be40b commit ab269a5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gql/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2631,6 +2631,10 @@ func godeep(it *lex.ItemIterator, gq *GraphQuery) error {
gq.UidCount = true
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
14 changes: 14 additions & 0 deletions query/query0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,20 @@ func TestDefaultValueVar2(t *testing.T) {
require.JSONEq(t, `{"data": {"data":[]}}`, js)
}

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


var maxPendingCh chan uint64

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

0 comments on commit ab269a5

Please sign in to comment.