entity query and record progress
This commit is contained in:
+4
-1
@@ -35,7 +35,10 @@ add_executable(tests
|
||||
models/optional.hpp
|
||||
ConvertTest.cpp
|
||||
DummyConnection.hpp
|
||||
DummyConnection.cpp)
|
||||
DummyConnection.cpp
|
||||
EntityQueryBuilderTest.cpp
|
||||
models/author.hpp
|
||||
models/book.hpp)
|
||||
|
||||
target_link_libraries(tests PRIVATE
|
||||
Catch2::Catch2WithMain
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include <matador/sql/connection.hpp>
|
||||
|
||||
using namespace matador::sql;
|
||||
|
||||
TEST_CASE("Create sql query for entity", "[query][entity][builder]") {
|
||||
connection noop("noop://noop.db");
|
||||
schema scm("noop");
|
||||
|
||||
}
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <matador/sql/condition.hpp>
|
||||
#include <matador/sql/connection.hpp>
|
||||
#include <matador/sql/dialect_builder.hpp>
|
||||
#include <matador/sql/query_builder.hpp>
|
||||
#include <matador/sql/query.hpp>
|
||||
|
||||
using namespace matador::sql;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef QUERY_AUTHOR_HPP
|
||||
#define QUERY_AUTHOR_HPP
|
||||
|
||||
#include "matador/utils/access.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace matador::test {
|
||||
|
||||
struct category
|
||||
{
|
||||
unsigned long id{};
|
||||
std::string name;
|
||||
|
||||
template<class 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);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //QUERY_AUTHOR_HPP
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef QUERY_BOOK_HPP
|
||||
#define QUERY_BOOK_HPP
|
||||
|
||||
#include "matador/sql/entity.hpp"
|
||||
|
||||
#include "matador/utils/access.hpp"
|
||||
#include "matador/utils/foreign_attributes.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace matador::test {
|
||||
|
||||
struct author;
|
||||
|
||||
struct book
|
||||
{
|
||||
unsigned long id{};
|
||||
matador::sql::entity<author> book_author;
|
||||
std::string title;
|
||||
unsigned short published_in{};
|
||||
|
||||
template<typename Operator>
|
||||
void process(Operator &op)
|
||||
{
|
||||
namespace field = matador::utils::access;
|
||||
field::primary_key(op, "id", id);
|
||||
field::attribute(op, "title", title, 511);
|
||||
field::has_one(op, "author_id", book_author, matador::utils::default_foreign_attributes);
|
||||
field::attribute(op, "published_in", published_in);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
#endif //QUERY_BOOK_HPP
|
||||
Reference in New Issue
Block a user