relation_completer progress

This commit is contained in:
Sascha Kühl
2025-07-01 17:13:52 +02:00
parent 5a7ab5d4d0
commit 38cbffc18b
11 changed files with 153 additions and 32 deletions
+30
View File
@@ -2,6 +2,8 @@
#include "matador/object/schema.hpp"
#include "../../models/department.hpp"
struct node {};
using namespace matador;
@@ -15,6 +17,16 @@ struct person {
struct student final : person {};
struct teacher final : person {};
struct names {
std::vector<std::string> names_list;
template<typename Operator>
void process(Operator &op) {
namespace field = matador::access;
field::has_many(op, "name_list", names_list, "names_id", utils::fetch_type::EAGER);
}
};
TEST_CASE("Test empty prototype tree", "[schema_node][empty]") {
const object::schema tree;
@@ -51,4 +63,22 @@ TEST_CASE("Test next and previous of schema node", "[schema_node][next][previous
REQUIRE( it->name() == "person" );
REQUIRE( (--it)->name() == "person" );
REQUIRE( ++it == tree.end() );
}
TEST_CASE("Test automatic creating of a relation table with foreign key", "[schema][relation_table][foreign_key]") {
object::schema tree;
REQUIRE( tree.empty() );
auto res = tree.attach<test::department>("department");
REQUIRE( res.is_ok() );
}
TEST_CASE("Test automatic creating of a relation table with values", "[schema][relation_table][values]") {
object::schema tree;
REQUIRE( tree.empty() );
auto res = tree.attach<names>("names");
REQUIRE( res.is_ok() );
}