diff --git a/src/query/procedure/mg_procedure_impl.cpp b/src/query/procedure/mg_procedure_impl.cpp index 7f036e229..491083eaf 100644 --- a/src/query/procedure/mg_procedure_impl.cpp +++ b/src/query/procedure/mg_procedure_impl.cpp @@ -1521,13 +1521,14 @@ std::ostream &PrintValue(const TypedValue &value, std::ostream *stream) { } } // namespace + void PrintProcSignature(const mgp_proc &proc, std::ostream *stream) { (*stream) << proc.name << "("; utils::PrintIterable( *stream, proc.args, ", ", [](auto &stream, const auto &arg) { stream << arg.first << " :: " << arg.second->GetPresentableName(); }); - if (!proc.opt_args.empty()) (*stream) << ", "; + if (!proc.args.empty() && !proc.opt_args.empty()) (*stream) << ", "; utils::PrintIterable( *stream, proc.opt_args, ", ", [](auto &stream, const auto &arg) { stream << std::get<0>(arg) << " = "; diff --git a/tests/unit/query_procedure_mgp_module.cpp b/tests/unit/query_procedure_mgp_module.cpp index 6d6719565..3f93a9a02 100644 --- a/tests/unit/query_procedure_mgp_module.cpp +++ b/tests/unit/query_procedure_mgp_module.cpp @@ -90,3 +90,12 @@ TEST(Module, ProcedureSignature) { "opt2 = \"string=\\\"value\\\"\" :: STRING) :: " "(res1 :: LIST OF INTEGER, DEPRECATED res2 :: STRING)"); } + +TEST(Module, ProcedureSignatureOnlyOptArg) { + mgp_memory memory{utils::NewDeleteResource()}; + mgp_module module(utils::NewDeleteResource()); + auto *proc = mgp_module_add_read_procedure(&module, "proc", DummyCallback); + mgp_proc_add_opt_arg(proc, "opt1", mgp_type_nullable(mgp_type_any()), + mgp_value_make_null(&memory)); + CheckSignature(proc, "proc(opt1 = Null :: ANY?) :: ()"); +}