entity query builder progress
This commit is contained in:
@@ -1,11 +1,33 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include <matador/sql/connection.hpp>
|
||||
#include <matador/sql/entity_query_builder.hpp>
|
||||
|
||||
#include "models/author.hpp"
|
||||
#include "models/book.hpp"
|
||||
|
||||
struct schiff {
|
||||
std::string id;
|
||||
|
||||
template<typename Operator>
|
||||
void process(Operator &op)
|
||||
{
|
||||
namespace field = matador::utils::access;
|
||||
field::primary_key(op, "id", id, 255);
|
||||
}
|
||||
};
|
||||
|
||||
using namespace matador::sql;
|
||||
|
||||
TEST_CASE("Create sql query for entity", "[query][entity][builder]") {
|
||||
connection noop("noop://noop.db");
|
||||
schema scm("noop");
|
||||
scm.attach<matador::test::author>("authors");
|
||||
scm.attach<matador::test::book>("books");
|
||||
|
||||
entity_query_builder eqb(17);
|
||||
|
||||
auto context = eqb.build<matador::test::book>(noop, scm);
|
||||
std::cout << "SQL: " << context.value().sql << "\n";
|
||||
context = eqb.build<schiff>(noop, scm);
|
||||
}
|
||||
+12
-5
@@ -7,18 +7,25 @@
|
||||
|
||||
namespace matador::test {
|
||||
|
||||
struct category
|
||||
struct author
|
||||
{
|
||||
unsigned long id{};
|
||||
std::string name;
|
||||
std::string first_name;
|
||||
std::string last_name;
|
||||
std::string date_of_birth;
|
||||
unsigned short year_of_birth{};
|
||||
bool distinguished{false};
|
||||
|
||||
template<class Operator>
|
||||
template<typename Operator>
|
||||
void process(Operator &op)
|
||||
{
|
||||
namespace field = matador::utils::access;
|
||||
using namespace matador::utils;
|
||||
field::primary_key(op, "id", id);
|
||||
field::attribute(op, "name", name, 255);
|
||||
field::attribute(op, "first_name", first_name, 63);
|
||||
field::attribute(op, "last_name", last_name, 63);
|
||||
field::attribute(op, "date_of_birth", date_of_birth, 31);
|
||||
field::attribute(op, "year_of_birth", year_of_birth);
|
||||
field::attribute(op, "distinguished", distinguished);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user