From f63722e0e452d8a4b43eb3cd35106bc0cc4e0f36 Mon Sep 17 00:00:00 2001 From: Wang Zhiyong Date: Sat, 11 May 2024 18:04:16 +0800 Subject: [PATCH] Fix unsupported parameter using (#512) fix unsupported parameter using --- src/cypher/parser/cypher_base_visitor.h | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/cypher/parser/cypher_base_visitor.h b/src/cypher/parser/cypher_base_visitor.h index 29b7283b36..aa5b6aeda4 100644 --- a/src/cypher/parser/cypher_base_visitor.h +++ b/src/cypher/parser/cypher_base_visitor.h @@ -888,13 +888,26 @@ class CypherBaseVisitor : public LcypherVisitor { } std::any visitOC_Properties(LcypherParser::OC_PropertiesContext *ctx) override { - if (ctx->oC_MapLiteral() == nullptr) { - CYPHER_TODO(); - return visitChildren(ctx); - } - Expression map_literal = std::any_cast(visit(ctx->oC_MapLiteral())); std::string parameter; - return std::make_tuple(map_literal, parameter); + if (ctx->oC_MapLiteral()) { + Expression map_literal = std::any_cast(visit(ctx->oC_MapLiteral())); + return std::make_tuple(map_literal, parameter); + } else if (ctx->oC_Parameter()) { + std::string parameter_val = ctx->oC_Parameter()->getText(); + if (ctx_->bolt_parameters_) { + auto iter = ctx_->bolt_parameters_->find(parameter_val); + if (iter == ctx_->bolt_parameters_->end()) { + throw lgraph::CypherException( + FMA_FMT("Parameter {} missing value", parameter_val)); + } + if (iter->second.type != Expression::DataType::MAP) { + throw lgraph::CypherException( + FMA_FMT("Parameter {} should be MAP type", parameter_val)); + } + return std::make_tuple(iter->second, parameter); + } + } + CYPHER_TODO(); } std::any visitOC_RelationshipTypes(