Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/reusable_package_mage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@

- name: Check mgdeps-cache availability
run: |
if curl --silent --fail "http://mgdeps-cache:8000/wheels/" -o /dev/null; then
if [ "${{ inputs.arch }}" == "amd64" ]; then

Check failure

Code scanning / SonarCloud

GitHub Actions should not be vulnerable to script injections High

Change this workflow to not use user-controlled data directly in a run block. See more on SonarQube Cloud
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be fixed in my reworking of all of MAGE's workflows.

echo "mgdeps-cache is temporary disabled for amd64"
echo "CACHE_PRESENT=false" >> $GITHUB_ENV
elif curl --silent --fail "http://mgdeps-cache:8000/wheels/" -o /dev/null; then
echo "mgdeps-cache is reachable :D"
echo "CACHE_PRESENT=true" >> $GITHUB_ENV
else
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/reusable_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@

- name: Check mgdeps-cache availability
run: |
if curl --silent --fail "http://mgdeps-cache:8000/wheels/" -o /dev/null; then
if [ "${{ inputs.arch }}" == "amd64" ]; then

Check failure

Code scanning / SonarCloud

GitHub Actions should not be vulnerable to script injections High

Change this workflow to not use user-controlled data directly in a run block. See more on SonarQube Cloud
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be fixed in my reworking of all of MAGE's workflows.

echo "mgdeps-cache is temporary disabled for amd64"
echo "CACHE_PRESENT=false" >> $GITHUB_ENV
elif curl --silent --fail "http://mgdeps-cache:8000/wheels/" -o /dev/null; then
echo "mgdeps-cache is reachable :D"
echo "CACHE_PRESENT=true" >> $GITHUB_ENV
else
Expand Down
5 changes: 3 additions & 2 deletions cpp/map_module/algorithm/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,10 @@ void Map::Merge(mgp_list *args, mgp_func_context *ctx, mgp_func_result *res, mgp
mgp::MemoryDispatcherGuard guard{memory};
const auto arguments = mgp::List(args);
auto result = mgp::Result(res);

try {
const auto map1 = arguments[0].ValueMap();
const auto map2 = arguments[1].ValueMap();
const auto map1 = arguments[0].IsMap() ? arguments[0].ValueMap() : mgp::Map();
const auto map2 = arguments[1].IsMap() ? arguments[1].ValueMap() : mgp::Map();

mgp::Map merged_map = mgp::Map(std::move(map2));
for (const auto element : map1) {
Expand Down
31 changes: 19 additions & 12 deletions cpp/map_module/map_module.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <mgp.hpp>

#include "_mgp.hpp"
#include "algorithm/map.hpp"

extern "C" int mgp_init_module(struct mgp_module *module, struct mgp_memory *memory) {
Expand All @@ -17,14 +18,6 @@ extern "C" int mgp_init_module(struct mgp_module *module, struct mgp_memory *mem
mgp::Parameter(std::string(Map::kArgumentListValuesFromLists).c_str(), {mgp::Type::List, mgp::Type::Any})},
module, memory);

mgp::AddFunction(
Map::RemoveKeys, std::string(Map::kProcedureRemoveKeys).c_str(),
{mgp::Parameter(std::string(Map::kArgumentsInputMapRemoveKeys).c_str(), mgp::Type::Map),
mgp::Parameter(std::string(Map::kArgumentsKeysListRemoveKeys).c_str(), {mgp::Type::List, mgp::Type::String}),
mgp::Parameter(std::string(Map::kArgumentsRecursiveRemoveKeys).c_str(), mgp::Type::Map,
mgp::Value(mgp::Map()))},
module, memory);

mgp::AddFunction(
Map::RemoveKey, Map::kProcedureRemoveKey,
{mgp::Parameter(Map::kArgumentsInputMap, mgp::Type::Map), mgp::Parameter(Map::kArgumentsKey, mgp::Type::String),
Expand All @@ -34,10 +27,24 @@ extern "C" int mgp_init_module(struct mgp_module *module, struct mgp_memory *mem
mgp::AddFunction(Map::FromPairs, Map::kProcedureFromPairs,
{mgp::Parameter(Map::kArgumentsInputList, {mgp::Type::List, mgp::Type::List})}, module, memory);

mgp::AddFunction(Map::Merge, Map::kProcedureMerge,
{mgp::Parameter(Map::kArgumentsInputMap1, mgp::Type::Map),
mgp::Parameter(Map::kArgumentsInputMap2, mgp::Type::Map)},
module, memory);
{
// mgp::AddFunction(Map::Merge, Map::kProcedureMerge,
// {mgp::Parameter(Map::kArgumentsInputMap1, mgp::Type::Any, mgp::Value(mgp::Map())),
// mgp::Parameter(Map::kArgumentsInputMap2, mgp::Type::Any, mgp::Value(mgp::Map()))},
// module, memory);

auto *func = mgp::module_add_function(module, Map::kProcedureMerge.data(), Map::Merge);
mgp::func_add_arg(func, Map::kArgumentsInputMap1.data(), mgp::type_nullable(mgp::type_map()));
mgp::func_add_arg(func, Map::kArgumentsInputMap2.data(), mgp::type_nullable(mgp::type_map()));
}

mgp::AddFunction(
Map::RemoveKeys, std::string(Map::kProcedureRemoveKeys).c_str(),
{mgp::Parameter(std::string(Map::kArgumentsInputMapRemoveKeys).c_str(), mgp::Type::Map),
mgp::Parameter(std::string(Map::kArgumentsKeysListRemoveKeys).c_str(), {mgp::Type::List, mgp::Type::String}),
mgp::Parameter(std::string(Map::kArgumentsRecursiveRemoveKeys).c_str(), mgp::Type::Map,
mgp::Value(mgp::Map()))},
module, memory);

AddProcedure(Map::FromNodes, Map::kProcedureFromNodes, mgp::ProcedureType::Read,
{mgp::Parameter(Map::kFromNodesArg1, mgp::Type::String),
Expand Down
4 changes: 2 additions & 2 deletions e2e/map_test/test_merge_empty/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
query: >
RETURN map.merge({}, {}) AS merged
RETURN map.merge(null, {id: 1}) AS merged

output:
- merged: {}
- merged: {id: 1}
Empty file.
5 changes: 5 additions & 0 deletions e2e/map_test/test_merge_null/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
query: >
RETURN map.merge({id: 1}, null) AS merged

output:
- merged: {id: 1}
Empty file.
5 changes: 5 additions & 0 deletions e2e/map_test/test_merge_null_2/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
query: >
RETURN map.merge(null, {id: 1}) AS merged

output:
- merged: {id: 1}