From 5ea972e5b32c3447c2c838b0ce079dbd280b6df0 Mon Sep 17 00:00:00 2001 From: antao Date: Mon, 7 Jan 2019 16:26:58 +0800 Subject: [PATCH] Modify the signature of the createDbClient() method --- lib/inc/drogon/HttpAppFramework.h | 4 ++-- lib/src/ConfigLoader.cc | 2 +- lib/src/HttpAppFrameworkImpl.cc | 4 ++-- lib/src/HttpAppFrameworkImpl.h | 4 ++-- orm_lib/src/sqlite3_impl/test/test1.cc | 7 +++++-- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/inc/drogon/HttpAppFramework.h b/lib/inc/drogon/HttpAppFramework.h index 068f6209..ce106704 100755 --- a/lib/inc/drogon/HttpAppFramework.h +++ b/lib/inc/drogon/HttpAppFramework.h @@ -189,8 +189,8 @@ class HttpAppFramework : public trantor::NonCopyable const std::string &userName, const std::string &password, const size_t connectionNum = 1, - const std::string &name = "default", - const std::string &filename = "") = 0; + const std::string &filename = "", + const std::string &name = "default") = 0; #endif private: diff --git a/lib/src/ConfigLoader.cc b/lib/src/ConfigLoader.cc index b54d5b2c..07b85622 100644 --- a/lib/src/ConfigLoader.cc +++ b/lib/src/ConfigLoader.cc @@ -250,7 +250,7 @@ static void loadDbClients(const Json::Value &dbClients) auto connNum = client.get("connection_number", 1).asUInt(); auto name = client.get("name", "default").asString(); auto filename = client.get("filename", "").asString(); - drogon::app().createDbClient(type, host, (u_short)port, dbname, user, password, connNum, name, filename); + drogon::app().createDbClient(type, host, (u_short)port, dbname, user, password, connNum, filename, name); } #endif } diff --git a/lib/src/HttpAppFrameworkImpl.cc b/lib/src/HttpAppFrameworkImpl.cc index 92b811d9..6ff5b819 100755 --- a/lib/src/HttpAppFrameworkImpl.cc +++ b/lib/src/HttpAppFrameworkImpl.cc @@ -1261,8 +1261,8 @@ void HttpAppFrameworkImpl::createDbClient(const std::string &dbType, const std::string &userName, const std::string &password, const size_t connectionNum, - const std::string &name, - const std::string &filename) + const std::string &filename, + const std::string &name) { auto connStr = formattedString("host=%s port=%u dbname=%s user=%s", host.c_str(), port, databaseName.c_str(), userName.c_str()); if (!password.empty()) diff --git a/lib/src/HttpAppFrameworkImpl.h b/lib/src/HttpAppFrameworkImpl.h index 5a74d87b..7526b07d 100644 --- a/lib/src/HttpAppFrameworkImpl.h +++ b/lib/src/HttpAppFrameworkImpl.h @@ -105,8 +105,8 @@ class HttpAppFrameworkImpl : public HttpAppFramework const std::string &userName, const std::string &password, const size_t connectionNum = 1, - const std::string &name = "default", - const std::string &filename = "") override; + const std::string &filename = "", + const std::string &name = "default") override; #endif private: virtual void registerHttpController(const std::string &pathPattern, diff --git a/orm_lib/src/sqlite3_impl/test/test1.cc b/orm_lib/src/sqlite3_impl/test/test1.cc index 4925fd03..fdffefc0 100644 --- a/orm_lib/src/sqlite3_impl/test/test1.cc +++ b/orm_lib/src/sqlite3_impl/test/test1.cc @@ -1,4 +1,5 @@ #include "Groups.h" +#include #include #include #include @@ -8,9 +9,11 @@ using namespace drogon::orm; int main() { trantor::Logger::setLogLevel(trantor::Logger::TRACE); - auto clientPtr = DbClient::newSqlite3Client("filename=test.db", 3); + drogon::app().createDbClient("sqlite3", "", 0, "", "", "", 3, "test.db"); + //auto clientPtr = DbClient::newSqlite3Client("filename=test.db", 3); - sleep(3); + sleep(1); + auto clientPtr = app().getDbClient(); LOG_DEBUG << "start!"; // *clientPtr << "Drop table groups;" << Mode::Blocking >> // [](const Result &r) {