fixed linux compile
This commit is contained in:
parent
5d41a592bb
commit
2efb106fc3
|
|
@ -2,7 +2,7 @@ CPMAddPackage("gh:catchorg/Catch2@3.7.1")
|
|||
|
||||
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
|
||||
|
||||
set(POSTGRES_CONNECTION_STRING "postgres://test:test123@localhost:15432/testdb")
|
||||
set(POSTGRES_CONNECTION_STRING "postgres://test:test123!@localhost:5432/matador")
|
||||
|
||||
configure_file(Connection.hpp.in ${PROJECT_BINARY_DIR}/backends/postgres/test/connection.hpp @ONLY IMMEDIATE)
|
||||
|
||||
|
|
@ -35,8 +35,8 @@ add_executable(${LIBRARY_TEST_TARGET} ${TEST_SOURCES})
|
|||
|
||||
target_link_libraries(${LIBRARY_TEST_TARGET} PRIVATE
|
||||
Catch2::Catch2WithMain
|
||||
matador-utils
|
||||
matador-query
|
||||
matador-core
|
||||
matador-orm
|
||||
${CMAKE_DL_LIBS}
|
||||
${PostgreSQL_LIBRARY})
|
||||
|
||||
|
|
|
|||
|
|
@ -32,16 +32,14 @@ public:
|
|||
void on_primary_key(const char *id, std::string &pk, size_t size);
|
||||
void on_revision(const char *id, uint64_t &rev);
|
||||
template < class Type >
|
||||
void on_attribute(const char *, Type &x, const utils::field_attributes &/*attr*/ = utils::null_attributes)
|
||||
{
|
||||
void on_attribute(const char *, Type &x, const utils::field_attributes &/*attr*/ = utils::null_attributes) {
|
||||
utils::data_type_traits<Type>::bind_value(*this, 0, x);
|
||||
}
|
||||
void on_attribute(const char *id, char *x, const utils::field_attributes &/*attr*/ = utils::null_attributes);
|
||||
void on_attribute(const char *id, std::string &x, const utils::field_attributes &/*attr*/ = utils::null_attributes);
|
||||
|
||||
template<class Type, template < class ... > class Pointer>
|
||||
void on_belongs_to(const char * /*id*/, Pointer<Type> &x, const utils::foreign_attributes &/*attr*/)
|
||||
{
|
||||
void on_belongs_to(const char * /*id*/, Pointer<Type> &x, const utils::foreign_attributes &/*attr*/) {
|
||||
values_.emplace_back(fk_value_extractor_.extract(*x));
|
||||
}
|
||||
template<class Type, template < class ... > class Pointer>
|
||||
|
|
|
|||
|
|
@ -38,11 +38,11 @@ TEST_CASE_METHOD( QueryFixture, "Insert and select basic datatypes", "[query][da
|
|||
int8_t cval = 'c';
|
||||
short sval = (std::numeric_limits<short>::min)();
|
||||
int ival = (std::numeric_limits<int>::min)();
|
||||
long long llval = (std::numeric_limits<long long>::max)();
|
||||
int64_t llval = (std::numeric_limits<long long>::max)();
|
||||
unsigned char ucval = (std::numeric_limits<unsigned char>::max)();
|
||||
unsigned short usval = (std::numeric_limits<unsigned short>::max)();
|
||||
unsigned int uival = (std::numeric_limits<unsigned int>::max)();
|
||||
unsigned long long ullval = (std::numeric_limits<unsigned long long>::max)();
|
||||
uint64_t ullval = (std::numeric_limits<unsigned long long>::max)();
|
||||
if (db.type() == "sqlite" || db.type() == "postgres") {
|
||||
ullval = (std::numeric_limits<long long>::max)();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,13 +214,13 @@ TEST_CASE_METHOD(QueryFixture, "Execute insert record statement", "[query][recor
|
|||
REQUIRE(i.size() == 3);
|
||||
REQUIRE(i.at(0).name() == "id");
|
||||
REQUIRE(i.at(0).is_integer());
|
||||
REQUIRE(i.at(0).template as<long long>() == 7);
|
||||
REQUIRE(i.at(0).template as<uint32_t>() == 7);
|
||||
REQUIRE(i.at(1).name() == "name");
|
||||
REQUIRE(i.at(1).is_varchar());
|
||||
REQUIRE(i.at(1).template as<std::string>() == "george");
|
||||
REQUIRE(i.at(2).name() == "age");
|
||||
REQUIRE(i.at(2).is_integer());
|
||||
REQUIRE(i.at(2).template as<int>() == 45);
|
||||
REQUIRE(i.at(2).template as<uint32_t>() == 45);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -317,13 +317,13 @@ TEST_CASE_METHOD(QueryFixture, "Execute update record statement", "[query][recor
|
|||
REQUIRE(i.size() == 3);
|
||||
REQUIRE(i.at(0).name() == "id");
|
||||
REQUIRE(i.at(0).is_integer());
|
||||
REQUIRE(i.at(0).as<long long>() == 7);
|
||||
REQUIRE(i.at(0).as<uint32_t>() == 7);
|
||||
REQUIRE(i.at(1).name() == "name");
|
||||
REQUIRE(i.at(1).is_varchar());
|
||||
REQUIRE(i.at(1).as<std::string>() == "jane");
|
||||
REQUIRE(i.at(2).name() == "age");
|
||||
REQUIRE(i.at(2).is_integer());
|
||||
REQUIRE(i.at(2).as<int>() == 35);
|
||||
REQUIRE(i.at(2).as<uint32_t>() == 35);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,13 +75,13 @@ TEST_CASE_METHOD(QueryFixture, "Execute select statement with where clause", "[q
|
|||
REQUIRE(i.size() == 4);
|
||||
REQUIRE(i.at(0).name() == "id");
|
||||
REQUIRE(i.at(0).is_integer());
|
||||
REQUIRE(i.at(0).as<long long>() == george.id);
|
||||
REQUIRE(i.at(0).as<uint32_t>() == george.id);
|
||||
REQUIRE(i.at(1).name() == "name");
|
||||
REQUIRE(i.at(1).is_varchar());
|
||||
REQUIRE(i.at(1).as<std::string>() == george.name);
|
||||
REQUIRE(i.at(2).name() == "age");
|
||||
REQUIRE(i.at(2).is_integer());
|
||||
REQUIRE(i.at(2).as<long long>() == george.age);
|
||||
REQUIRE(i.at(2).as<uint32_t>() == george.age);
|
||||
}
|
||||
|
||||
// fetch person as person
|
||||
|
|
@ -377,10 +377,10 @@ TEST_CASE_METHOD(QueryFixture, "Select statement with foreign key and for single
|
|||
auto f1 = select_result.release();
|
||||
REQUIRE(f1->id == expected_flight->id);
|
||||
REQUIRE(f1->pilot_name == expected_flight->pilot_name);
|
||||
REQUIRE(f1->airplane.get());
|
||||
REQUIRE(f1->airplane->id == 1);
|
||||
REQUIRE(f1->airplane->model == "A380");
|
||||
REQUIRE(f1->airplane->brand == "Airbus");
|
||||
REQUIRE(f1->plane.get());
|
||||
REQUIRE(f1->plane->id == 1);
|
||||
REQUIRE(f1->plane->model == "A380");
|
||||
REQUIRE(f1->plane->brand == "Airbus");
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(QueryFixture, "Select statement with many to many relationship", "[query][join][many_to_many]") {
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ TEST_CASE_METHOD(SessionFixture, "Session relation test", "[session][relation]")
|
|||
auto rf = *res;
|
||||
REQUIRE(rf->id == (*f)->id);
|
||||
REQUIRE(rf->pilot_name == (*f)->pilot_name);
|
||||
REQUIRE(rf->airplane);
|
||||
REQUIRE(rf->airplane->id == (*plane)->id);
|
||||
REQUIRE(rf->airplane->brand == (*plane)->brand);
|
||||
REQUIRE(rf->airplane->model == (*plane)->model);
|
||||
REQUIRE(rf->plane);
|
||||
REQUIRE(rf->plane->id == (*plane)->id);
|
||||
REQUIRE(rf->plane->brand == (*plane)->brand);
|
||||
REQUIRE(rf->plane->model == (*plane)->model);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SessionFixture, "Use session to find object with id", "[session][find]") {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,7 @@
|
|||
#ifndef QUERY_AIRPLANE_HPP
|
||||
#define QUERY_AIRPLANE_HPP
|
||||
|
||||
#include "category.hpp"
|
||||
#include "supplier.hpp"
|
||||
|
||||
#include "matador/utils/access.hpp"
|
||||
#include "matador/utils/cascade_type.hpp"
|
||||
#include "matador/utils/field_attributes.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
|
@ -14,7 +9,7 @@ namespace matador::test {
|
|||
|
||||
struct airplane {
|
||||
airplane() = default;
|
||||
airplane(unsigned int id, std::string b, std::string m)
|
||||
airplane(const unsigned int id, std::string b, std::string m)
|
||||
: id(id)
|
||||
, brand(std::move(b))
|
||||
, model(std::move(m)) {}
|
||||
|
|
|
|||
|
|
@ -14,14 +14,13 @@
|
|||
|
||||
namespace matador::test {
|
||||
|
||||
struct flight
|
||||
{
|
||||
struct flight {
|
||||
flight() = default;
|
||||
flight(const unsigned int id, const object::object_ptr<airplane> &plane, std::string name)
|
||||
: id(id), airplane(plane), pilot_name(std::move(name)) {}
|
||||
: id(id), plane(plane), pilot_name(std::move(name)) {}
|
||||
|
||||
unsigned int id{};
|
||||
object::object_ptr<airplane> airplane;
|
||||
object::object_ptr<airplane> plane;
|
||||
std::string pilot_name;
|
||||
|
||||
template<class Operator>
|
||||
|
|
@ -29,7 +28,7 @@ struct flight
|
|||
namespace field = matador::access;
|
||||
using namespace matador::utils;
|
||||
field::primary_key(op, "id", id);
|
||||
field::has_one(op, "airplane_id", airplane, {utils::cascade_type::ALL, utils::fetch_type::EAGER});
|
||||
field::has_one(op, "airplane_id", plane, {utils::cascade_type::ALL, utils::fetch_type::EAGER});
|
||||
field::attribute(op, "pilot_name", pilot_name, 255);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ struct types
|
|||
int8_t char_ = 'c';
|
||||
short short_ = -127;
|
||||
int int_ = -65000;
|
||||
long long long64_ = -1234567890;
|
||||
int64_t long64_ = -1234567890;
|
||||
unsigned char unsigned_char_ = 'H';
|
||||
unsigned short unsigned_short_ = 128;
|
||||
unsigned int unsigned_int_ = 65000;
|
||||
unsigned long long unsigned_long64_ = 1234567890;
|
||||
uint64_t unsigned_long64_ = 1234567890;
|
||||
float float_ = 3.1415f;
|
||||
double double_ = 1.1414;
|
||||
bool bool_ = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue