added session context and implemented the executor interface for session

This commit is contained in:
Sascha Kühl
2025-08-14 15:48:21 +02:00
parent a32330ef5b
commit 843d125b99
19 changed files with 131 additions and 100 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
namespace matador::test {
SessionFixture::SessionFixture()
: pool(connection::dns, 4), ses(pool) {}
: pool(connection::dns, 4), ses({bus, pool}) {}
SessionFixture::~SessionFixture() {
while (!tables_to_drop.empty()) {
+3
View File
@@ -3,6 +3,8 @@
#include "matador/orm/session.hpp"
#include "matador/utils/message_bus.hpp"
#include "connection.hpp"
#include <stack>
@@ -18,6 +20,7 @@ protected:
sql::connection_pool pool;
std::stack <std::string> tables_to_drop;
orm::session ses;
utils::message_bus bus;
private:
void drop_table_if_exists(const std::string &table_name) const;
-3
View File
@@ -234,7 +234,4 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with many-to-m
recipes.push_back(std::make_unique<recipe>(7, "Apple Crumble"));
recipes.push_back(std::make_unique<recipe>(8, "Beans Chili"));
recipes.push_back(std::make_unique<recipe>(9, "Fruit Salad"));
}
+2 -2
View File
@@ -15,13 +15,13 @@ class StatementCacheFixture
{
public:
StatementCacheFixture()
: pool(test::connection::dns, 4), ses(pool)
: pool(test::connection::dns, 4)//, ses(pool)
{}
~StatementCacheFixture() = default;
protected:
sql::connection_pool pool;
orm::session ses;
// orm::session ses;
};
TEST_CASE_METHOD(StatementCacheFixture, "Acquire prepared statement", "[statement cache]") {
+1 -2
View File
@@ -14,8 +14,7 @@ utils::result<size_t, utils::error> test_statement::execute(const sql::parameter
using namespace std::chrono_literals;
std::mt19937 rng(query_.sql.size());
std::uniform_int_distribution dist(10, 50);
std::this_thread::sleep_for(std::chrono::milliseconds(50));
// std::this_thread::sleep_for(std::chrono::milliseconds(dist(rng)));
std::this_thread::sleep_for(std::chrono::milliseconds(dist(rng)));
return utils::ok(static_cast<size_t>(8));
}