From 414bbca0bc2bf20c4f424c2368997a46129b32cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 1 Dec 2017 14:59:22 +0100 Subject: Handle postgresql and sqlite3 libs properly Do not fail to compile when one of them is missing but the other one is not. Raise an error when trying to open a database with the missing library. see #3237 --- src/database/postgresql_engine.hpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'src/database/postgresql_engine.hpp') diff --git a/src/database/postgresql_engine.hpp b/src/database/postgresql_engine.hpp index e6444d4..fe4fb53 100644 --- a/src/database/postgresql_engine.hpp +++ b/src/database/postgresql_engine.hpp @@ -1,16 +1,20 @@ #pragma once -#include +#include +#include +#include +#include #include +#include -#include - -#include -#include #include #include +#ifdef PQ_FOUND + +#include + class PostgresqlEngine: public DatabaseEngine { public: @@ -29,3 +33,16 @@ class PostgresqlEngine: public DatabaseEngine private: PGconn* const conn; }; + +#else + +class PostgresqlEngine +{ +public: + static std::unique_ptr open(const std::string& string) + { + throw std::runtime_error("Cannot open postgresql database "s + string + ": biboumi is not compiled with libpq."); + } +}; + +#endif -- cgit v1.2.3