From 52546b784698126aea792f78cbaea11e94ab8380 Mon Sep 17 00:00:00 2001 From: antao Date: Sun, 2 Dec 2018 22:43:23 +0800 Subject: [PATCH] Modify the model generator for time-type columns --- drogon_ctl/templates/model_cc.csp | 4 ++-- orm_lib/inc/drogon/orm/SqlBinder.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drogon_ctl/templates/model_cc.csp b/drogon_ctl/templates/model_cc.csp index ebc8978b..588303d8 100644 --- a/drogon_ctl/templates/model_cc.csp +++ b/drogon_ctl/templates/model_cc.csp @@ -315,9 +315,9 @@ Json::Value {{className}}::toJson() const if(get<%c++$$<()) { <%c++if(col._colDatabaseType=="date"){%> - ret["<%c++$$<"]=get<%c++$$<()->toCustomedFormattedStringLocal("%Y-%m-%d", false); + ret["<%c++$$<"]=get<%c++$$<()->toDbStringLocal(); <%c++}else if(col._colDatabaseType.find("timestamp")!=std::string::npos||col._colDatabaseType.find("datetime")!=std::string::npos){%> - ret["<%c++$$<"]=get<%c++$$<()->toCustomedFormattedStringLocal("%Y-%m-%d %H:%M:%S", true); + ret["<%c++$$<"]=get<%c++$$<()->toDbStringLocal(); <%c++}else if(col._colDatabaseType=="bytea"||col._colDatabaseType.find("blob")!=std::string::npos){%> ret["<%c++$$<"]=drogon::base64Encode((const unsigned char *)get<%c++$$<()->data(),get<%c++$$<()->size()); <%c++}else if(col._colType=="int64_t"){%> diff --git a/orm_lib/inc/drogon/orm/SqlBinder.h b/orm_lib/inc/drogon/orm/SqlBinder.h index a96bca85..f01bbdbe 100644 --- a/orm_lib/inc/drogon/orm/SqlBinder.h +++ b/orm_lib/inc/drogon/orm/SqlBinder.h @@ -350,11 +350,11 @@ class SqlBinder } self &operator<<(trantor::Date &&date) { - return operator<<(date.toCustomedFormattedStringLocal("%Y-%m-%d %H:%M:%S", true)); + return operator<<(date.toDbStringLocal()); } self &operator<<(const trantor::Date &date) { - return operator<<(date.toCustomedFormattedStringLocal("%Y-%m-%d %H:%M:%S", true)); + return operator<<(date.toDbStringLocal()); } self &operator<<(const std::vector &v) {