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