From 6f961aa57f850121ad95cc93c9d60490516e21cf Mon Sep 17 00:00:00 2001
From: matthias <matthias@emweb.be>
Date: Tue, 29 Oct 2024 14:41:42 +0100
Subject: [PATCH] Allow SqlConnection custom deleter

---
 src/Wt/Dbo/FixedSqlConnectionPool.C | 10 +++++-----
 src/Wt/Dbo/FixedSqlConnectionPool.h |  6 +++---
 src/Wt/Dbo/Session.C                |  8 ++++----
 src/Wt/Dbo/Session.h                | 11 +++++++----
 src/Wt/Dbo/SqlConnection.h          |  4 +++-
 src/Wt/Dbo/SqlConnectionPool.h      |  5 +++--
 src/Wt/Dbo/Transaction.h            |  4 +++-
 src/Wt/Dbo/backend/Firebird.C       |  4 ++--
 src/Wt/Dbo/backend/Firebird.h       |  2 +-
 src/Wt/Dbo/backend/MSSQLServer.C    |  4 ++--
 src/Wt/Dbo/backend/MSSQLServer.h    |  2 +-
 src/Wt/Dbo/backend/MySQL.C          |  4 ++--
 src/Wt/Dbo/backend/MySQL.h          |  2 +-
 src/Wt/Dbo/backend/Postgres.C       |  4 ++--
 src/Wt/Dbo/backend/Postgres.h       |  2 +-
 src/Wt/Dbo/backend/Sqlite3.C        |  4 ++--
 src/Wt/Dbo/backend/Sqlite3.h        |  2 +-
 test/dbo/DboFixture.h               | 14 ++++++++------
 test/dbo/DboTest4.C                 |  2 +-
 test/dbo/JsonTest.C                 |  2 +-
 test/dbo/SqliteTest.C               |  6 +++---
 21 files changed, 56 insertions(+), 46 deletions(-)

diff --git a/src/Wt/Dbo/FixedSqlConnectionPool.C b/src/Wt/Dbo/FixedSqlConnectionPool.C
index f3b950241..d903a600e 100644
--- a/src/Wt/Dbo/FixedSqlConnectionPool.C
+++ b/src/Wt/Dbo/FixedSqlConnectionPool.C
@@ -30,10 +30,10 @@ struct FixedSqlConnectionPool::Impl {
 #endif // WT_THREADED
 
   std::chrono::steady_clock::duration timeout{ std::chrono::steady_clock::duration::zero() };
-  std::vector<std::unique_ptr<SqlConnection>> freeList;
+  std::vector<std::unique_ptr<SqlConnection, SqlConnectionDeleter>> freeList;
 };
 
-FixedSqlConnectionPool::FixedSqlConnectionPool(std::unique_ptr<SqlConnection> connection,
+FixedSqlConnectionPool::FixedSqlConnectionPool(std::unique_ptr<SqlConnection, SqlConnectionDeleter> connection,
                                                int size)
   : impl_(new Impl)
 {
@@ -59,7 +59,7 @@ std::chrono::steady_clock::duration FixedSqlConnectionPool::timeout() const
   return impl_->timeout;
 }
 
-std::unique_ptr<SqlConnection> FixedSqlConnectionPool::getConnection()
+std::unique_ptr<SqlConnection, SqlConnectionDeleter> FixedSqlConnectionPool::getConnection()
 {
 #ifdef WT_THREADED
   std::unique_lock<std::mutex> lock(impl_->mutex);
@@ -79,7 +79,7 @@ std::unique_ptr<SqlConnection> FixedSqlConnectionPool::getConnection()
                     "no connection available but single-threaded build?");
 #endif // WT_THREADED
 
-  std::unique_ptr<SqlConnection> result = std::move(impl_->freeList.back());
+  std::unique_ptr<SqlConnection, SqlConnectionDeleter> result = std::move(impl_->freeList.back());
   impl_->freeList.pop_back();
 
   return result;
@@ -90,7 +90,7 @@ void FixedSqlConnectionPool::handleTimeout()
   throw Exception("FixedSqlConnectionPool::getConnection(): timeout");
 }
 
-void FixedSqlConnectionPool::returnConnection(std::unique_ptr<SqlConnection> connection)
+void FixedSqlConnectionPool::returnConnection(std::unique_ptr<SqlConnection, SqlConnectionDeleter> connection)
 {
 #ifdef WT_THREADED
   std::unique_lock<std::mutex> lock(impl_->mutex);
diff --git a/src/Wt/Dbo/FixedSqlConnectionPool.h b/src/Wt/Dbo/FixedSqlConnectionPool.h
index 5fb333b4a..b847fe99a 100644
--- a/src/Wt/Dbo/FixedSqlConnectionPool.h
+++ b/src/Wt/Dbo/FixedSqlConnectionPool.h
@@ -38,7 +38,7 @@ public:
    * The pool is initialized with the provided \p connection, which is
    * cloned (\p size - 1) times.
    */
-  FixedSqlConnectionPool(std::unique_ptr<SqlConnection> connection, int size);
+  FixedSqlConnectionPool(std::unique_ptr<SqlConnection, SqlConnectionDeleter> connection, int size);
 
   /*! \brief Set a timeout to get a connection.
    *
@@ -59,8 +59,8 @@ public:
   std::chrono::steady_clock::duration timeout() const;
 
   virtual ~FixedSqlConnectionPool();
-  virtual std::unique_ptr<SqlConnection> getConnection() override;
-  virtual void returnConnection(std::unique_ptr<SqlConnection>) override;
+  virtual std::unique_ptr<SqlConnection, SqlConnectionDeleter> getConnection() override;
+  virtual void returnConnection(std::unique_ptr<SqlConnection, SqlConnectionDeleter>) override;
   virtual void prepareForDropTables() const override;
 
 protected:
diff --git a/src/Wt/Dbo/Session.C b/src/Wt/Dbo/Session.C
index 664a2460b..13fac313e 100644
--- a/src/Wt/Dbo/Session.C
+++ b/src/Wt/Dbo/Session.C
@@ -169,7 +169,7 @@ Session::~Session()
     delete i->second;
 }
 
-void Session::setConnection(std::unique_ptr<SqlConnection> connection)
+void Session::setConnection(std::unique_ptr<SqlConnection, SqlConnectionDeleter> connection)
 {
   connection_ = std::move(connection);
 }
@@ -190,7 +190,7 @@ SqlConnection *Session::connection(bool openTransaction)
   return transaction_->connection_.get();
 }
 
-std::unique_ptr<SqlConnection> Session::useConnection()
+std::unique_ptr<SqlConnection, SqlConnectionDeleter> Session::useConnection()
 {
   if (connectionPool_)
     return connectionPool_->getConnection();
@@ -198,7 +198,7 @@ std::unique_ptr<SqlConnection> Session::useConnection()
     return std::move(connection_);
 }
 
-void Session::returnConnection(std::unique_ptr<SqlConnection> connection)
+void Session::returnConnection(std::unique_ptr<SqlConnection, SqlConnectionDeleter> connection)
 {
   if (connectionPool_)
     connectionPool_->returnConnection(std::move(connection));
@@ -285,7 +285,7 @@ void Session::prepareStatements(Impl::MappingInfo *mapping)
 
   sql << ")";
 
-  std::unique_ptr<SqlConnection> connPtr;
+  std::unique_ptr<SqlConnection, SqlConnectionDeleter> connPtr;
   SqlConnection *conn;
   if (transaction_)
     conn = transaction_->connection_.get();
diff --git a/src/Wt/Dbo/Session.h b/src/Wt/Dbo/Session.h
index d0d451dbd..c759bc578 100644
--- a/src/Wt/Dbo/Session.h
+++ b/src/Wt/Dbo/Session.h
@@ -18,6 +18,9 @@
 #include <Wt/Dbo/Transaction.h>
 #include <Wt/Dbo/SqlConnection.h>
 
+#include <Wt/Dbo/SqlConnectionDeleter.h>
+
+
 namespace Wt {
   namespace Dbo {
     namespace Impl {
@@ -149,7 +152,7 @@ public:
    *
    * \sa setConnectionPool()
    */
-  void setConnection(std::unique_ptr<SqlConnection> connection);
+  void setConnection(std::unique_ptr<SqlConnection, SqlConnectionDeleter> connection);
 
   /*! \brief Sets a connection pool.
    *
@@ -562,7 +565,7 @@ private:
 
   Impl::MetaDboBaseSet *dirtyObjects_;
   std::vector<MetaDboBase*> objectsToAdd_;
-  std::unique_ptr<SqlConnection> connection_;
+  std::unique_ptr<SqlConnection, SqlConnectionDeleter> connection_;
   SqlConnectionPool *connectionPool_;
   Transaction::Impl *transaction_;
   FlushMode flushMode_;
@@ -649,8 +652,8 @@ private:
   template <class C> std::string manyToManyJoinId(const std::string& joinName,
                                                   const std::string& notId);
 
-  std::unique_ptr<SqlConnection> useConnection();
-  void returnConnection(std::unique_ptr<SqlConnection> connection);
+  std::unique_ptr<SqlConnection, SqlConnectionDeleter> useConnection();
+  void returnConnection(std::unique_ptr<SqlConnection, SqlConnectionDeleter> connection);
   SqlConnection *connection(bool openTransaction);
 
   MetaDboBase *createDbo(Impl::MappingInfo *mapping);
diff --git a/src/Wt/Dbo/SqlConnection.h b/src/Wt/Dbo/SqlConnection.h
index 3b885beff..a7416a9ba 100644
--- a/src/Wt/Dbo/SqlConnection.h
+++ b/src/Wt/Dbo/SqlConnection.h
@@ -13,6 +13,8 @@
 #include <vector>
 #include <Wt/Dbo/WDboDllDefs.h>
 
+#include <Wt/Dbo/SqlConnectionDeleter.h>
+
 namespace Wt {
   namespace Dbo {
 
@@ -67,7 +69,7 @@ public:
    * object. This is used by connection pool implementations to create
    * its connections.
    */
-  virtual std::unique_ptr<SqlConnection> clone() const = 0;
+  virtual std::unique_ptr<SqlConnection, SqlConnectionDeleter> clone() const = 0;
 
   /*! \brief Executes an SQL statement.
    *
diff --git a/src/Wt/Dbo/SqlConnectionPool.h b/src/Wt/Dbo/SqlConnectionPool.h
index dd29fed41..667d61f47 100644
--- a/src/Wt/Dbo/SqlConnectionPool.h
+++ b/src/Wt/Dbo/SqlConnectionPool.h
@@ -8,6 +8,7 @@
 #define WT_DBO_SQL_CONNECTION_POOL_H_
 
 #include <Wt/Dbo/WDboDllDefs.h>
+#include <Wt/Dbo/SqlConnectionDeleter.h>
 
 #include <memory>
 #include <vector>
@@ -44,14 +45,14 @@ public:
    * This method is called by a Session when a new transaction is
    * started.
    */
-  virtual std::unique_ptr<SqlConnection> getConnection() = 0;
+  virtual std::unique_ptr<SqlConnection, SqlConnectionDeleter> getConnection() = 0;
 
   /*! \brief Returns a connection to the pool.
    *
    * This returns a connection to the pool. This method is called by a
    * Session after a transaction has been finished.
    */
-  virtual void returnConnection(std::unique_ptr<SqlConnection>) = 0;
+  virtual void returnConnection(std::unique_ptr<SqlConnection, SqlConnectionDeleter>) = 0;
 
   /*! \brief Prepares all connections in the pool for dropping the tables.
    */
diff --git a/src/Wt/Dbo/Transaction.h b/src/Wt/Dbo/Transaction.h
index c3267097a..f628fea10 100644
--- a/src/Wt/Dbo/Transaction.h
+++ b/src/Wt/Dbo/Transaction.h
@@ -11,6 +11,8 @@
 #include <vector>
 #include <Wt/Dbo/WDboDllDefs.h>
 
+#include <Wt/Dbo/SqlConnectionDeleter.h>
+
 namespace Wt {
   namespace Dbo {
 
@@ -146,7 +148,7 @@ private:
     int transactionCount_;
     std::vector<ptr_base *> objects_;
 
-    std::unique_ptr<SqlConnection> connection_;
+    std::unique_ptr<SqlConnection, SqlConnectionDeleter> connection_;
 
     void open();
     void commit();
diff --git a/src/Wt/Dbo/backend/Firebird.C b/src/Wt/Dbo/backend/Firebird.C
index 17d0663e2..dddc07427 100644
--- a/src/Wt/Dbo/backend/Firebird.C
+++ b/src/Wt/Dbo/backend/Firebird.C
@@ -537,9 +537,9 @@ LOGGER("Dbo.backend.Firebird");
         delete impl_;
       }
 
-      std::unique_ptr<SqlConnection> Firebird::clone() const
+      std::unique_ptr<SqlConnection, SqlConnectionDeleter> Firebird::clone() const
       {
-        return std::unique_ptr<SqlConnection>(new Firebird(*this));
+        return std::unique_ptr<SqlConnection, SqlConnectionDeleter>(new Firebird(*this));
       }
 
       std::unique_ptr<SqlStatement> Firebird::prepareStatement(const std::string& sql)
diff --git a/src/Wt/Dbo/backend/Firebird.h b/src/Wt/Dbo/backend/Firebird.h
index 0ed4b333a..5d3e67fe7 100644
--- a/src/Wt/Dbo/backend/Firebird.h
+++ b/src/Wt/Dbo/backend/Firebird.h
@@ -91,7 +91,7 @@ namespace Wt {
                      const std::string& CharSet = std::string(),
                      const std::string& CreateParams = std::string());
 
-        virtual std::unique_ptr<SqlConnection> clone() const override;
+        virtual std::unique_ptr<SqlConnection, SqlConnectionDeleter> clone() const override;
 
         /*! \brief Returns the underlying connection handle.
          */
diff --git a/src/Wt/Dbo/backend/MSSQLServer.C b/src/Wt/Dbo/backend/MSSQLServer.C
index 65b2c848f..b93e9747e 100644
--- a/src/Wt/Dbo/backend/MSSQLServer.C
+++ b/src/Wt/Dbo/backend/MSSQLServer.C
@@ -907,9 +907,9 @@ MSSQLServer::~MSSQLServer()
   delete impl_;
 }
 
-std::unique_ptr<SqlConnection> MSSQLServer::clone() const
+std::unique_ptr<SqlConnection, SqlConnectionDeleter> MSSQLServer::clone() const
 {
-  return std::unique_ptr<SqlConnection>(new MSSQLServer(*this));
+  return std::unique_ptr<SqlConnection, SqlConnectionDeleter>(new MSSQLServer(*this));
 }
 
 bool MSSQLServer::connect(const std::string &connectionString)
diff --git a/src/Wt/Dbo/backend/MSSQLServer.h b/src/Wt/Dbo/backend/MSSQLServer.h
index 114bd984f..e22c1a9ec 100644
--- a/src/Wt/Dbo/backend/MSSQLServer.h
+++ b/src/Wt/Dbo/backend/MSSQLServer.h
@@ -55,7 +55,7 @@ public:
    */
   virtual ~MSSQLServer();
 
-  virtual std::unique_ptr<Wt::Dbo::SqlConnection> clone() const override;
+  virtual std::unique_ptr<Wt::Dbo::SqlConnection, SqlConnectionDeleter> clone() const override;
 
   /*! \brief Tries to connect.
    *
diff --git a/src/Wt/Dbo/backend/MySQL.C b/src/Wt/Dbo/backend/MySQL.C
index 03b885c9a..4dc3bb9fc 100644
--- a/src/Wt/Dbo/backend/MySQL.C
+++ b/src/Wt/Dbo/backend/MySQL.C
@@ -953,9 +953,9 @@ MySQL::~MySQL()
   }
 }
 
-std::unique_ptr<SqlConnection> MySQL::clone() const
+std::unique_ptr<SqlConnection, SqlConnectionDeleter> MySQL::clone() const
 {
-  return std::unique_ptr<SqlConnection>(new MySQL(*this));
+  return std::unique_ptr<SqlConnection, SqlConnectionDeleter>(new MySQL(*this));
 }
 
 bool MySQL::connect(const std::string &db,  const std::string &dbuser,
diff --git a/src/Wt/Dbo/backend/MySQL.h b/src/Wt/Dbo/backend/MySQL.h
index d3a98c355..7f155f49b 100644
--- a/src/Wt/Dbo/backend/MySQL.h
+++ b/src/Wt/Dbo/backend/MySQL.h
@@ -71,7 +71,7 @@ public:
 
   /*! \brief Returns a copy of the connection.
    */
-  virtual std::unique_ptr<SqlConnection> clone() const override;
+  virtual std::unique_ptr<SqlConnection, SqlConnectionDeleter> clone() const override;
 
   /*! \brief Tries to connect.
    *
diff --git a/src/Wt/Dbo/backend/Postgres.C b/src/Wt/Dbo/backend/Postgres.C
index ded1e6b73..6b80578e6 100644
--- a/src/Wt/Dbo/backend/Postgres.C
+++ b/src/Wt/Dbo/backend/Postgres.C
@@ -893,9 +893,9 @@ void Postgres::setTimeout(std::chrono::microseconds timeout)
   timeout_ = timeout;
 }
 
-std::unique_ptr<SqlConnection> Postgres::clone() const
+std::unique_ptr<SqlConnection, SqlConnectionDeleter> Postgres::clone() const
 {
-  return std::unique_ptr<SqlConnection>(new Postgres(*this));
+  return std::unique_ptr<SqlConnection, SqlConnectionDeleter>(new Postgres(*this));
 }
 
 bool Postgres::connect(const std::string& db)
diff --git a/src/Wt/Dbo/backend/Postgres.h b/src/Wt/Dbo/backend/Postgres.h
index 5d6609a25..a343586b9 100644
--- a/src/Wt/Dbo/backend/Postgres.h
+++ b/src/Wt/Dbo/backend/Postgres.h
@@ -65,7 +65,7 @@ public:
    */
   ~Postgres();
 
-  virtual std::unique_ptr<SqlConnection> clone() const override;
+  virtual std::unique_ptr<SqlConnection, SqlConnectionDeleter> clone() const override;
 
   /*! \brief Tries to connect.
    *
diff --git a/src/Wt/Dbo/backend/Sqlite3.C b/src/Wt/Dbo/backend/Sqlite3.C
index 958544605..2e2fa731c 100644
--- a/src/Wt/Dbo/backend/Sqlite3.C
+++ b/src/Wt/Dbo/backend/Sqlite3.C
@@ -551,9 +551,9 @@ Sqlite3::~Sqlite3()
   sqlite3_close(db_);
 }
 
-std::unique_ptr<SqlConnection> Sqlite3::clone() const
+std::unique_ptr<SqlConnection, SqlConnectionDeleter> Sqlite3::clone() const
 {
-  return std::unique_ptr<SqlConnection>(new Sqlite3(*this));
+  return std::unique_ptr<SqlConnection, SqlConnectionDeleter>(new Sqlite3(*this));
 }
 
 std::unique_ptr<SqlStatement> Sqlite3::prepareStatement(const std::string& sql)
diff --git a/src/Wt/Dbo/backend/Sqlite3.h b/src/Wt/Dbo/backend/Sqlite3.h
index aad9f387c..69f9600d1 100644
--- a/src/Wt/Dbo/backend/Sqlite3.h
+++ b/src/Wt/Dbo/backend/Sqlite3.h
@@ -90,7 +90,7 @@ public:
    */
   ~Sqlite3();
 
-  virtual std::unique_ptr<SqlConnection> clone() const override;
+  virtual std::unique_ptr<SqlConnection, SqlConnectionDeleter> clone() const override;
 
   /*! \brief Returns the underlying connection.
    */
diff --git a/test/dbo/DboFixture.h b/test/dbo/DboFixture.h
index 68337ae9e..ec6b4be23 100644
--- a/test/dbo/DboFixture.h
+++ b/test/dbo/DboFixture.h
@@ -14,6 +14,8 @@
 #include <Wt/Dbo/ptr_tuple.h>
 #include <Wt/Dbo/QueryModel.h>
 
+#include <Wt/Dbo/SqlConnectionDeleter.h>
+
 namespace dbo = Wt::Dbo;
 
 #if defined(SQLITE3)
@@ -37,7 +39,7 @@ struct DboFixtureBase
   DboFixtureBase(bool showQueries = true)
   {
     static bool logged = false;
-    std::unique_ptr<dbo::SqlConnection> connection;
+    std::unique_ptr<dbo::SqlConnection, SqlConnectionDeleter> connection;
 
 #ifdef SQLITE3
     if (!logged) {
@@ -49,7 +51,7 @@ struct DboFixtureBase
     sqlite3->setDateTimeStorage
       (dbo::SqlDateTimeType::Date,
        dbo::backend::DateTimeStorage::JulianDaysAsReal);
-    connection = std::unique_ptr<dbo::SqlConnection>(sqlite3);
+    connection = std::unique_ptr<dbo::SqlConnection, SqlConnectionDeleter>(sqlite3);
 #endif // SQLITE3
 
 #ifdef POSTGRES
@@ -58,7 +60,7 @@ struct DboFixtureBase
       logged = true;
     }
 
-    connection = std::unique_ptr<dbo::SqlConnection>(new dbo::backend::Postgres
+    connection = std::unique_ptr<dbo::SqlConnection, SqlConnectionDeleter>(new dbo::backend::Postgres
         ("host=db user=postgres_test password=postgres_test port=5432 dbname=wt_test"));
 
 #endif // POSTGRES");
@@ -69,7 +71,7 @@ struct DboFixtureBase
       logged = true;
     }
 
-    std::unique_ptr<dbo::backend::MySQL> mysql(
+    std::unique_ptr<dbo::backend::MySQL, SqlConnectionDeleter> mysql(
         new dbo::backend::MySQL("wt_test_db", "test_user", "test_pw", "db", 3306));
     mysql->setFractionalSecondsPart(3);
     connection = std::move(mysql);
@@ -92,7 +94,7 @@ struct DboFixtureBase
       logged = true;
     }
 
-    connection = std::unique_ptr<dbo::SqlConnection>(
+    connection = std::unique_ptr<dbo::SqlConnection, SqlConnectionDeleter>(
           new dbo::backend::Firebird ("db",
                                       file,
                                       "test_user", "test_pwd",
@@ -105,7 +107,7 @@ struct DboFixtureBase
       logged = true;
     }
 
-    connection = std::unique_ptr<dbo::SqlConnection>(
+    connection = std::unique_ptr<dbo::SqlConnection, SqlConnectionDeleter>(
       new dbo::backend::MSSQLServer(
         "Driver={ODBC Driver 17 for SQL Server};"
         "Server=db;"
diff --git a/test/dbo/DboTest4.C b/test/dbo/DboTest4.C
index f07974f99..32b5f26b1 100644
--- a/test/dbo/DboTest4.C
+++ b/test/dbo/DboTest4.C
@@ -203,7 +203,7 @@ BOOST_AUTO_TEST_CASE( dbo4_test1 )
   }
 
   // None of the following should throw!
-  std::unique_ptr<Wt::Dbo::SqlConnection> connection = f.connectionPool_->getConnection();
+  std::unique_ptr<Wt::Dbo::SqlConnection, SqlConnectionDeleter> connection = f.connectionPool_->getConnection();
   connection->startTransaction();
   connection->executeSql("SELECT \"side1_name\",\"side2_name\" FROM \"friends1\"");
   connection->executeSql("SELECT \"side1\",\"side2\" FROM \"friends2\"");
diff --git a/test/dbo/JsonTest.C b/test/dbo/JsonTest.C
index 90a67c97c..49891c8ec 100644
--- a/test/dbo/JsonTest.C
+++ b/test/dbo/JsonTest.C
@@ -222,7 +222,7 @@ struct JsonDboFixture
       logged = true;
     }
 
-    std::unique_ptr<dbo::SqlConnection> sqlite3(new dbo::backend::Sqlite3(":memory:"));
+    std::unique_ptr<dbo::SqlConnection, SqlConnectionDeleter> sqlite3(new dbo::backend::Sqlite3(":memory:"));
 
     session_ = std::unique_ptr<dbo::Session>(new dbo::Session());
     session_->setConnection(std::move(sqlite3));
diff --git a/test/dbo/SqliteTest.C b/test/dbo/SqliteTest.C
index ad0601154..4636cf937 100644
--- a/test/dbo/SqliteTest.C
+++ b/test/dbo/SqliteTest.C
@@ -41,7 +41,7 @@ namespace {
 
 BOOST_AUTO_TEST_CASE( sqlite3_test_iso_timestamp )
 {
-  auto sqlite3 = std::make_unique<dbo::backend::Sqlite3>(":memory:");
+  auto sqlite3 = std::unique_ptr<dbo::backend::Sqlite3, SqlConnectionDeleter>(new dbo::backend::Sqlite3(":memory:"));
   sqlite3->setProperty("show-queries", "true");
   sqlite3->setDateTimeStorage(dbo::SqlDateTimeType::Date, dbo::backend::DateTimeStorage::ISO8601AsText);
   sqlite3->setDateTimeStorage(dbo::SqlDateTimeType::DateTime, dbo::backend::DateTimeStorage::ISO8601AsText);
@@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE( sqlite3_test_iso_timestamp )
 
 BOOST_AUTO_TEST_CASE( sqlite3_test_julian_day )
 {
-  auto sqlite3 = std::make_unique<dbo::backend::Sqlite3>(":memory:");
+  auto sqlite3 = std::unique_ptr<dbo::backend::Sqlite3, SqlConnectionDeleter>(new dbo::backend::Sqlite3(":memory:"));
   sqlite3->setProperty("show-queries", "true");
   sqlite3->setDateTimeStorage(dbo::SqlDateTimeType::Date, dbo::backend::DateTimeStorage::JulianDaysAsReal);
   sqlite3->setDateTimeStorage(dbo::SqlDateTimeType::DateTime, dbo::backend::DateTimeStorage::JulianDaysAsReal);
@@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE( sqlite3_test_julian_day )
 
 BOOST_AUTO_TEST_CASE( sqlite3_test_unix_timestamp )
 {
-  auto sqlite3 = std::make_unique<dbo::backend::Sqlite3>(":memory:");
+  auto sqlite3 = std::unique_ptr<dbo::backend::Sqlite3, SqlConnectionDeleter>(new dbo::backend::Sqlite3(":memory:"));
   sqlite3->setProperty("show-queries", "true");
   sqlite3->setDateTimeStorage(dbo::SqlDateTimeType::Date, dbo::backend::DateTimeStorage::UnixTimeAsInteger);
   sqlite3->setDateTimeStorage(dbo::SqlDateTimeType::DateTime, dbo::backend::DateTimeStorage::UnixTimeAsInteger);
-- 
2.43.0

