Use symbol names for header if missing token position

Summary:
This fixes a bug, where streaming would try to get the name of the symbol from
an invalid token position. For example, `MATCH (n) WITH n RETURN *`

Reviewers: florijan, mislav.bradac

Reviewed By: florijan, mislav.bradac

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D811
This commit is contained in:
Teon Banek 2017-09-20 10:45:27 +02:00
parent 08eaaba77f
commit 182a9241cf
2 changed files with 18 additions and 5 deletions

View File

@ -170,11 +170,9 @@ class Interpreter {
// When the symbol is aliased or expanded from '*' (inside RETURN or
// WITH), then there is no token position, so use symbol name.
// Otherwise, find the name from stripped query.
if (symbol.token_position() == -1)
header.push_back(symbol.name());
else
header.push_back(
stripped.named_expressions().at(symbol.token_position()));
header.push_back(FindOr(stripped.named_expressions(),
symbol.token_position(), symbol.name())
.first);
}
stream.Header(header);

View File

@ -221,3 +221,18 @@ Feature: With
| 1 |
| 3 |
| 5 |
Scenario: With test 15:
Given an empty graph
And having executed:
"""
CREATE ({id: 0})
"""
When executing query:
"""
MATCH (n) WITH n RETURN *
"""
Then the result should be:
| n |
| ({id: 0}) |