From: sangwan.kwon Date: Fri, 30 Nov 2018 04:32:47 +0000 (+0900) Subject: Change return type to reference on query-builder X-Git-Tag: submit/tizen/20190219.012108~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5a07b56967b55b8a13808392c7e033737e52ffc4;p=platform%2Fcore%2Fsecurity%2Fklay.git Change return type to reference on query-builder - Database, Table should be returned by reference for recursive call Change-Id: Ia97f32e260dc16855ef14a9661d623945c77e505 Signed-off-by: sangwan.kwon --- diff --git a/include/klay/db/query-builder/database.hxx b/include/klay/db/query-builder/database.hxx index 7133f6c..b5f9250 100644 --- a/include/klay/db/query-builder/database.hxx +++ b/include/klay/db/query-builder/database.hxx @@ -36,16 +36,16 @@ public: using Self = Database; template - Self select(ColumnTypes&&... cts); + Self& select(ColumnTypes&&... cts); template - Self where(Expr expr); + Self& where(Expr expr); template - Self join(condition::Join type = condition::Join::INNER); + Self& join(condition::Join type = condition::Join::INNER); template - Self on(Expr expr); + Self& on(Expr expr); operator std::string(); @@ -125,7 +125,7 @@ Database::Database(const std::string& name, ImplType&& impl) template template -Database Database::select(ColumnTypes&&... cts) +Database& Database::select(ColumnTypes&&... cts) { this->cache.clear(); @@ -161,7 +161,7 @@ Database Database::select(ColumnTypes&&... cts) template template -Database Database::where(Expr expr) +Database& Database::where(Expr expr) { std::stringstream ss; ss << "WHERE " << this->processWhere(expr); @@ -173,7 +173,7 @@ Database Database::where(Expr expr) template template -Database Database::join(condition::Join type) +Database& Database::join(condition::Join type) { std::stringstream ss; ss << condition::to_string(type) << " "; @@ -186,7 +186,7 @@ Database Database::join(condition::Join type) template template -Database Database::on(Expr expr) +Database& Database::on(Expr expr) { std::stringstream ss; ss << "ON "; diff --git a/include/klay/db/query-builder/table.hxx b/include/klay/db/query-builder/table.hxx index 68cfff1..8ee466d 100644 --- a/include/klay/db/query-builder/table.hxx +++ b/include/klay/db/query-builder/table.hxx @@ -36,24 +36,24 @@ public: using TableType = typename ImplType::TableType; template - Self select(ColumnTypes&&... cts); + Self& select(ColumnTypes&&... cts); template - Self select(Distinct distinct); + Self& select(Distinct distinct); - Self selectAll(void); + Self& selectAll(void); template - Self update(ColumnTypes&&... cts); + Self& update(ColumnTypes&&... cts); template - Self insert(ColumnTypes&&... cts); + Self& insert(ColumnTypes&&... cts); template - Self remove(ColumnTypes&&... cts); + Self& remove(ColumnTypes&&... cts); template - Self where(Expr expr); + Self& where(Expr expr); template bool compare(const That& that) const noexcept; @@ -72,7 +72,7 @@ private: friend Table make_table(const std::string& name, Cs&& ...columns); template - Self selectInternal(ColumnTuple&& ct, bool distinct = false); + Self& selectInternal(ColumnTuple&& ct, bool distinct = false); template std::vector getColumnNames(Cs&& tuple); @@ -122,7 +122,7 @@ Table::Table(const std::string& name, ImplType&& impl) template template -Table Table::select(ColumnTypes&&... cts) +Table& Table::select(ColumnTypes&&... cts) { auto columnTuple = std::make_tuple(std::forward(cts)...); @@ -131,14 +131,14 @@ Table Table::select(ColumnTypes&&... cts) template template -Table Table::select(Distinct distinct) +Table& Table::select(Distinct distinct) { return this->selectInternal(std::move(distinct.value), true); } template template -Table Table::selectInternal(ColumnTuple&& ct, bool distinct) +Table& Table::selectInternal(ColumnTuple&& ct, bool distinct) { this->cache.clear(); @@ -166,7 +166,7 @@ Table Table::selectInternal(ColumnTuple&& ct, bool disti } template -Table Table::selectAll(void) +Table& Table::selectAll(void) { this->cache.clear(); @@ -180,7 +180,7 @@ Table Table::selectAll(void) template template -Table Table::update(ColumnTypes&&... cts) +Table& Table::update(ColumnTypes&&... cts) { this->cache.clear(); @@ -206,7 +206,7 @@ Table Table::update(ColumnTypes&&... cts) template template -Table Table::insert(ColumnTypes&&... cts) +Table& Table::insert(ColumnTypes&&... cts) { this->cache.clear(); @@ -240,7 +240,7 @@ Table Table::insert(ColumnTypes&&... cts) template template -Table Table::remove(ColumnTypes&&... cts) +Table& Table::remove(ColumnTypes&&... cts) { this->cache.clear(); @@ -257,7 +257,7 @@ Table Table::remove(ColumnTypes&&... cts) template template -Table Table::where(Expr expr) +Table& Table::where(Expr expr) { std::stringstream ss; ss << "WHERE " << this->processWhere(expr);