schema creation progress

This commit is contained in:
2025-12-07 22:18:01 +01:00
parent 2e354b435c
commit 2fcb504b9a
11 changed files with 336 additions and 168 deletions
+31 -31
View File
@@ -14,47 +14,47 @@ using namespace matador;
using namespace matador::test;
TEST_CASE_METHOD(SchemaFixture, "Test schema one-two-many", "[schema][one-to-many]") {
using namespace matador::test;
orm::schema repo(pool/*, "NoopSchema"*/);
using namespace matador::test;
orm::schema repo(pool/*, "NoopSchema"*/);
auto result = repo.attach<department>("departments")
.and_then( [&repo] { return repo.attach<employee>("employees"); } );
REQUIRE(result);
auto result = repo.attach<department>("departments")
.and_then([&repo] { return repo.attach<employee>("employees"); });
REQUIRE(result);
result = repo.create();
REQUIRE(result);
result = repo.create();
REQUIRE(result);
auto exists_result = repo.table_exists("departments");
REQUIRE(exists_result.is_ok());
REQUIRE(exists_result.value());
auto exists_result = repo.table_exists("departments");
REQUIRE(exists_result.is_ok());
REQUIRE(exists_result.value());
result = repo.drop();
REQUIRE(result);
result = repo.drop();
REQUIRE(result);
exists_result = repo.table_exists("departments");
REQUIRE(exists_result.is_ok());
REQUIRE(!exists_result.value());
exists_result = repo.table_exists("departments");
REQUIRE(exists_result.is_ok());
REQUIRE(!exists_result.value());
}
TEST_CASE_METHOD(SchemaFixture, "Test schema many-to-many", "[schema][many-to-many]") {
using namespace matador::test;
orm::schema repo(pool/*, "NoopSchema"*/);
using namespace matador::test;
orm::schema repo(pool/*, "NoopSchema"*/);
auto result = repo.attach<recipe>("recipes")
.and_then( [&repo] { return repo.attach<ingredient>("ingredients"); } );
REQUIRE(result);
auto result = repo.attach<recipe>("recipes")
.and_then([&repo] { return repo.attach<ingredient>("ingredients"); });
REQUIRE(result);
result = repo.create();
REQUIRE(result);
result = repo.create();
REQUIRE(result);
auto exists_result = repo.table_exists("recipes");
REQUIRE(exists_result.is_ok());
REQUIRE(exists_result.value());
auto exists_result = repo.table_exists("recipes");
REQUIRE(exists_result.is_ok());
REQUIRE(exists_result.value());
result = repo.drop();
REQUIRE(result);
result = repo.drop();
REQUIRE(result);
exists_result = repo.table_exists("recipes");
REQUIRE(exists_result.is_ok());
REQUIRE(!exists_result.value());
}
exists_result = repo.table_exists("recipes");
REQUIRE(exists_result.is_ok());
REQUIRE(!exists_result.value());
}