insert_query_builder progress

This commit is contained in:
2026-04-12 22:07:24 +02:00
parent f03664d60a
commit a0326632ab
25 changed files with 319 additions and 124 deletions
+3 -4
View File
@@ -7,8 +7,7 @@
namespace matador::test {
SessionFixture::SessionFixture()
: ses({bus, connection::dns, 4}, schema)
, db(connection::dns) {
: db(connection::dns) {
REQUIRE(db.open());
}
@@ -19,8 +18,8 @@ SessionFixture::~SessionFixture() {
}
void SessionFixture::drop_table_if_exists(const std::string &table_name) const {
if (ses.table_exists(table_name)) {
REQUIRE(ses.drop_table(table_name));
if (db.exists(table_name)) {
REQUIRE(query::drop().table(table_name).execute(db));
}
}
-3
View File
@@ -5,8 +5,6 @@
#include "matador/utils/message_bus.hpp"
#include <stack>
namespace matador::test {
class SessionFixture {
@@ -15,7 +13,6 @@ public:
~SessionFixture();
protected:
orm::session ses;
utils::message_bus bus;
sql::connection db;
+3
View File
@@ -2,6 +2,8 @@
#include "SessionFixture.hpp"
#include "connection.hpp"
#include "models/author.hpp"
#include "models/book.hpp"
@@ -15,6 +17,7 @@ TEST_CASE_METHOD(SessionFixture, "Test insert object with has many relation", "[
.and_then([this] { return schema.create(db); } );
REQUIRE(result.is_ok());
orm::session ses({bus, connection::dns, 4}, schema);
schema.initialize(ses);
auto s_king = make_object<author>(1, "Steven", "King", "21.9.1947", 1956, false);
+17
View File
@@ -2,6 +2,8 @@
#include "SessionFixture.hpp"
#include "connection.hpp"
#include "models/airplane.hpp"
#include "models/author.hpp"
#include "models/book.hpp"
@@ -20,6 +22,7 @@ TEST_CASE_METHOD(SessionFixture, "Session insert test", "[session][insert]") {
.and_then([this] { return schema.create(db); } );
REQUIRE(result.is_ok());
orm::session ses({bus, connection::dns, 4}, schema);
auto plane = ses.insert(make_object<airplane>(1, "Boeing", "A380"));
REQUIRE(plane.is_ok());
@@ -36,6 +39,7 @@ TEST_CASE_METHOD(SessionFixture, "Session update test", "[session][update]") {
.and_then([this] { return schema.create(db); } );
REQUIRE(res.is_ok());
orm::session ses({bus, connection::dns, 4}, schema);
auto result = ses.insert(make_object<airplane>(1, "Boeing", "A380"));
REQUIRE(result.is_ok());
@@ -66,6 +70,8 @@ TEST_CASE_METHOD(SessionFixture, "Session delete test", "[session][delete]") {
.and_then([this] { return schema.create(db); } );
REQUIRE(res.is_ok());
orm::session ses({bus, connection::dns, 4}, schema);
schema.initialize(ses);
auto result = ses.insert(make_object<airplane>(1, "Boeing", "A380"));
@@ -90,6 +96,7 @@ TEST_CASE_METHOD(SessionFixture, "Session relation test", "[session][relation]")
.and_then([this] { return schema.create(db); } );
REQUIRE(result.is_ok());
orm::session ses({bus, connection::dns, 4}, schema);
auto plane = ses.insert(make_object<airplane>(1, "Boeing", "A380"));
REQUIRE(plane.is_ok());
auto f = ses.insert(make_object<flight>(2, *plane, "sully"));
@@ -111,6 +118,7 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find object with id", "[session
.and_then([this] { return schema.create(db); } );
REQUIRE(result.is_ok());
orm::session ses({bus, connection::dns, 4}, schema);
auto a380 = ses.insert(make_object<airplane>(1, "Boeing", "A380"));
REQUIRE(a380.is_ok());
@@ -130,6 +138,8 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects", "[session][f
.and_then([this] { return schema.create(db); } );
REQUIRE(result.is_ok());
orm::session ses({bus, connection::dns, 4}, schema);
std::vector planes {
make_object<airplane>(1, "Airbus", "A380"),
make_object<airplane>(2, "Boeing", "707"),
@@ -165,6 +175,7 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with one-to-ma
.and_then([this] { return schema.create(db); } );
REQUIRE(result.is_ok());
orm::session ses({bus, connection::dns, 4}, schema);
schema.initialize(ses);
std::vector authors {
make_object<author>(1, "Michael", "Crichton", "23.10.1942", 1975, true),
@@ -219,6 +230,8 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with one-to-ma
.and_then([this] { return schema.create(db); } );
REQUIRE(result.is_ok());
orm::session ses({bus, connection::dns, 4}, schema);
std::vector departments {
make_object<department>(1, "Insurance"),
make_object<department>(2, "Invoice")
@@ -276,6 +289,8 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with many-to-m
return schema.create(db);
} );
orm::session ses({bus, connection::dns, 4}, schema);
std::vector ingredients {
make_object<ingredient>(1, "Apple"),
make_object<ingredient>(2, "Strawberry"),
@@ -310,6 +325,8 @@ TEST_CASE_METHOD(SessionFixture, "Use session to find all objects with many-to-m
return schema.create(db);
} );
orm::session ses({bus, connection::dns, 4}, schema);
std::vector ingredients {
make_object<ingredient>(1, "Apple"),
make_object<ingredient>(2, "Strawberry"),