From 04efc7a4a695ee1acad6d73e2bb3be3fa753cfe3 Mon Sep 17 00:00:00 2001
From: Andi <andi8647@gmail.com>
Date: Tue, 31 Jan 2023 13:11:59 +0100
Subject: [PATCH 1/3] Remove torch and igraph from sys cache (#720)

---
 src/query/procedure/module.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/query/procedure/module.cpp b/src/query/procedure/module.cpp
index a063881e4..b7d0cb55c 100644
--- a/src/query/procedure/module.cpp
+++ b/src/query/procedure/module.cpp
@@ -1,4 +1,4 @@
-// Copyright 2022 Memgraph Ltd.
+// Copyright 2023 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
@@ -35,7 +35,7 @@ namespace memgraph::query::procedure {
 
 constexpr const char *func_code =
     "import ast\n\n"
-    "no_removals = ['collections', 'abc', 'sys']\n"
+    "no_removals = ['collections', 'abc', 'sys', 'torch', 'torch_geometric', 'igraph']\n"
     "modules = set()\n\n"
     "def visit_Import(node):\n"
     "  for name in node.names:\n"

From 14c651d3ba4ead72fc39d26e8e847b912d563a1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bruno=20Sa=C4=8Dari=C4=87?= <bruno.sacaric@gmail.com>
Date: Tue, 31 Jan 2023 23:20:49 +0100
Subject: [PATCH 2/3] edit workflows (#756)

---
 .github/workflows/daily_benchmark.yaml    | 2 +-
 .github/workflows/release_centos8.yaml    | 2 +-
 .github/workflows/release_debian10.yaml   | 2 +-
 .github/workflows/release_ubuntu2004.yaml | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/daily_benchmark.yaml b/.github/workflows/daily_benchmark.yaml
index 5842a3cf5..118371231 100644
--- a/.github/workflows/daily_benchmark.yaml
+++ b/.github/workflows/daily_benchmark.yaml
@@ -3,7 +3,7 @@ name: Daily Benchmark
 on:
   workflow_dispatch:
   schedule:
-    - cron: "0 1 * * *"
+    - cron: "0 22 * * *"
 
 jobs:
   release_benchmarks:
diff --git a/.github/workflows/release_centos8.yaml b/.github/workflows/release_centos8.yaml
index cd54749e9..ae5c176d0 100644
--- a/.github/workflows/release_centos8.yaml
+++ b/.github/workflows/release_centos8.yaml
@@ -3,7 +3,7 @@ name: Release CentOS 8
 on:
   workflow_dispatch:
   schedule:
-    - cron: "0 1 * * *"
+    - cron: "0 22 * * *"
 
 jobs:
   community_build:
diff --git a/.github/workflows/release_debian10.yaml b/.github/workflows/release_debian10.yaml
index e434a37ea..2bcd2560e 100644
--- a/.github/workflows/release_debian10.yaml
+++ b/.github/workflows/release_debian10.yaml
@@ -3,7 +3,7 @@ name: Release Debian 10
 on:
   workflow_dispatch:
   schedule:
-    - cron: "0 1 * * *"
+    - cron: "0 22 * * *"
 
 jobs:
   community_build:
diff --git a/.github/workflows/release_ubuntu2004.yaml b/.github/workflows/release_ubuntu2004.yaml
index ab96159c6..b92ddf58e 100644
--- a/.github/workflows/release_ubuntu2004.yaml
+++ b/.github/workflows/release_ubuntu2004.yaml
@@ -3,7 +3,7 @@ name: Release Ubuntu 20.04
 on:
   workflow_dispatch:
   schedule:
-    - cron: "0 1 * * *"
+    - cron: "0 22 * * *"
 
 jobs:
   community_build:

From 8f70c5f2a5a3644e52b1eca6489e33b95209c3e0 Mon Sep 17 00:00:00 2001
From: Josipmrden <josip.mrden@memgraph.io>
Date: Wed, 1 Feb 2023 13:20:26 +0100
Subject: [PATCH 3/3] Fix label-based auth using OLD view instead of NEW when
 merging nodes (#755)

---
 src/query/plan/operator.cpp                   | 20 ++++++++++--------
 .../create_delete_filtering_tests.py          | 21 ++++++++++++++++---
 2 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/src/query/plan/operator.cpp b/src/query/plan/operator.cpp
index 6583a52a3..645b0a463 100644
--- a/src/query/plan/operator.cpp
+++ b/src/query/plan/operator.cpp
@@ -410,10 +410,11 @@ VertexAccessor &CreateExpand::CreateExpandCursor::OtherVertex(Frame &frame, Exec
 template <class TVerticesFun>
 class ScanAllCursor : public Cursor {
  public:
-  explicit ScanAllCursor(Symbol output_symbol, UniqueCursorPtr input_cursor, TVerticesFun get_vertices,
-                         const char *op_name)
+  explicit ScanAllCursor(Symbol output_symbol, UniqueCursorPtr input_cursor, storage::View view,
+                         TVerticesFun get_vertices, const char *op_name)
       : output_symbol_(output_symbol),
         input_cursor_(std::move(input_cursor)),
+        view_(view),
         get_vertices_(std::move(get_vertices)),
         op_name_(op_name) {}
 
@@ -448,7 +449,7 @@ class ScanAllCursor : public Cursor {
 #ifdef MG_ENTERPRISE
   bool FindNextVertex(const ExecutionContext &context) {
     while (vertices_it_.value() != vertices_.value().end()) {
-      if (context.auth_checker->Has(*vertices_it_.value(), memgraph::storage::View::OLD,
+      if (context.auth_checker->Has(*vertices_it_.value(), view_,
                                     memgraph::query::AuthQuery::FineGrainedPrivilege::READ)) {
         return true;
       }
@@ -469,6 +470,7 @@ class ScanAllCursor : public Cursor {
  private:
   const Symbol output_symbol_;
   const UniqueCursorPtr input_cursor_;
+  storage::View view_;
   TVerticesFun get_vertices_;
   std::optional<typename std::result_of<TVerticesFun(Frame &, ExecutionContext &)>::type::value_type> vertices_;
   std::optional<decltype(vertices_.value().begin())> vertices_it_;
@@ -487,7 +489,7 @@ UniqueCursorPtr ScanAll::MakeCursor(utils::MemoryResource *mem) const {
     auto *db = context.db_accessor;
     return std::make_optional(db->Vertices(view_));
   };
-  return MakeUniqueCursorPtr<ScanAllCursor<decltype(vertices)>>(mem, output_symbol_, input_->MakeCursor(mem),
+  return MakeUniqueCursorPtr<ScanAllCursor<decltype(vertices)>>(mem, output_symbol_, input_->MakeCursor(mem), view_,
                                                                 std::move(vertices), "ScanAll");
 }
 
@@ -510,7 +512,7 @@ UniqueCursorPtr ScanAllByLabel::MakeCursor(utils::MemoryResource *mem) const {
     auto *db = context.db_accessor;
     return std::make_optional(db->Vertices(view_, label_));
   };
-  return MakeUniqueCursorPtr<ScanAllCursor<decltype(vertices)>>(mem, output_symbol_, input_->MakeCursor(mem),
+  return MakeUniqueCursorPtr<ScanAllCursor<decltype(vertices)>>(mem, output_symbol_, input_->MakeCursor(mem), view_,
                                                                 std::move(vertices), "ScanAllByLabel");
 }
 
@@ -575,7 +577,7 @@ UniqueCursorPtr ScanAllByLabelPropertyRange::MakeCursor(utils::MemoryResource *m
     if (maybe_upper && maybe_upper->value().IsNull()) return std::nullopt;
     return std::make_optional(db->Vertices(view_, label_, property_, maybe_lower, maybe_upper));
   };
-  return MakeUniqueCursorPtr<ScanAllCursor<decltype(vertices)>>(mem, output_symbol_, input_->MakeCursor(mem),
+  return MakeUniqueCursorPtr<ScanAllCursor<decltype(vertices)>>(mem, output_symbol_, input_->MakeCursor(mem), view_,
                                                                 std::move(vertices), "ScanAllByLabelPropertyRange");
 }
 
@@ -607,7 +609,7 @@ UniqueCursorPtr ScanAllByLabelPropertyValue::MakeCursor(utils::MemoryResource *m
     }
     return std::make_optional(db->Vertices(view_, label_, property_, storage::PropertyValue(value)));
   };
-  return MakeUniqueCursorPtr<ScanAllCursor<decltype(vertices)>>(mem, output_symbol_, input_->MakeCursor(mem),
+  return MakeUniqueCursorPtr<ScanAllCursor<decltype(vertices)>>(mem, output_symbol_, input_->MakeCursor(mem), view_,
                                                                 std::move(vertices), "ScanAllByLabelPropertyValue");
 }
 
@@ -625,7 +627,7 @@ UniqueCursorPtr ScanAllByLabelProperty::MakeCursor(utils::MemoryResource *mem) c
     auto *db = context.db_accessor;
     return std::make_optional(db->Vertices(view_, label_, property_));
   };
-  return MakeUniqueCursorPtr<ScanAllCursor<decltype(vertices)>>(mem, output_symbol_, input_->MakeCursor(mem),
+  return MakeUniqueCursorPtr<ScanAllCursor<decltype(vertices)>>(mem, output_symbol_, input_->MakeCursor(mem), view_,
                                                                 std::move(vertices), "ScanAllByLabelProperty");
 }
 
@@ -651,7 +653,7 @@ UniqueCursorPtr ScanAllById::MakeCursor(utils::MemoryResource *mem) const {
     if (!maybe_vertex) return std::nullopt;
     return std::vector<VertexAccessor>{*maybe_vertex};
   };
-  return MakeUniqueCursorPtr<ScanAllCursor<decltype(vertices)>>(mem, output_symbol_, input_->MakeCursor(mem),
+  return MakeUniqueCursorPtr<ScanAllCursor<decltype(vertices)>>(mem, output_symbol_, input_->MakeCursor(mem), view_,
                                                                 std::move(vertices), "ScanAllById");
 }
 
diff --git a/tests/e2e/fine_grained_access/create_delete_filtering_tests.py b/tests/e2e/fine_grained_access/create_delete_filtering_tests.py
index a97d69550..9966c3039 100644
--- a/tests/e2e/fine_grained_access/create_delete_filtering_tests.py
+++ b/tests/e2e/fine_grained_access/create_delete_filtering_tests.py
@@ -9,12 +9,11 @@
 # by the Apache License, Version 2.0, included in the file
 # licenses/APL.txt.
 
-import pytest
 import sys
 
-from mgclient import DatabaseError
-
 import common
+import pytest
+from mgclient import DatabaseError
 
 
 def test_create_node_all_labels_granted():
@@ -513,5 +512,21 @@ def test_remove_label_when_label_denied():
         common.execute_and_fetch_all(user_connection.cursor(), "MATCH (p:test_delete) REMOVE p:test_delete;")
 
 
+def test_merge_nodes_pass_when_having_create_delete():
+    admin_connection = common.connect(username="admin", password="test")
+    user_connection = common.connect(username="user", password="test")
+
+    common.reset_and_prepare(admin_connection.cursor())
+    common.execute_and_fetch_all(admin_connection.cursor(), "GRANT CREATE_DELETE ON LABELS * TO user;")
+    common.execute_and_fetch_all(admin_connection.cursor(), "GRANT CREATE_DELETE ON EDGE_TYPES * TO user;")
+
+    results = common.execute_and_fetch_all(
+        user_connection.cursor(),
+        "UNWIND [{id: '1', lat: 10, lng: 10}, {id: '2', lat: 10, lng: 10}, {id: '3', lat: 10, lng: 10}] AS row MERGE (o:Location {id: row.id}) RETURN o;",
+    )
+
+    assert len(results) == 3
+
+
 if __name__ == "__main__":
     sys.exit(pytest.main([__file__, "-rA"]))