diff --git a/include/sqlpp11/connection_pool.h b/include/sqlpp11/connection_pool.h index 629443ea..007ccfd1 100644 --- a/include/sqlpp11/connection_pool.h +++ b/include/sqlpp11/connection_pool.h @@ -44,7 +44,7 @@ namespace sqlpp struct automatic { template - bool validate(Connection* connection) + void validate(Connection* connection) { if (!connection->is_valid()) { @@ -52,7 +52,7 @@ namespace sqlpp { connection->reconnect(); } - catch (const sqlpp::exception& e) + catch (const sqlpp::exception&) { throw sqlpp::exception("Failed to reconnect to database."); } @@ -191,7 +191,7 @@ namespace sqlpp break; } } - catch (const sqlpp::exception& e) + catch (const sqlpp::exception&) { throw sqlpp::exception("Failed to retrieve a valid connection."); } @@ -201,7 +201,7 @@ namespace sqlpp { return pool_connection(std::move(std::make_unique(config)), this); } - catch (const sqlpp::exception& e) + catch (const sqlpp::exception&) { throw sqlpp::exception("Failed to spawn a new connection."); } diff --git a/include/sqlpp11/pool_connection.h b/include/sqlpp11/pool_connection.h index a8e1b222..0594a75a 100644 --- a/include/sqlpp11/pool_connection.h +++ b/include/sqlpp11/pool_connection.h @@ -45,7 +45,10 @@ namespace sqlpp ~pool_connection() { - origin->free_connection(_impl); + if (_impl.get()) + { + origin->free_connection(_impl); + } } template @@ -81,7 +84,10 @@ namespace sqlpp pool_connection(pool_connection&& other) : _impl(std::move(other._impl)), origin(other.origin) {} pool_connection& operator=(const pool_connection&) = delete; - pool_connection& operator=(pool_connection&&) = delete; + pool_connection& operator=(pool_connection&& other) + { + _impl(std::move(other._impl)), origin(other.origin); + } }; }