From 1e83a5cc4e074db78277cf77aacbeae6771a0696 Mon Sep 17 00:00:00 2001 From: An Tao Date: Tue, 10 Sep 2019 15:58:42 +0800 Subject: [PATCH] Fix a bug of creating models for mysql (#237) --- drogon_ctl/templates/model_cc.csp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drogon_ctl/templates/model_cc.csp b/drogon_ctl/templates/model_cc.csp index a3902aa2..7e0172b2 100644 --- a/drogon_ctl/templates/model_cc.csp +++ b/drogon_ctl/templates/model_cc.csp @@ -209,7 +209,7 @@ const std::string &[[className]]::getColumnName(size_t index) noexcept(false) } $$<<"\n"; } - if(@@.get("rdbms")=="postgresql") + if(@@.get("rdbms")=="postgresql"||@@.get("hasPrimaryKey")!=1) { $$<<"void "<("rdbms")=="mysql"||@@.get("rdbms")=="sqlite3") { + auto primaryKeyTypeString=@@.get("primaryKeyType"); $$<<"void "<(id);\n"; + if(primaryKeyTypeString!="uint64_t") + { + $$<<" _"<(static_cast<"<(id));\n"; + } + else + { + $$<<" _"<(id);\n"; + } break; } }