Skip to content
Snippets Groups Projects
Verified Commit b6086b31 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Merge branch 'f-query' into f-files

parents 7daa47c3 c84a193c
No related branches found
No related tags found
1 merge request!11F files
Pipeline #11584 failed
...@@ -253,17 +253,6 @@ private: ...@@ -253,17 +253,6 @@ private:
std::unique_ptr<Entity> entity; std::unique_ptr<Entity> entity;
}; };
// TODO(fspreck) One possibility for count-queries: Transaction gets a
// GetQueryCount function that returns exactly this. In case of a
// single FIND Query this will be equivalent to the Size of the
// ResultSet, but it may be different in case of Query + RetrieveById,
// and in case of COUNT queries which have an empty ResultSet. We have
// to think about how to extend this to transactions with more than
// one query in the future. My suggestion is to treat a transaction
// with more than one query as the union of the query results in which
// case the query count would return the cumulative number of
// results. This would even allow the combination of FIND, FIND
// unique, and COUNT, albeit a little strangely.
/** /**
* @brief Create a transaction via `CaosDBConnection.createTransaction()` * @brief Create a transaction via `CaosDBConnection.createTransaction()`
*/ */
...@@ -391,7 +380,7 @@ public: ...@@ -391,7 +380,7 @@ public:
* this transaction. In all other cases, the return value will be * this transaction. In all other cases, the return value will be
* -1. * -1.
*/ */
[[nodiscard]] inline auto GetCountResult() const -> int { [[nodiscard]] inline auto GetCountResult() const -> long {
return query_count; return query_count;
} }
...@@ -406,7 +395,7 @@ public: ...@@ -406,7 +395,7 @@ public:
} }
/** /**
* Get a JSON representation of the respone. * Get a JSON representation of the response.
* *
* For debugging. * For debugging.
*/ */
......
...@@ -169,8 +169,6 @@ Transaction::Transaction( ...@@ -169,8 +169,6 @@ Transaction::Transaction(
return this->status.GetCode(); return this->status.GetCode();
} }
// TODO(fspreck) What about count queries (mixed with retrievals),
// what about unique queries?
auto Transaction::Query(const std::string &query) noexcept -> StatusCode { auto Transaction::Query(const std::string &query) noexcept -> StatusCode {
ASSERT_CAN_ADD_QUERY ASSERT_CAN_ADD_QUERY
...@@ -190,7 +188,7 @@ auto Transaction::DeleteById(const std::string &id) noexcept -> StatusCode { ...@@ -190,7 +188,7 @@ auto Transaction::DeleteById(const std::string &id) noexcept -> StatusCode {
auto *sub_request = this->request->add_requests(); auto *sub_request = this->request->add_requests();
sub_request->mutable_delete_request()->set_id(id); sub_request->mutable_delete_request()->set_id(id);
this->status = TransactionStatus::READY(); this->status = TransactionStatus::GO_ON();
return this->status.GetCode(); return this->status.GetCode();
} }
......
...@@ -177,4 +177,16 @@ TEST(test_transaction, test_update_entity) { ...@@ -177,4 +177,16 @@ TEST(test_transaction, test_update_entity) {
EXPECT_EQ(error, StatusCode::ORIGINAL_ENTITY_MISSING_ID); EXPECT_EQ(error, StatusCode::ORIGINAL_ENTITY_MISSING_ID);
} }
TEST(test_transaction, test_multi_deletion) {
const auto *host = "localhost";
auto configuration = InsecureConnectionConfiguration(host, 8000);
Connection connection(configuration);
auto transaction = connection.CreateTransaction();
EXPECT_EQ(transaction.GetStatus().GetCode(), StatusCode::INITIAL);
for (int i = 0; i < 3; i++) {
auto status = transaction->DeleteById("asdf");
EXPECT_EQ(status, StatusCode::GO_ON);
}
}
} // namespace caosdb::transaction } // namespace caosdb::transaction
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment