Fix namespace in model template. (#1107)
This commit is contained in:
parent
e9fafc643d
commit
6a55a3aa64
|
@ -61,6 +61,7 @@ for(auto convertMethod : convertMethods ) {
|
|||
%>
|
||||
|
||||
using namespace drogon;
|
||||
using namespace drogon::orm;
|
||||
using namespace drogon_model::[[dbName]]<%c++
|
||||
auto &schema=@@.get<std::string>("schema");
|
||||
if(!schema.empty())
|
||||
|
@ -118,7 +119,7 @@ const std::string &[[className]]::getColumnName(size_t index) noexcept(false)
|
|||
assert(index < metaData_.size());
|
||||
return metaData_[index].colName_;
|
||||
}
|
||||
[[className]]::[[className]](const drogon::orm::Row &r, const ssize_t indexOffset) noexcept
|
||||
[[className]]::[[className]](const Row &r, const ssize_t indexOffset) noexcept
|
||||
{
|
||||
if(indexOffset < 0)
|
||||
{
|
||||
|
@ -176,7 +177,7 @@ const std::string &[[className]]::getColumnName(size_t index) noexcept(false)
|
|||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if(col.colDatabaseType_=="bytea")
|
||||
{
|
||||
$$<<" auto str = r[\""<<col.colName_<<"\"].as<string_view>();\n";
|
||||
|
@ -191,7 +192,7 @@ const std::string &[[className]]::getColumnName(size_t index) noexcept(false)
|
|||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
%>
|
||||
{%col.colValName_%}_=std::make_shared<{%col.colType_%}>(r["{%col.colName_%}"].as<{%col.colType_%}>());
|
||||
<%c++
|
||||
|
@ -267,7 +268,7 @@ const std::string &[[className]]::getColumnName(size_t index) noexcept(false)
|
|||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if(col.colDatabaseType_=="bytea")
|
||||
{
|
||||
$$<<" auto str = r[index].as<string_view>();\n";
|
||||
|
@ -282,7 +283,7 @@ const std::string &[[className]]::getColumnName(size_t index) noexcept(false)
|
|||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
%>
|
||||
{%col.colValName_%}_=std::make_shared<{%col.colType_%}>(r[index].as<{%col.colType_%}>());
|
||||
<%c++
|
||||
|
@ -306,7 +307,7 @@ const std::string &[[className]]::getColumnName(size_t index) noexcept(false)
|
|||
<%c++
|
||||
for(size_t i=0; i<cols.size(); ++i)
|
||||
{
|
||||
auto &col = cols[i];
|
||||
auto &col = cols[i];
|
||||
if(col.colType_.empty())
|
||||
continue;
|
||||
%>
|
||||
|
@ -378,7 +379,7 @@ const std::string &[[className]]::getColumnName(size_t index) noexcept(false)
|
|||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if(col.colDatabaseType_=="bytea" || col.colDatabaseType_.find("blob") != std::string::npos)
|
||||
{
|
||||
$$<<" if(!pJson[pMasqueradingVector["<<i<<"]].isNull())\n";
|
||||
|
@ -392,7 +393,7 @@ const std::string &[[className]]::getColumnName(size_t index) noexcept(false)
|
|||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if(col.colType_.find("uint") == 0 || col.colType_ == "unsigned short")
|
||||
{
|
||||
$$<<" if(!pJson[pMasqueradingVector["<<i<<"]].isNull())\n";
|
||||
|
@ -457,10 +458,10 @@ const std::string &[[className]]::getColumnName(size_t index) noexcept(false)
|
|||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
%>
|
||||
}
|
||||
<%c++
|
||||
<%c++
|
||||
}
|
||||
%>
|
||||
}
|
||||
|
@ -538,10 +539,10 @@ const std::string &[[className]]::getColumnName(size_t index) noexcept(false)
|
|||
$$<<" "<< convertMethod->methodBeforeDbWrite() << "(" << col.colValName_ << "_);\n";
|
||||
} //endif
|
||||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if(col.colDatabaseType_=="bytea" || col.colDatabaseType_.find("blob") != std::string::npos)
|
||||
{
|
||||
$$<<" if(!pJson[\""<<col.colName_<<"\"].isNull())\n";
|
||||
|
@ -552,10 +553,10 @@ const std::string &[[className]]::getColumnName(size_t index) noexcept(false)
|
|||
if (convertMethod != convertMethods.end() && convertMethod->methodBeforeDbWrite() != "") {
|
||||
$$<<" "<< convertMethod->methodBeforeDbWrite() << "(" << col.colValName_ << "_);\n";
|
||||
} //endif
|
||||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if(col.colType_.find("uint") == 0 || col.colType_ == "unsigned short")
|
||||
{
|
||||
$$<<" if(!pJson[\""<<col.colName_<<"\"].isNull())\n";
|
||||
|
@ -565,7 +566,7 @@ const std::string &[[className]]::getColumnName(size_t index) noexcept(false)
|
|||
if (convertMethod != convertMethods.end() && convertMethod->methodBeforeDbWrite() != "") {
|
||||
$$<<" "<< convertMethod->methodBeforeDbWrite() << "(" << col.colValName_ << "_);\n";
|
||||
} //endif
|
||||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
|
@ -578,7 +579,7 @@ const std::string &[[className]]::getColumnName(size_t index) noexcept(false)
|
|||
if (convertMethod != convertMethods.end() && convertMethod->methodBeforeDbWrite() != "") {
|
||||
$$<<" "<< convertMethod->methodBeforeDbWrite() << "(" << col.colValName_ << "_);\n";
|
||||
} //endif
|
||||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
|
@ -591,7 +592,7 @@ const std::string &[[className]]::getColumnName(size_t index) noexcept(false)
|
|||
if (convertMethod != convertMethods.end() && convertMethod->methodBeforeDbWrite() != "") {
|
||||
$$<<" "<< convertMethod->methodBeforeDbWrite() << "(" << col.colValName_ << "_);\n";
|
||||
} //endif
|
||||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
|
@ -604,7 +605,7 @@ const std::string &[[className]]::getColumnName(size_t index) noexcept(false)
|
|||
if (convertMethod != convertMethods.end() && convertMethod->methodBeforeDbWrite() != "") {
|
||||
$$<<" "<< convertMethod->methodBeforeDbWrite() << "(" << col.colValName_ << "_);\n";
|
||||
} //endif
|
||||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
|
@ -617,10 +618,10 @@ const std::string &[[className]]::getColumnName(size_t index) noexcept(false)
|
|||
if (convertMethod != convertMethods.end() && convertMethod->methodBeforeDbWrite() != "") {
|
||||
$$<<" "<< convertMethod->methodBeforeDbWrite() << "(" << col.colValName_ << "_);\n";
|
||||
} //endif
|
||||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
%>
|
||||
}
|
||||
<%c++
|
||||
|
@ -713,7 +714,7 @@ void [[className]]::updateByMasqueradedJson(const Json::Value &pJson,
|
|||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if(col.colDatabaseType_=="bytea" || col.colDatabaseType_.find("blob") != std::string::npos)
|
||||
{
|
||||
$$<<" if(!pJson[pMasqueradingVector["<<i<<"]].isNull())\n";
|
||||
|
@ -727,7 +728,7 @@ void [[className]]::updateByMasqueradedJson(const Json::Value &pJson,
|
|||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if(col.colType_.find("uint") == 0 || col.colType_ == "unsigned short")
|
||||
{
|
||||
$$<<" if(!pJson[pMasqueradingVector["<<i<<"]].isNull())\n";
|
||||
|
@ -792,14 +793,14 @@ void [[className]]::updateByMasqueradedJson(const Json::Value &pJson,
|
|||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
%>
|
||||
}
|
||||
<%c++
|
||||
}
|
||||
%>
|
||||
}
|
||||
|
||||
|
||||
void [[className]]::updateByJson(const Json::Value &pJson) noexcept(false)
|
||||
{
|
||||
<%c++
|
||||
|
@ -879,7 +880,7 @@ void [[className]]::updateByJson(const Json::Value &pJson) noexcept(false)
|
|||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if(col.colDatabaseType_=="bytea" || col.colDatabaseType_.find("blob") != std::string::npos)
|
||||
{
|
||||
$$<<" if(!pJson[\""<<col.colName_<<"\"].isNull())\n";
|
||||
|
@ -893,7 +894,7 @@ void [[className]]::updateByJson(const Json::Value &pJson) noexcept(false)
|
|||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if(col.colType_.find("uint") == 0 || col.colType_ == "unsigned short")
|
||||
{
|
||||
$$<<" if(!pJson[\""<<col.colName_<<"\"].isNull())\n";
|
||||
|
@ -958,7 +959,7 @@ void [[className]]::updateByJson(const Json::Value &pJson) noexcept(false)
|
|||
$$<<" }\n";
|
||||
$$<<" }\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
%>
|
||||
}
|
||||
<%c++
|
||||
|
@ -993,7 +994,7 @@ void [[className]]::updateByJson(const Json::Value &pJson) noexcept(false)
|
|||
$$<<"{\n";
|
||||
$$<<" return "<<col.colValName_<<"_;\n";
|
||||
$$<<"}\n";
|
||||
|
||||
|
||||
$$<<"void "<<className<<"::set"<<col.colTypeName_<<"(const "<<col.colType_<<" &p"<<col.colTypeName_<<") noexcept\n";
|
||||
$$<<"{\n";
|
||||
if(col.colDatabaseType_=="date")
|
||||
|
@ -1006,7 +1007,7 @@ void [[className]]::updateByJson(const Json::Value &pJson) noexcept(false)
|
|||
}
|
||||
$$<<" dirtyFlag_["<<i<<"] = true;\n";
|
||||
$$<<"}\n";
|
||||
|
||||
|
||||
if(col.colType_=="std::string")
|
||||
{
|
||||
$$<<"void "<<className<<"::set"<<col.colTypeName_<<"("<<col.colType_<<" &&p"<<col.colTypeName_<<") noexcept\n";
|
||||
|
@ -1043,7 +1044,7 @@ void [[className]]::updateByJson(const Json::Value &pJson) noexcept(false)
|
|||
$$<<"}\n";
|
||||
}
|
||||
}
|
||||
$$<<"\n";
|
||||
$$<<"\n";
|
||||
}
|
||||
if(@@.get<std::string>("rdbms")=="postgresql"||@@.get<int>("hasPrimaryKey")!=1)
|
||||
{
|
||||
|
@ -1328,7 +1329,7 @@ bool [[className]]::validateMasqueradedJsonForCreation(const Json::Value &pJson,
|
|||
}
|
||||
<%c++}%>
|
||||
}
|
||||
catch(const Json::LogicError &e)
|
||||
catch(const Json::LogicError &e)
|
||||
{
|
||||
err = e.what();
|
||||
return false;
|
||||
|
@ -1358,7 +1359,7 @@ bool [[className]]::validateJsonForUpdate(const Json::Value &pJson, std::string
|
|||
err = "The value of primary key must be set in the json object for update";
|
||||
return false;
|
||||
}
|
||||
<%c++
|
||||
<%c++
|
||||
}
|
||||
}%>
|
||||
return true;
|
||||
|
@ -1385,7 +1386,7 @@ bool [[className]]::validateMasqueradedJsonForUpdate(const Json::Value &pJson,
|
|||
if(!validJsonOfField({%i%}, pMasqueradingVector[{%i%}], pJson[pMasqueradingVector[{%i%}]], err, false))
|
||||
return false;
|
||||
}
|
||||
<%c++
|
||||
<%c++
|
||||
if(col.isPrimaryKey_)
|
||||
{
|
||||
%>
|
||||
|
@ -1394,11 +1395,11 @@ bool [[className]]::validateMasqueradedJsonForUpdate(const Json::Value &pJson,
|
|||
err = "The value of primary key must be set in the json object for update";
|
||||
return false;
|
||||
}
|
||||
<%c++
|
||||
<%c++
|
||||
}
|
||||
}%>
|
||||
}
|
||||
catch(const Json::LogicError &e)
|
||||
catch(const Json::LogicError &e)
|
||||
{
|
||||
err = e.what();
|
||||
return false;
|
||||
|
@ -1407,8 +1408,8 @@ bool [[className]]::validateMasqueradedJsonForUpdate(const Json::Value &pJson,
|
|||
}
|
||||
bool [[className]]::validJsonOfField(size_t index,
|
||||
{%indentStr%} const std::string &fieldName,
|
||||
{%indentStr%} const Json::Value &pJson,
|
||||
{%indentStr%} std::string &err,
|
||||
{%indentStr%} const Json::Value &pJson,
|
||||
{%indentStr%} std::string &err,
|
||||
{%indentStr%} bool isForCreation)
|
||||
{
|
||||
switch(index)
|
||||
|
@ -1429,7 +1430,7 @@ bool [[className]]::validJsonOfField(size_t index,
|
|||
}
|
||||
<%c++}
|
||||
if(col.isAutoVal_)
|
||||
{
|
||||
{
|
||||
if(col.isPrimaryKey_)
|
||||
{
|
||||
%>
|
||||
|
@ -1437,8 +1438,8 @@ bool [[className]]::validJsonOfField(size_t index,
|
|||
{
|
||||
err="The automatic primary key cannot be set";
|
||||
return false;
|
||||
}
|
||||
<%c++
|
||||
}
|
||||
<%c++
|
||||
}else
|
||||
{
|
||||
%>
|
||||
|
@ -1452,15 +1453,15 @@ bool [[className]]::validJsonOfField(size_t index,
|
|||
err="The automatic primary key cannot be update";
|
||||
return false;
|
||||
}
|
||||
<%c++
|
||||
<%c++
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!col.notNull_){%>
|
||||
if(pJson.isNull())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
<%c++}
|
||||
<%c++}
|
||||
if(col.colType_ == "uint64_t")
|
||||
{
|
||||
%>
|
||||
|
@ -1519,7 +1520,7 @@ if(!col.notNull_){%>
|
|||
err="Type error in the "+fieldName+" field";
|
||||
return false;
|
||||
}
|
||||
<%c++
|
||||
<%c++
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1527,7 +1528,7 @@ if(!col.notNull_){%>
|
|||
if(!pJson.isString())
|
||||
{
|
||||
err="Type error in the "+fieldName+" field";
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
<%c++
|
||||
if(col.colType_ == "std::string" && col.colLength_>0)
|
||||
|
@ -1539,7 +1540,7 @@ if(!col.notNull_){%>
|
|||
err="String length exceeds limit for the " +
|
||||
fieldName +
|
||||
" field (the maximum value is {%col.colLength_%})";
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
<%c++
|
||||
|
@ -1548,7 +1549,7 @@ if(!col.notNull_){%>
|
|||
%>
|
||||
break;
|
||||
<%c++
|
||||
}%>
|
||||
}%>
|
||||
default:
|
||||
err="Internal error in the server";
|
||||
return false;
|
||||
|
@ -1578,7 +1579,7 @@ for(auto &relationship : relationships)
|
|||
}
|
||||
std::string alind(alias.length(), ' ');
|
||||
%>
|
||||
void [[className]]::get{%alias%}(const DbClientPtr &clientPtr,
|
||||
void [[className]]::get{%alias%}(const DbClientPtr &clientPtr,
|
||||
{%indentStr%} {%alind%} const std::function<void({%relationshipClassName%})> &rcb,
|
||||
{%indentStr%} {%alind%} const ExceptionCallback &ecb) const
|
||||
<%c++
|
||||
|
@ -1587,7 +1588,7 @@ void [[className]]::get{%alias%}(const DbClientPtr &clientPtr,
|
|||
{
|
||||
std::string relationshipClassInde(relationshipClassName.length(), ' ');
|
||||
%>
|
||||
void [[className]]::get{%relationshipClassName%}(const DbClientPtr &clientPtr,
|
||||
void [[className]]::get{%relationshipClassName%}(const DbClientPtr &clientPtr,
|
||||
{%indentStr%} {%relationshipClassInde%} const std::function<void({%relationshipClassName%})> &rcb,
|
||||
{%indentStr%} {%relationshipClassInde%} const ExceptionCallback &ecb) const
|
||||
<%c++
|
||||
|
@ -1604,7 +1605,7 @@ void [[className]]::get{%relationshipClassName%}(const DbClientPtr &clientPtr,
|
|||
$$<<"?";
|
||||
}%>";
|
||||
*clientPtr << sql
|
||||
<< *{%nameTransform(relationship.originalKey(), false)%}_
|
||||
<< *{%nameTransform(relationship.originalKey(), false)%}_
|
||||
>> [rcb = std::move(rcb), ecb](const Result &r){
|
||||
if (r.size() == 0)
|
||||
{
|
||||
|
@ -1633,7 +1634,7 @@ void [[className]]::get{%relationshipClassName%}(const DbClientPtr &clientPtr,
|
|||
}
|
||||
std::string alind(alias.length(), ' ');
|
||||
%>
|
||||
void [[className]]::get{%alias%}(const DbClientPtr &clientPtr,
|
||||
void [[className]]::get{%alias%}(const DbClientPtr &clientPtr,
|
||||
{%indentStr%} {%alind%} const std::function<void(std::vector<{%relationshipClassName%}>)> &rcb,
|
||||
{%indentStr%} {%alind%} const ExceptionCallback &ecb) const
|
||||
<%c++
|
||||
|
@ -1642,7 +1643,7 @@ void [[className]]::get{%alias%}(const DbClientPtr &clientPtr,
|
|||
{
|
||||
std::string relationshipClassInde(relationshipClassName.length(), ' ');
|
||||
%>
|
||||
void [[className]]::get{%relationshipClassName%}(const DbClientPtr &clientPtr,
|
||||
void [[className]]::get{%relationshipClassName%}(const DbClientPtr &clientPtr,
|
||||
{%indentStr%} {%relationshipClassInde%} const std::function<void(std::vector<{%relationshipClassName%}>)> &rcb,
|
||||
{%indentStr%} {%relationshipClassInde%} const ExceptionCallback &ecb) const
|
||||
<%c++
|
||||
|
@ -1659,7 +1660,7 @@ void [[className]]::get{%relationshipClassName%}(const DbClientPtr &clientPtr,
|
|||
$$<<"?";
|
||||
}%>";
|
||||
*clientPtr << sql
|
||||
<< *{%nameTransform(relationship.originalKey(), false)%}_
|
||||
<< *{%nameTransform(relationship.originalKey(), false)%}_
|
||||
>> [rcb = std::move(rcb)](const Result &r){
|
||||
std::vector<{%relationshipClassName%}> ret;
|
||||
ret.reserve(ret.size());
|
||||
|
@ -1687,7 +1688,7 @@ void [[className]]::get{%relationshipClassName%}(const DbClientPtr &clientPtr,
|
|||
}
|
||||
std::string alind(alias.length(), ' ');
|
||||
%>
|
||||
void [[className]]::get{%alias%}(const DbClientPtr &clientPtr,
|
||||
void [[className]]::get{%alias%}(const DbClientPtr &clientPtr,
|
||||
{%indentStr%} {%alind%} const std::function<void(std::vector<std::pair<{%relationshipClassName%},{%pivotTableClassName%}>>)> &rcb,
|
||||
{%indentStr%} {%alind%} const ExceptionCallback &ecb) const
|
||||
<%c++
|
||||
|
@ -1696,7 +1697,7 @@ void [[className]]::get{%alias%}(const DbClientPtr &clientPtr,
|
|||
{
|
||||
std::string relationshipClassInde(relationshipClassName.length(), ' ');
|
||||
%>
|
||||
void [[className]]::get{%relationshipClassName%}(const DbClientPtr &clientPtr,
|
||||
void [[className]]::get{%relationshipClassName%}(const DbClientPtr &clientPtr,
|
||||
{%indentStr%} {%relationshipClassInde%} const std::function<void(std::vector<std::pair<{%relationshipClassName%},{%pivotTableClassName%}>>)> &rcb,
|
||||
{%indentStr%} {%relationshipClassInde%} const ExceptionCallback &ecb) const
|
||||
<%c++
|
||||
|
@ -1713,7 +1714,7 @@ void [[className]]::get{%relationshipClassName%}(const DbClientPtr &clientPtr,
|
|||
$$<<"?";
|
||||
}%> and {%pivotTableName%}.{%pivotTargetKey%} = {%name%}.{%relationship.targetKey()%}";
|
||||
*clientPtr << sql
|
||||
<< *{%nameTransform(relationship.originalKey(), false)%}_
|
||||
<< *{%nameTransform(relationship.originalKey(), false)%}_
|
||||
>> [rcb = std::move(rcb)](const Result &r){
|
||||
std::vector<std::pair<{%relationshipClassName%},{%pivotTableClassName%}>> ret;
|
||||
ret.reserve(ret.size());
|
||||
|
|
|
@ -37,7 +37,7 @@ using DbClientPtr = std::shared_ptr<DbClient>;
|
|||
}
|
||||
namespace drogon_model
|
||||
{
|
||||
namespace [[dbName]]
|
||||
namespace [[dbName]]
|
||||
{
|
||||
<%c++
|
||||
auto &schema=@@.get<std::string>("schema");
|
||||
|
@ -97,7 +97,7 @@ auto cols=@@.get<std::vector<ColumnInfo>>("columns");
|
|||
int getPrimaryKey() const { assert(false); return 0; }
|
||||
<%c++}%>
|
||||
<%c++}else{
|
||||
auto pkTypes=@@.get<std::vector<std::string>>("primaryKeyType");
|
||||
auto pkTypes=@@.get<std::vector<std::string>>("primaryKeyType");
|
||||
std::string typelist;
|
||||
for(size_t i=0;i<pkTypes.size();i++)
|
||||
{
|
||||
|
@ -117,15 +117,15 @@ auto cols=@@.get<std::vector<ColumnInfo>>("columns");
|
|||
}
|
||||
%>
|
||||
|
||||
PrimaryKeyType getPrimaryKey() const;
|
||||
PrimaryKeyType getPrimaryKey() const;
|
||||
<%c++}%>
|
||||
|
||||
/**
|
||||
* @brief constructor
|
||||
* @param r One row of records in the SQL query result.
|
||||
* @param indexOffset Set the offset to -1 to access all columns by column names,
|
||||
* @param indexOffset Set the offset to -1 to access all columns by column names,
|
||||
* otherwise access all columns by offsets.
|
||||
* @note If the SQL is not a style of 'select * from table_name ...' (select all
|
||||
* @note If the SQL is not a style of 'select * from table_name ...' (select all
|
||||
* columns by an asterisk), please set the offset to -1.
|
||||
*/
|
||||
explicit [[className]](const drogon::orm::Row &r, const ssize_t indexOffset = 0) noexcept;
|
||||
|
@ -144,7 +144,7 @@ auto cols=@@.get<std::vector<ColumnInfo>>("columns");
|
|||
[[className]](const Json::Value &pJson, const std::vector<std::string> &pMasqueradingVector) noexcept(false);
|
||||
|
||||
[[className]]() = default;
|
||||
|
||||
|
||||
void updateByJson(const Json::Value &pJson) noexcept(false);
|
||||
void updateByMasqueradedJson(const Json::Value &pJson,
|
||||
const std::vector<std::string> &pMasqueradingVector) noexcept(false);
|
||||
|
@ -158,8 +158,8 @@ auto cols=@@.get<std::vector<ColumnInfo>>("columns");
|
|||
std::string &err);
|
||||
static bool validJsonOfField(size_t index,
|
||||
const std::string &fieldName,
|
||||
const Json::Value &pJson,
|
||||
std::string &err,
|
||||
const Json::Value &pJson,
|
||||
std::string &err,
|
||||
bool isForCreation);
|
||||
|
||||
<%c++
|
||||
|
@ -194,7 +194,7 @@ auto cols=@@.get<std::vector<ColumnInfo>>("columns");
|
|||
}
|
||||
else
|
||||
$$<<" //FIXME!!"<<" getValueOf"<<col.colTypeName_<<"() const noexcept;\n";
|
||||
$$<<"\n";
|
||||
$$<<"\n";
|
||||
}
|
||||
%>
|
||||
|
||||
|
@ -204,7 +204,7 @@ auto cols=@@.get<std::vector<ColumnInfo>>("columns");
|
|||
Json::Value toJson() const;
|
||||
Json::Value toMasqueradedJson(const std::vector<std::string> &pMasqueradingVector) const;
|
||||
/// Relationship interfaces
|
||||
<%c++
|
||||
<%c++
|
||||
for(auto &relationship : relationships)
|
||||
{
|
||||
if(relationship.targetKey().empty() || relationship.originalKey().empty())
|
||||
|
@ -226,18 +226,18 @@ auto cols=@@.get<std::vector<ColumnInfo>>("columns");
|
|||
}
|
||||
std::string alind(alias.length(), ' ');
|
||||
%>
|
||||
void get{%alias%}(const DbClientPtr &clientPtr,
|
||||
void get{%alias%}(const drogon::orm::DbClientPtr &clientPtr,
|
||||
{%alind%} const std::function<void({%relationshipClassName%})> &rcb,
|
||||
{%alind%} const ExceptionCallback &ecb) const;
|
||||
{%alind%} const drogon::orm::ExceptionCallback &ecb) const;
|
||||
<%c++
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string relationshipClassInde(relationshipClassName.length(), ' ');
|
||||
%>
|
||||
void get{%relationshipClassName%}(const DbClientPtr &clientPtr,
|
||||
void get{%relationshipClassName%}(const drogon::orm::DbClientPtr &clientPtr,
|
||||
{%relationshipClassInde%} const std::function<void({%relationshipClassName%})> &rcb,
|
||||
{%relationshipClassInde%} const ExceptionCallback &ecb) const;
|
||||
{%relationshipClassInde%} const drogon::orm::ExceptionCallback &ecb) const;
|
||||
<%c++
|
||||
}
|
||||
}
|
||||
|
@ -251,18 +251,18 @@ auto cols=@@.get<std::vector<ColumnInfo>>("columns");
|
|||
}
|
||||
std::string alind(alias.length(), ' ');
|
||||
%>
|
||||
void get{%alias%}(const DbClientPtr &clientPtr,
|
||||
void get{%alias%}(const drogon::orm::DbClientPtr &clientPtr,
|
||||
{%alind%} const std::function<void(std::vector<{%relationshipClassName%}>)> &rcb,
|
||||
{%alind%} const ExceptionCallback &ecb) const;
|
||||
{%alind%} const drogon::orm::ExceptionCallback &ecb) const;
|
||||
<%c++
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string relationshipClassInde(relationshipClassName.length(), ' ');
|
||||
%>
|
||||
void get{%relationshipClassName%}(const DbClientPtr &clientPtr,
|
||||
void get{%relationshipClassName%}(const drogon::orm::DbClientPtr &clientPtr,
|
||||
{%relationshipClassInde%} const std::function<void(std::vector<{%relationshipClassName%}>)> &rcb,
|
||||
{%relationshipClassInde%} const ExceptionCallback &ecb) const;
|
||||
{%relationshipClassInde%} const drogon::orm::ExceptionCallback &ecb) const;
|
||||
<%c++
|
||||
}
|
||||
}
|
||||
|
@ -278,18 +278,18 @@ auto cols=@@.get<std::vector<ColumnInfo>>("columns");
|
|||
}
|
||||
std::string alind(alias.length(), ' ');
|
||||
%>
|
||||
void get{%alias%}(const DbClientPtr &clientPtr,
|
||||
void get{%alias%}(const drogon::orm::DbClientPtr &clientPtr,
|
||||
{%alind%} const std::function<void(std::vector<std::pair<{%relationshipClassName%},{%pivotTableClassName%}>>)> &rcb,
|
||||
{%alind%} const ExceptionCallback &ecb) const;
|
||||
{%alind%} const drogon::orm::ExceptionCallback &ecb) const;
|
||||
<%c++
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string relationshipClassInde(relationshipClassName.length(), ' ');
|
||||
%>
|
||||
void get{%relationshipClassName%}(const DbClientPtr &clientPtr,
|
||||
void get{%relationshipClassName%}(const drogon::orm::DbClientPtr &clientPtr,
|
||||
{%relationshipClassInde%} const std::function<void(std::vector<std::pair<{%relationshipClassName%},{%pivotTableClassName%}>>)> &rcb,
|
||||
{%relationshipClassInde%} const ExceptionCallback &ecb) const;
|
||||
{%relationshipClassInde%} const drogon::orm::ExceptionCallback &ecb) const;
|
||||
<%c++
|
||||
}
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ if(@@.get<int>("hasPrimaryKey")<=1){
|
|||
$$<<"\";\n";
|
||||
}
|
||||
%>
|
||||
return sql;
|
||||
return sql;
|
||||
}
|
||||
|
||||
static const std::string &sqlForDeletingByPrimaryKey()
|
||||
|
@ -388,7 +388,7 @@ if(@@.get<int>("hasPrimaryKey")<=1){
|
|||
$$<<"\";\n";
|
||||
}
|
||||
%>
|
||||
return sql;
|
||||
return sql;
|
||||
}
|
||||
std::string sqlForInserting(bool &needSelection) const
|
||||
{
|
||||
|
@ -412,7 +412,7 @@ if(@@.get<int>("hasPrimaryKey")<=1){
|
|||
$$<<" sql += \""<<cols[i].colName_<<",\";\n";
|
||||
$$<<" ++parametersCount;\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(cols[i].colType_.empty())
|
||||
continue;
|
||||
if(cols[i].hasDefaultVal_)
|
||||
|
@ -433,13 +433,13 @@ if(@@.get<int>("hasPrimaryKey")<=1){
|
|||
<%c++
|
||||
}
|
||||
if(@@.get<int>("hasPrimaryKey")>0||@@.get<std::string>("rdbms")=="postgresql")
|
||||
{
|
||||
{
|
||||
%>
|
||||
if(!dirtyFlag_[{%i%}])
|
||||
{
|
||||
needSelection=true;
|
||||
}
|
||||
<%c++
|
||||
<%c++
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -450,7 +450,7 @@ if(@@.get<int>("hasPrimaryKey")<=1){
|
|||
sql += "{%cols[i].colName_%},";
|
||||
++parametersCount;
|
||||
}
|
||||
<%c++
|
||||
<%c++
|
||||
}
|
||||
}
|
||||
if(selFlag)
|
||||
|
@ -465,7 +465,7 @@ if(@@.get<int>("hasPrimaryKey")<=1){
|
|||
}
|
||||
else
|
||||
sql += ") values (";
|
||||
|
||||
|
||||
<%c++
|
||||
if(@@.get<std::string>("rdbms")=="postgresql")
|
||||
{
|
||||
|
@ -473,8 +473,8 @@ if(@@.get<std::string>("rdbms")=="postgresql")
|
|||
int placeholder=1;
|
||||
char placeholderStr[64];
|
||||
size_t n=0;
|
||||
<%c++
|
||||
}
|
||||
<%c++
|
||||
}
|
||||
for(size_t i=0;i<cols.size();i++)
|
||||
{
|
||||
if(cols[i].isAutoVal_)
|
||||
|
@ -486,7 +486,7 @@ if(@@.get<std::string>("rdbms")=="postgresql")
|
|||
<%c++
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(cols[i].colType_.empty())
|
||||
continue;
|
||||
%>
|
||||
|
@ -507,7 +507,7 @@ if(@@.get<std::string>("rdbms")=="postgresql")
|
|||
<%c++
|
||||
}
|
||||
%>
|
||||
}
|
||||
}
|
||||
<%c++
|
||||
if(cols[i].hasDefaultVal_&&@@.get<std::string>("rdbms")!="sqlite3")
|
||||
{
|
||||
|
@ -544,7 +544,7 @@ if(cols[i].hasDefaultVal_&&@@.get<std::string>("rdbms")!="sqlite3")
|
|||
}
|
||||
%>
|
||||
LOG_TRACE << sql;
|
||||
return sql;
|
||||
return sql;
|
||||
}
|
||||
};
|
||||
<%c++
|
||||
|
|
Loading…
Reference in New Issue