schema progress
This commit is contained in:
+8
-1
@@ -8,7 +8,12 @@ FetchContent_Declare(
|
||||
|
||||
FetchContent_MakeAvailable(Catch2)
|
||||
|
||||
add_executable(tests QueryBuilderTest.cpp
|
||||
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
|
||||
include(CTest)
|
||||
include(Catch)
|
||||
|
||||
add_executable(tests
|
||||
QueryBuilderTest.cpp
|
||||
RecordTest.cpp
|
||||
ConnectionPoolTest.cpp
|
||||
BackendProviderTest.cpp
|
||||
@@ -39,3 +44,5 @@ target_link_libraries(tests PRIVATE
|
||||
${SQLite3_LIBRARIES}
|
||||
${PostgreSQL_LIBRARY})
|
||||
target_include_directories(tests PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>/include)
|
||||
|
||||
catch_discover_tests(tests)
|
||||
|
||||
+15
-15
@@ -13,7 +13,7 @@ using namespace matador::utils;
|
||||
TEST_CASE("Create table sql statement string", "[query]")
|
||||
{
|
||||
connection noop("noop://noop.db");
|
||||
auto scm = std::make_shared<schema>("noop");
|
||||
schema scm("noop");
|
||||
query q(noop, scm);
|
||||
auto result = q.create().table({"person"}, {
|
||||
make_pk_column<unsigned long>("id"),
|
||||
@@ -38,7 +38,7 @@ TEST_CASE("Create table sql statement string", "[query]")
|
||||
TEST_CASE("Drop table sql statement string", "[query]")
|
||||
{
|
||||
connection noop("noop://noop.db");
|
||||
auto scm = std::make_shared<schema>("noop");
|
||||
schema scm("noop");
|
||||
query q(noop, scm);
|
||||
const auto result = q.drop().table("person").build();
|
||||
|
||||
@@ -49,7 +49,7 @@ TEST_CASE("Drop table sql statement string", "[query]")
|
||||
TEST_CASE("Select sql statement string", "[query]")
|
||||
{
|
||||
connection noop("noop://noop.db");
|
||||
auto scm = std::make_shared<schema>("noop");
|
||||
schema scm("noop");
|
||||
query q(noop, scm);
|
||||
const auto result = q.select({"id", "name", "age"}).from("person").build();
|
||||
|
||||
@@ -60,7 +60,7 @@ TEST_CASE("Select sql statement string", "[query]")
|
||||
TEST_CASE("Insert sql statement string", "[query]")
|
||||
{
|
||||
connection noop("noop://noop.db");
|
||||
auto scm = std::make_shared<schema>("noop");
|
||||
schema scm("noop");
|
||||
query q(noop, scm);
|
||||
const auto result = q.insert().into("person", {
|
||||
"id", "name", "age"
|
||||
@@ -73,7 +73,7 @@ TEST_CASE("Insert sql statement string", "[query]")
|
||||
TEST_CASE("Update sql statement string", "[query]")
|
||||
{
|
||||
connection noop("noop://noop.db");
|
||||
auto scm = std::make_shared<schema>("noop");
|
||||
schema scm("noop");
|
||||
query q(noop, scm);
|
||||
const auto result = q.update("person").set({
|
||||
{"id", 7UL},
|
||||
@@ -88,7 +88,7 @@ TEST_CASE("Update sql statement string", "[query]")
|
||||
TEST_CASE("Update limit sql statement", "[query][update][limit]")
|
||||
{
|
||||
connection noop("noop://noop.db");
|
||||
auto scm = std::make_shared<schema>("noop");
|
||||
schema scm("noop");
|
||||
query q(noop, scm);
|
||||
const auto result = q.update("person")
|
||||
.set({{"id", 7UL}, {"name", "george"}, {"age", 65U}})
|
||||
@@ -104,7 +104,7 @@ TEST_CASE("Update limit sql statement", "[query][update][limit]")
|
||||
TEST_CASE("Delete sql statement string", "[query]")
|
||||
{
|
||||
connection noop("noop://noop.db");
|
||||
auto scm = std::make_shared<schema>("noop");
|
||||
schema scm("noop");
|
||||
query q(noop, scm);
|
||||
const auto result = q.remove().from("person").build();
|
||||
|
||||
@@ -115,7 +115,7 @@ TEST_CASE("Delete sql statement string", "[query]")
|
||||
TEST_CASE("Delete limit sql statement", "[query][delete][limit]")
|
||||
{
|
||||
connection noop("noop://noop.db");
|
||||
auto scm = std::make_shared<schema>("noop");
|
||||
schema scm("noop");
|
||||
query q(noop, scm);
|
||||
const auto result = q.remove()
|
||||
.from("person")
|
||||
@@ -131,7 +131,7 @@ TEST_CASE("Delete limit sql statement", "[query][delete][limit]")
|
||||
TEST_CASE("Select sql statement string with where clause", "[query]")
|
||||
{
|
||||
connection noop("noop://noop.db");
|
||||
auto scm = std::make_shared<schema>("noop");
|
||||
schema scm("noop");
|
||||
query q(noop, scm);
|
||||
auto result = q.select({"id", "name", "age"})
|
||||
.from("person")
|
||||
@@ -153,7 +153,7 @@ TEST_CASE("Select sql statement string with where clause", "[query]")
|
||||
TEST_CASE("Insert sql statement with placeholder", "[query]")
|
||||
{
|
||||
connection noop("noop://noop.db");
|
||||
auto scm = std::make_shared<schema>("noop");
|
||||
schema scm("noop");
|
||||
query q(noop, scm);
|
||||
const auto result = q.insert().into("person", {
|
||||
"id", "name", "age"
|
||||
@@ -167,7 +167,7 @@ TEST_CASE("Insert sql statement with placeholder", "[query]")
|
||||
TEST_CASE("Select sql statement string with order by", "[query]")
|
||||
{
|
||||
connection noop("noop://noop.db");
|
||||
auto scm = std::make_shared<schema>("noop");
|
||||
schema scm("noop");
|
||||
query q(noop, scm);
|
||||
const auto result = q.select({"id", "name", "age"})
|
||||
.from("person")
|
||||
@@ -181,7 +181,7 @@ TEST_CASE("Select sql statement string with order by", "[query]")
|
||||
TEST_CASE("Select sql statement string with group by", "[query]")
|
||||
{
|
||||
connection noop("noop://noop.db");
|
||||
auto scm = std::make_shared<schema>("noop");
|
||||
schema scm("noop");
|
||||
query q(noop, scm);
|
||||
const auto result = q.select({"id", "name", "age"})
|
||||
.from("person")
|
||||
@@ -195,7 +195,7 @@ TEST_CASE("Select sql statement string with group by", "[query]")
|
||||
TEST_CASE("Select sql statement string with offset and limit", "[query]")
|
||||
{
|
||||
connection noop("noop://noop.db");
|
||||
auto scm = std::make_shared<schema>("noop");
|
||||
schema scm("noop");
|
||||
query q(noop, scm);
|
||||
const auto result = q.select({"id", "name", "age"})
|
||||
.from("person")
|
||||
@@ -211,7 +211,7 @@ TEST_CASE("Select sql statement string with offset and limit", "[query]")
|
||||
TEST_CASE("Create, insert and select a blob column", "[query][blob]")
|
||||
{
|
||||
connection noop("noop://noop.db");
|
||||
auto scm = std::make_shared<schema>("noop");
|
||||
schema scm("noop");
|
||||
query q(noop, scm);
|
||||
auto result = q.create().table("person", {
|
||||
make_pk_column<unsigned long>("id"),
|
||||
@@ -238,7 +238,7 @@ TEST_CASE("Create, insert and select a blob column", "[query][blob]")
|
||||
TEST_CASE("Select statement with join_left", "[query][join_left]")
|
||||
{
|
||||
connection noop("noop://noop.db");
|
||||
auto scm = std::make_shared<schema>("noop");
|
||||
schema scm("noop");
|
||||
query q(noop, scm);
|
||||
auto result = q.select({"f.id", "ap.brand", "f.pilot_name"})
|
||||
.from({"flight", "f"})
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "matador/utils/access.hpp"
|
||||
#include "matador/utils/cascade_type.hpp"
|
||||
#include "matador/utils/fetch_type.hpp"
|
||||
#include "matador/utils/field_attributes.hpp"
|
||||
|
||||
#include "matador/sql/entity.hpp"
|
||||
@@ -29,7 +30,7 @@ struct flight
|
||||
namespace field = matador::utils::access;
|
||||
using namespace matador::utils;
|
||||
field::primary_key(op, "id", id);
|
||||
field::has_one(op, "airplane_id", airplane, utils::cascade_type::ALL);
|
||||
field::has_one(op, "airplane_id", airplane, {utils::cascade_type::ALL, utils::fetch_type::EAGER});
|
||||
field::attribute(op, "pilot_name", pilot_name, 255);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -42,7 +42,7 @@ struct order
|
||||
field::attribute(op, "ship_region", ship_region, 255);
|
||||
field::attribute(op, "ship_postal_code", ship_postal_code, 255);
|
||||
field::attribute(op, "ship_country", ship_country, 255);
|
||||
field::has_many(op, "order_details", order_details_, fetch_type::EAGER);
|
||||
field::has_many(op, "order_details", order_details_, utils::fetch_type::EAGER);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user