From dbf21f7dbc58e39367b8333e601400a3bd313b65 Mon Sep 17 00:00:00 2001 From: An Tao Date: Tue, 27 Oct 2020 21:26:01 +0800 Subject: [PATCH] Fix a bug when creating sqlite3 database models (#618) --- drogon_ctl/create_model.cc | 4 ++++ lib/src/ConfigLoader.cc | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drogon_ctl/create_model.cc b/drogon_ctl/create_model.cc index 5255a1f1..08a8f42a 100644 --- a/drogon_ctl/create_model.cc +++ b/drogon_ctl/create_model.cc @@ -608,6 +608,10 @@ void create_model::createModelClassFromSqlite3( { info.colType_ = "std::vector"; } + else if (type == "datetime" || type == "date") + { + info.colType_ = "::trantor::Date"; + } else { info.colType_ = "std::string"; diff --git a/lib/src/ConfigLoader.cc b/lib/src/ConfigLoader.cc index ca754343..3280fbd9 100644 --- a/lib/src/ConfigLoader.cc +++ b/lib/src/ConfigLoader.cc @@ -461,10 +461,11 @@ static void loadDbClients(const Json::Value &dbClients) for (auto const &client : dbClients) { auto type = client.get("rdbms", "postgresql").asString(); + std::transform(type.begin(), type.end(), type.begin(), ::tolower); auto host = client.get("host", "127.0.0.1").asString(); auto port = client.get("port", 5432).asUInt(); auto dbname = client.get("dbname", "").asString(); - if (dbname == "") + if (dbname == "" && type != "sqlite3") { std::cerr << "Please configure dbname in the configuration file" << std::endl;