Fix missing statistics for SetPropertiesCursor (#1460)

This commit is contained in:
Andi 2023-11-07 09:11:20 +01:00 committed by GitHub
parent 58648d1a70
commit f4b97fc03d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -2896,6 +2896,8 @@ void SetPropertiesOnRecord(TRecordAccessor *record, const TypedValue &rhs, SetPr
auto update_props = [&, record](PropertiesMap &new_properties) {
auto updated_properties = UpdatePropertiesChecked(record, new_properties);
// NOLINTNEXTLINE(bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions)
context->execution_stats[ExecutionStats::Key::UPDATED_PROPERTIES] += new_properties.size();
if (should_register_change) {
for (const auto &[id, old_value, new_value] : updated_properties) {

View File

@ -27,6 +27,7 @@
#include "query/exceptions.hpp"
#include "query/interpreter.hpp"
#include "query/interpreter_context.hpp"
#include "query/metadata.hpp"
#include "query/stream.hpp"
#include "query/typed_value.hpp"
#include "query_common.hpp"
@ -1274,6 +1275,24 @@ TYPED_TEST(InterpreterTest, ExecutionStatsValues) {
}
}
TYPED_TEST(InterpreterTest, ExecutionStatsValuesPropertiesSet) {
{
auto [stream, qid] = this->Prepare(
"CREATE (u:Employee {Uid: 'EMP_AAAAA', FirstName: 'Bong', LastName: 'Revilla'}) RETURN u.name AS name;");
this->Pull(&stream);
}
{
auto [stream, qid] = this->Prepare(
"MATCH (node:Employee) WHERE node.Uid='EMP_AAAAA' SET node={FirstName: 'James', LastName: 'Revilla', Uid: "
"'EMP_AAAAA', CreatedOn: 'null', CreatedBy: 'null', LastModifiedOn: '1698226931701', LastModifiedBy: 'null', "
"Description: 'null'};");
this->Pull(&stream);
auto stats = stream.GetSummary().at("stats").ValueMap();
auto key = memgraph::query::ExecutionStatsKeyToString(memgraph::query::ExecutionStats::Key::UPDATED_PROPERTIES);
ASSERT_EQ(stats[key].ValueInt(), 8);
}
}
TYPED_TEST(InterpreterTest, NotificationsValidStructure) {
{
auto [stream, qid] = this->Prepare("MATCH (n) DELETE n;");