added more tests

This commit is contained in:
Sascha Kühl
2025-02-06 16:17:47 +01:00
parent c76aa56440
commit 0b70f5d4ee
68 changed files with 2117 additions and 263 deletions
+52
View File
@@ -0,0 +1,52 @@
#ifndef QUERY_RECIPE_HPP
#define QUERY_RECIPE_HPP
#include "matador/utils/access.hpp"
#include "matador/utils/foreign_attributes.hpp"
#include "matador/object/object_ptr.hpp"
#include "matador/object/many_to_many_relation.hpp"
#include <string>
namespace matador::test {
struct recipe;
struct ingredient
{
unsigned int id{};
std::string name;
std::vector<matador::object::object_ptr<recipe>> recipes;
template<class Operator>
void process(Operator &op) {
namespace field = matador::access;
field::primary_key(op, "id", id);
field::attribute(op, "name", name, 255);
// field::has_many_to_many(op, "recipe_ingredients", recipes, "ingredient_id", "recipe_id", utils::fetch_type::EAGER);
}
};
struct recipe
{
unsigned int id{};
std::string name;
std::vector<matador::object::object_ptr<ingredient>> ingredients;
template<class Operator>
void process(Operator &op) {
namespace field = matador::access;
field::primary_key(op, "id", id);
field::attribute(op, "name", name, 255);
// field::has_many_to_many(op, "recipe_ingredients", ingredients, utils::fetch_type::LAZY);
}
};
class recipe_ingredient : public object::many_to_many_relation<recipe, ingredient> {
public:
recipe_ingredient() : many_to_many_relation("recipe_id", "ingredient_id") {}
};
}
#endif //QUERY_RECIPE_HPP