From 2efb106fc388462fc04c248ff8d0459d0ae8d074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20K=C3=BChl?= Date: Thu, 13 Feb 2025 07:06:10 +0100 Subject: [PATCH] fixed linux compile --- backends/postgres/test/CMakeLists.txt | 6 +++--- include/matador/query/value_extractor.hpp | 6 ++---- test/backends/QueryBasicTest.cpp | 4 ++-- test/backends/QueryRecordTest.cpp | 8 ++++---- test/backends/QueryTest.cpp | 12 ++++++------ test/backends/SessionTest.cpp | 8 ++++---- test/models/airplane.hpp | 7 +------ test/models/flight.hpp | 9 ++++----- test/models/types.hpp | 4 ++-- 9 files changed, 28 insertions(+), 36 deletions(-) diff --git a/backends/postgres/test/CMakeLists.txt b/backends/postgres/test/CMakeLists.txt index 88cb8c7..2cc6ac5 100644 --- a/backends/postgres/test/CMakeLists.txt +++ b/backends/postgres/test/CMakeLists.txt @@ -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}) diff --git a/include/matador/query/value_extractor.hpp b/include/matador/query/value_extractor.hpp index 46567a6..059ff3f 100644 --- a/include/matador/query/value_extractor.hpp +++ b/include/matador/query/value_extractor.hpp @@ -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::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 Pointer> - void on_belongs_to(const char * /*id*/, Pointer &x, const utils::foreign_attributes &/*attr*/) - { + void on_belongs_to(const char * /*id*/, Pointer &x, const utils::foreign_attributes &/*attr*/) { values_.emplace_back(fk_value_extractor_.extract(*x)); } template class Pointer> diff --git a/test/backends/QueryBasicTest.cpp b/test/backends/QueryBasicTest.cpp index 681ca05..1be2b8d 100644 --- a/test/backends/QueryBasicTest.cpp +++ b/test/backends/QueryBasicTest.cpp @@ -38,11 +38,11 @@ TEST_CASE_METHOD( QueryFixture, "Insert and select basic datatypes", "[query][da int8_t cval = 'c'; short sval = (std::numeric_limits::min)(); int ival = (std::numeric_limits::min)(); - long long llval = (std::numeric_limits::max)(); + int64_t llval = (std::numeric_limits::max)(); unsigned char ucval = (std::numeric_limits::max)(); unsigned short usval = (std::numeric_limits::max)(); unsigned int uival = (std::numeric_limits::max)(); - unsigned long long ullval = (std::numeric_limits::max)(); + uint64_t ullval = (std::numeric_limits::max)(); if (db.type() == "sqlite" || db.type() == "postgres") { ullval = (std::numeric_limits::max)(); } diff --git a/test/backends/QueryRecordTest.cpp b/test/backends/QueryRecordTest.cpp index bbf7619..c2f5b80 100644 --- a/test/backends/QueryRecordTest.cpp +++ b/test/backends/QueryRecordTest.cpp @@ -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() == 7); + REQUIRE(i.at(0).template as() == 7); REQUIRE(i.at(1).name() == "name"); REQUIRE(i.at(1).is_varchar()); REQUIRE(i.at(1).template as() == "george"); REQUIRE(i.at(2).name() == "age"); REQUIRE(i.at(2).is_integer()); - REQUIRE(i.at(2).template as() == 45); + REQUIRE(i.at(2).template as() == 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() == 7); + REQUIRE(i.at(0).as() == 7); REQUIRE(i.at(1).name() == "name"); REQUIRE(i.at(1).is_varchar()); REQUIRE(i.at(1).as() == "jane"); REQUIRE(i.at(2).name() == "age"); REQUIRE(i.at(2).is_integer()); - REQUIRE(i.at(2).as() == 35); + REQUIRE(i.at(2).as() == 35); } } diff --git a/test/backends/QueryTest.cpp b/test/backends/QueryTest.cpp index bdb8123..70e5548 100644 --- a/test/backends/QueryTest.cpp +++ b/test/backends/QueryTest.cpp @@ -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() == george.id); + REQUIRE(i.at(0).as() == george.id); REQUIRE(i.at(1).name() == "name"); REQUIRE(i.at(1).is_varchar()); REQUIRE(i.at(1).as() == george.name); REQUIRE(i.at(2).name() == "age"); REQUIRE(i.at(2).is_integer()); - REQUIRE(i.at(2).as() == george.age); + REQUIRE(i.at(2).as() == 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]") { diff --git a/test/backends/SessionTest.cpp b/test/backends/SessionTest.cpp index 0194c7e..373af8e 100644 --- a/test/backends/SessionTest.cpp +++ b/test/backends/SessionTest.cpp @@ -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]") { diff --git a/test/models/airplane.hpp b/test/models/airplane.hpp index 3ee5b57..84d7ccd 100644 --- a/test/models/airplane.hpp +++ b/test/models/airplane.hpp @@ -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 @@ -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)) {} diff --git a/test/models/flight.hpp b/test/models/flight.hpp index b01da0c..87f62b9 100644 --- a/test/models/flight.hpp +++ b/test/models/flight.hpp @@ -14,14 +14,13 @@ namespace matador::test { -struct flight -{ +struct flight { flight() = default; flight(const unsigned int id, const object::object_ptr &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; + object::object_ptr plane; std::string pilot_name; template @@ -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); } }; diff --git a/test/models/types.hpp b/test/models/types.hpp index e8e2b0a..2a07339 100644 --- a/test/models/types.hpp +++ b/test/models/types.hpp @@ -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;