Fixing bug in drogon_ctl when creating a model, that causes to write the content of the header and sourcefiles multiple times (#540)

This commit is contained in:
itgenie98 2020-08-15 01:14:52 +02:00 committed by GitHub
parent c4d727cbe6
commit 168d2afb17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 22 deletions

View File

@ -624,29 +624,28 @@ void create_model::createModelClassFromSqlite3(
pkNames.push_back(col.colName_);
pkTypes.push_back(col.colType_);
}
data["hasPrimaryKey"] = (int)pkNames.size();
if (pkNames.size() == 1)
{
data["primaryKeyName"] = pkNames[0];
data["primaryKeyType"] = pkTypes[0];
}
else if (pkNames.size() > 1)
{
data["primaryKeyName"] = pkNames;
data["primaryKeyType"] = pkTypes;
}
data["columns"] = cols;
std::ofstream headerFile(path + "/" + className + ".h",
std::ofstream::out);
std::ofstream sourceFile(path + "/" + className + ".cc",
std::ofstream::out);
auto templ = DrTemplateBase::newTemplate("model_h.csp");
headerFile << templ->genText(data);
templ = DrTemplateBase::newTemplate("model_cc.csp");
sourceFile << templ->genText(data);
createRestfulAPIController(data, restfulApiConfig);
}
data["hasPrimaryKey"] = (int)pkNames.size();
if (pkNames.size() == 1)
{
data["primaryKeyName"] = pkNames[0];
data["primaryKeyType"] = pkTypes[0];
}
else if (pkNames.size() > 1)
{
data["primaryKeyName"] = pkNames;
data["primaryKeyType"] = pkTypes;
}
data["columns"] = cols;
std::ofstream headerFile(path + "/" + className + ".h",
std::ofstream::out);
std::ofstream sourceFile(path + "/" + className + ".cc",
std::ofstream::out);
auto templ = DrTemplateBase::newTemplate("model_h.csp");
headerFile << templ->genText(data);
templ = DrTemplateBase::newTemplate("model_cc.csp");
sourceFile << templ->genText(data);
createRestfulAPIController(data, restfulApiConfig);
}
void create_model::createModelFromSqlite3(