Skip to content

Commit 3ba20a3

Browse files
maxbachmannSRombauts
authored andcommitted
Improve execute many and fix GCC 9 Build by explicitly scoping SQLiteCpp::bind()
Fix SRombauts#206 SRombauts#207
1 parent a637d24 commit 3ba20a3

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

include/SQLiteCpp/ExecuteMany.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @ingroup SQLiteCpp
44
* @brief Convenience function to execute a Statement with multiple Parameter sets
55
*
6-
* Copyright (c) 2019 Maximilian Bachmann (github maxbachmann)
6+
* Copyright (c) 2019 Maximilian Bachmann (contact@maxbachmann.de)
77
* Copyright (c) 2019 Sebastien Rombauts ([email protected])
88
*
99
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
@@ -33,8 +33,8 @@ namespace SQLite
3333
*
3434
* \code{.cpp}
3535
* execute_many(db, "INSERT INTO test VALUES (?, ?)",
36-
* std::make_tuple(1, "one"),
37-
* std::make_tuple(2, "two"),
36+
* 1,
37+
* std::make_tuple(2),
3838
* std::make_tuple(3, "three")
3939
* );
4040
* \endcode
@@ -47,10 +47,10 @@ template <typename Arg, typename... Types>
4747
void execute_many(Database& aDatabase, const char* apQuery, Arg&& aArg, Types&&... aParams)
4848
{
4949
SQLite::Statement query(aDatabase, apQuery);
50-
bind_exec(query, std::forward<decltype(aArg)>(aArg));
50+
bind_exec(query, std::forward<Arg>(aArg));
5151
(void)std::initializer_list<int>
5252
{
53-
((void)reset_bind_exec(query, std::forward<decltype(aParams)>(aParams)), 0)...
53+
((void)reset_bind_exec(query, std::forward<Types>(aParams)), 0)...
5454
};
5555
}
5656

@@ -63,11 +63,11 @@ void execute_many(Database& aDatabase, const char* apQuery, Arg&& aArg, Types&&.
6363
* @param apQuery Query to use
6464
* @param aTuple Tuple to bind
6565
*/
66-
template <typename ... Types>
67-
void reset_bind_exec(SQLite::Statement& apQuery, std::tuple<Types...>&& aTuple)
66+
template <typename TupleT>
67+
void reset_bind_exec(Statement& apQuery, TupleT&& aTuple)
6868
{
6969
apQuery.reset();
70-
bind_exec(apQuery, std::forward<decltype(aTuple)>(aTuple));
70+
bind_exec(apQuery, std::forward<TupleT>(aTuple));
7171
}
7272

7373
/**
@@ -78,10 +78,10 @@ void reset_bind_exec(SQLite::Statement& apQuery, std::tuple<Types...>&& aTuple)
7878
* @param apQuery Query to use
7979
* @param aTuple Tuple to bind
8080
*/
81-
template <typename ... Types>
82-
void bind_exec(SQLite::Statement& apQuery, std::tuple<Types...>&& aTuple)
81+
template <typename TupleT>
82+
void bind_exec(Statement& apQuery, TupleT&& aTuple)
8383
{
84-
bind(apQuery, std::forward<decltype(aTuple)>(aTuple));
84+
SQLite::bind(apQuery, std::forward<TupleT>(aTuple));
8585
while (apQuery.executeStep()) {}
8686
}
8787

include/SQLiteCpp/VariadicBind.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright (c) 2016 Paul Dreik ([email protected])
77
* Copyright (c) 2016-2019 Sebastien Rombauts ([email protected])
8-
* Copyright (c) 2019 Maximilian Bachmann (github maxbachmann)
8+
* Copyright (c) 2019 Maximilian Bachmann (contact@maxbachmann.de)
99
*
1010
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
1111
* or copy at http://opensource.org/licenses/MIT)

tests/ExecuteMany_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @ingroup tests
44
* @brief Test of variadic bind
55
*
6-
* Copyright (c) 2019 Maximilian Bachmann (github@maxbachmann)
6+
* Copyright (c) 2019 Maximilian Bachmann (contact@maxbachmann.de)
77
* Copyright (c) 2019 Sebastien Rombauts ([email protected])
88
*
99
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
@@ -29,8 +29,8 @@ TEST(ExecuteMany, invalid)
2929
EXPECT_TRUE(db.tableExists("test"));
3030
{
3131
execute_many(db, "INSERT INTO test VALUES (?, ?)",
32-
std::make_tuple(1),
33-
std::make_tuple(2, "two"),
32+
1,
33+
std::make_tuple(2),
3434
std::make_tuple(3, "three")
3535
);
3636
}
@@ -47,7 +47,7 @@ TEST(ExecuteMany, invalid)
4747
EXPECT_EQ(std::size_t(3), results.size());
4848

4949
EXPECT_EQ(std::make_pair(1,std::string{""}), results.at(0));
50-
EXPECT_EQ(std::make_pair(2,std::string{"two"}), results.at(1));
50+
EXPECT_EQ(std::make_pair(2,std::string{""}), results.at(1));
5151
EXPECT_EQ(std::make_pair(3,std::string{"three"}), results.at(2));
5252
}
5353
}

0 commit comments

Comments
 (0)