From 7ae8f58bb8657699e85bd22623811c76c63869dd Mon Sep 17 00:00:00 2001 From: antao Date: Tue, 15 Jan 2019 13:21:40 +0800 Subject: [PATCH] Modify the Result class --- orm_lib/inc/drogon/orm/Field.h | 2 +- orm_lib/inc/drogon/orm/Result.h | 5 +---- orm_lib/inc/drogon/orm/Row.h | 2 +- orm_lib/src/Result.cc | 1 - orm_lib/src/sqlite3_impl/test/test1.cc | 6 ++---- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/orm_lib/inc/drogon/orm/Field.h b/orm_lib/inc/drogon/orm/Field.h index 547c8b9c..0ad0a7c1 100644 --- a/orm_lib/inc/drogon/orm/Field.h +++ b/orm_lib/inc/drogon/orm/Field.h @@ -158,7 +158,7 @@ class Field Field(const Row &row, Row::size_type columnNum) noexcept; private: - Result _result; + const Result _result; }; template <> std::string Field::as() const; diff --git a/orm_lib/inc/drogon/orm/Result.h b/orm_lib/inc/drogon/orm/Result.h index 615bae45..35d54290 100644 --- a/orm_lib/inc/drogon/orm/Result.h +++ b/orm_lib/inc/drogon/orm/Result.h @@ -76,8 +76,6 @@ class Result row_size_type columns() const noexcept; /// Name of column with this number (throws exception if it doesn't exist) const char *columnName(row_size_type number) const; - const std::string &errorDescription() const { return _errString; } - void setError(const std::string &description) { _errString = description; } size_type affectedRows() const noexcept; @@ -88,8 +86,7 @@ class Result private: ResultImplPtr _resultPtr; - - std::string _errString; + friend class Field; friend class Row; /// Number of given column (throws exception if it doesn't exist). diff --git a/orm_lib/inc/drogon/orm/Row.h b/orm_lib/inc/drogon/orm/Row.h index 82310a47..b5ffa0dd 100644 --- a/orm_lib/inc/drogon/orm/Row.h +++ b/orm_lib/inc/drogon/orm/Row.h @@ -55,7 +55,7 @@ class Row ConstReverseIterator crend() const; private: - Result _result; + const Result _result; protected: friend class Field; diff --git a/orm_lib/src/Result.cc b/orm_lib/src/Result.cc index 6eeea770..0c0700bc 100644 --- a/orm_lib/src/Result.cc +++ b/orm_lib/src/Result.cc @@ -114,7 +114,6 @@ Result::size_type Result::size() const noexcept void Result::swap(Result &other) noexcept { _resultPtr.swap(other._resultPtr); - _errString.swap(other._errString); } Result::row_size_type Result::columns() const noexcept { diff --git a/orm_lib/src/sqlite3_impl/test/test1.cc b/orm_lib/src/sqlite3_impl/test/test1.cc index fdffefc0..3d0da05b 100644 --- a/orm_lib/src/sqlite3_impl/test/test1.cc +++ b/orm_lib/src/sqlite3_impl/test/test1.cc @@ -9,11 +9,9 @@ using namespace drogon::orm; int main() { trantor::Logger::setLogLevel(trantor::Logger::TRACE); - drogon::app().createDbClient("sqlite3", "", 0, "", "", "", 3, "test.db"); - //auto clientPtr = DbClient::newSqlite3Client("filename=test.db", 3); - + auto clientPtr = DbClient::newSqlite3Client("filename=test.db", 3); sleep(1); - auto clientPtr = app().getDbClient(); + LOG_DEBUG << "start!"; // *clientPtr << "Drop table groups;" << Mode::Blocking >> // [](const Result &r) {