From 182a9241cf74fdc40e5046730c54273ee5602fe0 Mon Sep 17 00:00:00 2001 From: Teon Banek Date: Wed, 20 Sep 2017 10:45:27 +0200 Subject: [PATCH] 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 --- src/query/interpreter.hpp | 8 +++----- .../tests/memgraph_V1/features/with.feature | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/query/interpreter.hpp b/src/query/interpreter.hpp index e38f76962..f34b268b6 100644 --- a/src/query/interpreter.hpp +++ b/src/query/interpreter.hpp @@ -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); diff --git a/tests/qa/tck_engine/tests/memgraph_V1/features/with.feature b/tests/qa/tck_engine/tests/memgraph_V1/features/with.feature index 84d2cd225..0963a25b5 100644 --- a/tests/qa/tck_engine/tests/memgraph_V1/features/with.feature +++ b/tests/qa/tck_engine/tests/memgraph_V1/features/with.feature @@ -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}) | +