fix set and remove clauses
This commit is contained in:
parent
fc84243cc9
commit
112f2e15d7
@ -568,6 +568,44 @@ bool SymbolGenerator::PostVisit(SetProperty & /*set_property*/) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SymbolGenerator::PreVisit(SetLabels &set_labels) {
|
||||
auto &scope = scopes_.back();
|
||||
scope.in_set_labels = true;
|
||||
for (auto &label : set_labels.labels_) {
|
||||
if (auto *expression = std::get_if<Expression *>(&label)) {
|
||||
(*expression)->Accept(*this);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SymbolGenerator::PostVisit(SetLabels & /*set_labels*/) {
|
||||
auto &scope = scopes_.back();
|
||||
scope.in_set_labels = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SymbolGenerator::PreVisit(RemoveLabels &remove_labels) {
|
||||
auto &scope = scopes_.back();
|
||||
scope.in_remove_labels = true;
|
||||
for (auto &label : remove_labels.labels_) {
|
||||
if (auto *expression = std::get_if<Expression *>(&label)) {
|
||||
(*expression)->Accept(*this);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SymbolGenerator::PostVisit(RemoveLabels & /*remove_labels*/) {
|
||||
auto &scope = scopes_.back();
|
||||
scope.in_remove_labels = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Pattern and its subparts.
|
||||
|
||||
bool SymbolGenerator::PreVisit(Pattern &pattern) {
|
||||
|
@ -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
|
||||
@ -68,6 +68,10 @@ class SymbolGenerator : public HierarchicalTreeVisitor {
|
||||
bool PostVisit(Foreach &) override;
|
||||
bool PreVisit(SetProperty & /*set_property*/) override;
|
||||
bool PostVisit(SetProperty & /*set_property*/) override;
|
||||
bool PreVisit(SetLabels &) override;
|
||||
bool PostVisit(SetLabels & /*set_labels*/) override;
|
||||
bool PreVisit(RemoveLabels &) override;
|
||||
bool PostVisit(RemoveLabels & /*remove_labels*/) override;
|
||||
|
||||
// Expressions
|
||||
ReturnType Visit(Identifier &) override;
|
||||
@ -128,6 +132,8 @@ class SymbolGenerator : public HierarchicalTreeVisitor {
|
||||
bool in_set_property{false};
|
||||
bool in_call_subquery{false};
|
||||
bool has_return{false};
|
||||
bool in_set_labels{false};
|
||||
bool in_remove_labels{false};
|
||||
// True when visiting a pattern atom (node or edge) identifier, which can be
|
||||
// reused or created in the pattern itself.
|
||||
bool in_pattern_atom_identifier{false};
|
||||
|
@ -3174,6 +3174,7 @@ bool SetLabels::SetLabelsCursor::Pull(Frame &frame, ExecutionContext &context) {
|
||||
SCOPED_PROFILE_OP("SetLabels");
|
||||
ExpressionEvaluator evaluator(&frame, context.symbol_table, context.evaluation_context, context.db_accessor,
|
||||
storage::View::NEW);
|
||||
if (!input_cursor_->Pull(frame, context)) return false;
|
||||
std::vector<storage::LabelId> labels;
|
||||
for (const auto &label : self_.labels_) {
|
||||
if (std::holds_alternative<storage::LabelId>(label)) {
|
||||
@ -3191,8 +3192,6 @@ bool SetLabels::SetLabelsCursor::Pull(Frame &frame, ExecutionContext &context) {
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!input_cursor_->Pull(frame, context)) return false;
|
||||
|
||||
TypedValue &vertex_value = frame[self_.input_symbol_];
|
||||
// Skip setting labels on Null (can occur in optional match).
|
||||
if (vertex_value.IsNull()) return true;
|
||||
@ -3354,6 +3353,7 @@ bool RemoveLabels::RemoveLabelsCursor::Pull(Frame &frame, ExecutionContext &cont
|
||||
SCOPED_PROFILE_OP("RemoveLabels");
|
||||
ExpressionEvaluator evaluator(&frame, context.symbol_table, context.evaluation_context, context.db_accessor,
|
||||
storage::View::NEW);
|
||||
if (!input_cursor_->Pull(frame, context)) return false;
|
||||
std::vector<storage::LabelId> labels;
|
||||
for (const auto &label : self_.labels_) {
|
||||
if (std::holds_alternative<storage::LabelId>(label)) {
|
||||
@ -3371,8 +3371,6 @@ bool RemoveLabels::RemoveLabelsCursor::Pull(Frame &frame, ExecutionContext &cont
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!input_cursor_->Pull(frame, context)) return false;
|
||||
|
||||
TypedValue &vertex_value = frame[self_.input_symbol_];
|
||||
// Skip removing labels on Null (can occur in optional match).
|
||||
if (vertex_value.IsNull()) return true;
|
||||
|
@ -361,7 +361,7 @@ void Filters::CollectPatternFilters(Pattern &pattern, SymbolTable &symbol_table,
|
||||
std::vector<LabelIx> labels;
|
||||
for (auto label : node->labels_) {
|
||||
if (const auto *label_node = std::get_if<Expression *>(&label)) {
|
||||
throw SemanticException("Parameter lookup not supported in MATCH/MERGE clause!");
|
||||
throw SemanticException("Property lookup not supported in MATCH/MERGE clause!");
|
||||
}
|
||||
labels.push_back(std::get<LabelIx>(label));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user