From f4f914dd4b03feaeaa238a10fe9b9b5082a94b37 Mon Sep 17 00:00:00 2001
From: Daniel <d.hornung@indiscale.com>
Date: Wed, 25 Aug 2021 10:10:27 +0200
Subject: [PATCH] FIX: Transaction::GetResultSet() now always returns a good
 reference

---
 CHANGELOG.md                 | 2 ++
 include/caosdb/transaction.h | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index aa0ef42..db5c51a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,4 +20,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Fixed
 
+* #11 - Transaction::GetResultSet() now always returns a valid reference.
+
 ### Security
diff --git a/include/caosdb/transaction.h b/include/caosdb/transaction.h
index 621c6cb..f92cf28 100644
--- a/include/caosdb/transaction.h
+++ b/include/caosdb/transaction.h
@@ -365,6 +365,10 @@ public:
   [[nodiscard]] inline auto GetStatus() const noexcept -> TransactionStatus { return this->status; }
 
   [[nodiscard]] inline auto GetResultSet() const noexcept -> const ResultSet & {
+    if (!this->result_set) {
+      this->result_set = std::make_unique<MultiResultSet>(
+          std::move(std::vector<std::unique_ptr<Entity>>()));
+    }
     return *(this->result_set.get());
   }
 
-- 
GitLab