From d4bcdb77ad7301073aa51a31ddb12adb9bcdbed4 Mon Sep 17 00:00:00 2001 From: DavIvek <david.ivekovic@memgraph.io> Date: Wed, 10 Jan 2024 11:46:20 +0100 Subject: [PATCH] Fix using path identifier after CREATE (#1629) --- src/query/plan/rule_based_planner.hpp | 3 ++- .../tests/memgraph_V1/features/match.feature | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/query/plan/rule_based_planner.hpp b/src/query/plan/rule_based_planner.hpp index 074bd1c88..bdd7bdbd9 100644 --- a/src/query/plan/rule_based_planner.hpp +++ b/src/query/plan/rule_based_planner.hpp @@ -1,4 +1,4 @@ -// Copyright 2023 Memgraph Ltd. +// Copyright 2024 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -380,6 +380,7 @@ class RuleBasedPlanner { if (pattern.identifier_->user_declared_) { std::vector<Symbol> path_elements; for (const PatternAtom *atom : pattern.atoms_) path_elements.emplace_back(symbol_table.at(*atom->identifier_)); + bound_symbols.insert(symbol_table.at(*pattern.identifier_)); last_op = std::make_unique<ConstructNamedPath>(std::move(last_op), symbol_table.at(*pattern.identifier_), path_elements); } diff --git a/tests/gql_behave/tests/memgraph_V1/features/match.feature b/tests/gql_behave/tests/memgraph_V1/features/match.feature index 227ad9ad6..0d0477ad9 100644 --- a/tests/gql_behave/tests/memgraph_V1/features/match.feature +++ b/tests/gql_behave/tests/memgraph_V1/features/match.feature @@ -771,3 +771,17 @@ Feature: Match Then the result should be: | path | | <(:label1 {id: 1})-[:type1 {id: 1}]->(:label2 {id: 2})-[:type1 {id: 2}]->(:label3 {id: 3})> | + + Scenario: Using path indentifier from CREATE in MERGE + Given an empty graph + And having executed: + """ + CREATE p0=()-[:T0]->() MERGE ({k:(size(p0))}); + """ + When executing query: + """ + MATCH (n {k: 1}) RETURN n; + """ + Then the result should be: + | n | + | ({k: 1}) |