From 4aacd45640027a77a31a51a39f73802f536fb7f0 Mon Sep 17 00:00:00 2001 From: Andi Date: Thu, 2 Nov 2023 08:25:34 +0100 Subject: [PATCH] Throw when exists() combined with CASE (#1382) --- src/query/frontend/semantic/symbol_generator.cpp | 4 ++++ .../tests/memgraph_V1/features/case.feature | 12 ++++++++++++ .../tests/memgraph_V1_on_disk/features/case.feature | 12 ++++++++++++ 3 files changed, 28 insertions(+) diff --git a/src/query/frontend/semantic/symbol_generator.cpp b/src/query/frontend/semantic/symbol_generator.cpp index 038bdf66b..8a555d96e 100644 --- a/src/query/frontend/semantic/symbol_generator.cpp +++ b/src/query/frontend/semantic/symbol_generator.cpp @@ -507,6 +507,10 @@ bool SymbolGenerator::PreVisit(Exists &exists) { throw utils::NotYetImplemented("RETURN can not be used with exists, but only during matching!"); } + if (scope.num_if_operators) { + throw utils::NotYetImplemented("IF operator cannot be used with exists, but only during matching!"); + } + scope.in_exists = true; const auto &symbol = CreateAnonymousSymbol(); diff --git a/tests/gql_behave/tests/memgraph_V1/features/case.feature b/tests/gql_behave/tests/memgraph_V1/features/case.feature index 0ad70d4dc..b9140c06f 100644 --- a/tests/gql_behave/tests/memgraph_V1/features/case.feature +++ b/tests/gql_behave/tests/memgraph_V1/features/case.feature @@ -97,3 +97,15 @@ Feature: Case Then the result should be: | CASE name WHEN null THEN "doesn't work" WHEN 2 THEN "doesn't work" ELSE 'works' END | | 'works' | + + Scenario: Test exists does not work in CASE clauses + Given an empty graph + And having executed: + """ + CREATE ()-[:T]->(); + """ + When executing query: + """ + MATCH (a) WHERE CASE WHEN TRUE THEN exists(()-[]->()) END RETURN a; + """ + Then an error should be raised diff --git a/tests/gql_behave/tests/memgraph_V1_on_disk/features/case.feature b/tests/gql_behave/tests/memgraph_V1_on_disk/features/case.feature index 0ad70d4dc..b9140c06f 100644 --- a/tests/gql_behave/tests/memgraph_V1_on_disk/features/case.feature +++ b/tests/gql_behave/tests/memgraph_V1_on_disk/features/case.feature @@ -97,3 +97,15 @@ Feature: Case Then the result should be: | CASE name WHEN null THEN "doesn't work" WHEN 2 THEN "doesn't work" ELSE 'works' END | | 'works' | + + Scenario: Test exists does not work in CASE clauses + Given an empty graph + And having executed: + """ + CREATE ()-[:T]->(); + """ + When executing query: + """ + MATCH (a) WHERE CASE WHEN TRUE THEN exists(()-[]->()) END RETURN a; + """ + Then an error should be raised