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/db_types.hpp"
29#include "ores.database/repository/repository_exception.hpp"
58void ensure_success(
const T& result, logging::logger_t& lg) {
62 BOOST_LOG_SEV(lg, error) << result.error().what();
63 BOOST_THROW_EXCEPTION(
65 result.error().what())));
83inline auto make_timestamp(
const std::string& s, logging::logger_t& lg) {
86 const auto r = db_timestamp::from_string(s);
88 BOOST_LOG_SEV(lg, error) <<
"Error converting timestamp: '" << s
89 <<
"'. Error: " << r.error().what();
90 BOOST_THROW_EXCEPTION(
92 std::format(
"Timestamp conversion error: {}", s)));
111template<
typename EntityType>
112std::string generate_create_table_sql(logging::logger_t& lg) {
114 using namespace sqlgen;
116 const auto query = create_table<EntityType> | if_not_exists;
117 const auto sql = postgres::to_sql(query);
119 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:40
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