added timestamp code, support columns for group by and order by and tested load has-many eager code
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "matador/utils/convert.hpp"
|
||||
#include "matador/utils/value.hpp"
|
||||
#include "matador/utils/string.hpp"
|
||||
|
||||
namespace matador::backends::postgres {
|
||||
postgres_result_reader::postgres_result_reader(PGresult *result)
|
||||
@@ -104,18 +105,25 @@ void postgres_result_reader::read_value(const char * /*id*/, const size_t index,
|
||||
|
||||
void postgres_result_reader::read_value(const char * /*id*/, const size_t index, utils::date_type_t &value) {
|
||||
if (const auto val = column(index); strlen(val) > 0) {
|
||||
// value = time::parse(val, "%Y-%m-%d %T.%f");
|
||||
if (const auto res = utils::to<utils::date_type_t>(std::string(val)); res.is_ok()) {
|
||||
value = res.value();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void postgres_result_reader::read_value(const char * /*id*/, const size_t index, utils::time_type_t &value) {
|
||||
if (const auto val = column(index); strlen(val) > 0) {
|
||||
// value.set(val, matador::utils::date_format::ISO8601);
|
||||
if (const auto res = utils::to<utils::time_type_t>(std::string(val)); res.is_ok()) {
|
||||
value = res.value();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void postgres_result_reader::read_value(const char * /*id*/, size_t index, utils::timestamp_type_t &value) {
|
||||
void postgres_result_reader::read_value(const char * /*id*/, const size_t index, utils::timestamp_type_t &value) {
|
||||
if (const auto val = column(index); strlen(val) > 0) {
|
||||
if (const auto res = utils::to<utils::timestamp_type_t>(std::string(val)); res.is_ok()) {
|
||||
value = res.value();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ set(TEST_SOURCES
|
||||
../../../test/backends/StatementCacheTest.cpp
|
||||
../../../test/backends/StatementTest.cpp
|
||||
../../../test/backends/TypeTraitsTest.cpp
|
||||
../../../test/utils/record_printer.hpp
|
||||
../../../test/utils/record_printer.cpp
|
||||
)
|
||||
|
||||
set(LIBRARY_TEST_TARGET PostgresTests)
|
||||
|
||||
Reference in New Issue
Block a user