Skip to content

Commit

Permalink
Fixing bug in drogon_ctl when creating a model, that causes to write …
Browse files Browse the repository at this point in the history
…the content of the header and sourcefiles multiple times (#540)
  • Loading branch information
itgenie98 authored Aug 14, 2020
1 parent c4d727c commit 168d2af
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions drogon_ctl/create_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 168d2af

Please sign in to comment.