From 64e916ccb39d5c82ab99023a9323fa1445364a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=81=E7=9B=9F?= Date: Tue, 5 Jan 2021 22:14:31 +0800 Subject: [PATCH] Fix an error with missing composite key to sqlite3 ORM generator (#673) --- drogon_ctl/create_model.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drogon_ctl/create_model.cc b/drogon_ctl/create_model.cc index f89354b9..c2697ce3 100644 --- a/drogon_ctl/create_model.cc +++ b/drogon_ctl/create_model.cc @@ -548,7 +548,7 @@ void create_model::createModelClassFromSqlite3( for (auto &row : result) { bool notnull = row["notnull"].as(); - bool primary = row["pk"].as(); + bool primary = row["pk"].as(); auto type = row["type"].as(); std::transform(type.begin(), type.end(), type.begin(), tolower); ColumnInfo info; @@ -627,13 +627,14 @@ void create_model::createModelClassFromSqlite3( std::cerr << e.base().what() << std::endl; exit(1); }; - std::vector pkNames, pkTypes; + std::vector pkNames, pkTypes, pkValNames; for (auto const &col : cols) { if (col.isPrimaryKey_) { pkNames.push_back(col.colName_); pkTypes.push_back(col.colType_); + pkValNames.push_back(nameTransform(col.colName_, false)); } } data["hasPrimaryKey"] = (int)pkNames.size(); @@ -646,6 +647,7 @@ void create_model::createModelClassFromSqlite3( { data["primaryKeyName"] = pkNames; data["primaryKeyType"] = pkTypes; + data["primaryKeyValNames"] = pkValNames; } data["columns"] = cols; std::ofstream headerFile(path + "/" + className + ".h", std::ofstream::out);