20#ifndef ORES_DATABASE_REPOSITORY_HELPERS_HPP
21#define ORES_DATABASE_REPOSITORY_HELPERS_HPP
25#include <boost/exception/diagnostic_information.hpp>
26#include <sqlgen/postgres.hpp>
27#include "ores.logging/make_logger.hpp"
28#include "ores.database/repository/repository_exception.hpp"
57void ensure_success(
const T& result, logging::logger_t& lg) {
61 BOOST_LOG_SEV(lg, error) << result.error().what();
62 BOOST_THROW_EXCEPTION(
64 result.error().what())));
82inline auto make_timestamp(
const std::string& s, logging::logger_t& lg) {
85 const auto r = sqlgen::Timestamp<
"%Y-%m-%d %H:%M:%S">::from_string(s);
87 BOOST_LOG_SEV(lg, error) <<
"Error converting timestamp: '" << s
88 <<
"'. Error: " << r.error().what();
89 BOOST_THROW_EXCEPTION(
91 std::format(
"Timestamp conversion error: {}", s)));
110template<
typename EntityType>
111std::string generate_create_table_sql(logging::logger_t& lg) {
113 using namespace sqlgen;
115 const auto query = create_table<EntityType> | if_not_exists;
116 const auto sql = postgres::to_sql(query);
118 BOOST_LOG_SEV(lg, debug) << sql;
Repository infrastructure and bitemporal operations.
Definition bitemporal_operations.hpp:31
constexpr const char * MAX_TIMESTAMP
Maximum timestamp used for bitemporal records (represents "infinity").
Definition helpers.hpp:39
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
A fatal error has occurred whilst reading or writing to the repository.
Definition repository_exception.hpp:33