-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve execute many and fix GCC 9 Build by explicitly scoping SQLite…
- Loading branch information
1 parent
a637d24
commit 3ba20a3
Showing
3 changed files
with
16 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* @ingroup SQLiteCpp | ||
* @brief Convenience function to execute a Statement with multiple Parameter sets | ||
* | ||
* Copyright (c) 2019 Maximilian Bachmann (github maxbachmann) | ||
* Copyright (c) 2019 Maximilian Bachmann (contact@maxbachmann.de) | ||
* Copyright (c) 2019 Sebastien Rombauts ([email protected]) | ||
* | ||
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt | ||
|
@@ -33,8 +33,8 @@ namespace SQLite | |
* | ||
* \code{.cpp} | ||
* execute_many(db, "INSERT INTO test VALUES (?, ?)", | ||
* std::make_tuple(1, "one"), | ||
* std::make_tuple(2, "two"), | ||
* 1, | ||
* std::make_tuple(2), | ||
* std::make_tuple(3, "three") | ||
* ); | ||
* \endcode | ||
|
@@ -47,10 +47,10 @@ template <typename Arg, typename... Types> | |
void execute_many(Database& aDatabase, const char* apQuery, Arg&& aArg, Types&&... aParams) | ||
{ | ||
SQLite::Statement query(aDatabase, apQuery); | ||
bind_exec(query, std::forward<decltype(aArg)>(aArg)); | ||
bind_exec(query, std::forward<Arg>(aArg)); | ||
(void)std::initializer_list<int> | ||
{ | ||
((void)reset_bind_exec(query, std::forward<decltype(aParams)>(aParams)), 0)... | ||
((void)reset_bind_exec(query, std::forward<Types>(aParams)), 0)... | ||
}; | ||
} | ||
|
||
|
@@ -63,11 +63,11 @@ void execute_many(Database& aDatabase, const char* apQuery, Arg&& aArg, Types&&. | |
* @param apQuery Query to use | ||
* @param aTuple Tuple to bind | ||
*/ | ||
template <typename ... Types> | ||
void reset_bind_exec(SQLite::Statement& apQuery, std::tuple<Types...>&& aTuple) | ||
template <typename TupleT> | ||
void reset_bind_exec(Statement& apQuery, TupleT&& aTuple) | ||
{ | ||
apQuery.reset(); | ||
bind_exec(apQuery, std::forward<decltype(aTuple)>(aTuple)); | ||
bind_exec(apQuery, std::forward<TupleT>(aTuple)); | ||
} | ||
|
||
/** | ||
|
@@ -78,10 +78,10 @@ void reset_bind_exec(SQLite::Statement& apQuery, std::tuple<Types...>&& aTuple) | |
* @param apQuery Query to use | ||
* @param aTuple Tuple to bind | ||
*/ | ||
template <typename ... Types> | ||
void bind_exec(SQLite::Statement& apQuery, std::tuple<Types...>&& aTuple) | ||
template <typename TupleT> | ||
void bind_exec(Statement& apQuery, TupleT&& aTuple) | ||
{ | ||
bind(apQuery, std::forward<decltype(aTuple)>(aTuple)); | ||
SQLite::bind(apQuery, std::forward<TupleT>(aTuple)); | ||
while (apQuery.executeStep()) {} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* | ||
* Copyright (c) 2016 Paul Dreik ([email protected]) | ||
* Copyright (c) 2016-2019 Sebastien Rombauts ([email protected]) | ||
* Copyright (c) 2019 Maximilian Bachmann (github maxbachmann) | ||
* Copyright (c) 2019 Maximilian Bachmann (contact@maxbachmann.de) | ||
* | ||
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt | ||
* or copy at http://opensource.org/licenses/MIT) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* @ingroup tests | ||
* @brief Test of variadic bind | ||
* | ||
* Copyright (c) 2019 Maximilian Bachmann (github@maxbachmann) | ||
* Copyright (c) 2019 Maximilian Bachmann (contact@maxbachmann.de) | ||
* Copyright (c) 2019 Sebastien Rombauts ([email protected]) | ||
* | ||
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt | ||
|
@@ -29,8 +29,8 @@ TEST(ExecuteMany, invalid) | |
EXPECT_TRUE(db.tableExists("test")); | ||
{ | ||
execute_many(db, "INSERT INTO test VALUES (?, ?)", | ||
std::make_tuple(1), | ||
std::make_tuple(2, "two"), | ||
1, | ||
std::make_tuple(2), | ||
std::make_tuple(3, "three") | ||
); | ||
} | ||
|
@@ -47,7 +47,7 @@ TEST(ExecuteMany, invalid) | |
EXPECT_EQ(std::size_t(3), results.size()); | ||
|
||
EXPECT_EQ(std::make_pair(1,std::string{""}), results.at(0)); | ||
EXPECT_EQ(std::make_pair(2,std::string{"two"}), results.at(1)); | ||
EXPECT_EQ(std::make_pair(2,std::string{""}), results.at(1)); | ||
EXPECT_EQ(std::make_pair(3,std::string{"three"}), results.at(2)); | ||
} | ||
} | ||
|