mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 04:47:18 +08:00
SQLite3: Enable execute() to run prepared_statements
Limit execute to run only non-select statements. (Note: Does not apply to raw sql string select queries).
This commit is contained in:
parent
fc23782369
commit
b99e1b0e7d
@ -374,14 +374,28 @@ namespace sqlpp
|
||||
|
||||
template <
|
||||
typename Execute,
|
||||
typename Enable = typename std::enable_if<not std::is_convertible<Execute, std::string>::value, void>::type>
|
||||
typename std::enable_if<not std::is_convertible<Execute, std::string>::value
|
||||
and not sqlpp::is_prepared_statement_t<Execute>::value, int>::type = 0>
|
||||
size_t execute(const Execute& x)
|
||||
{
|
||||
static_assert(not sqlpp::is_select_t<Execute>::value, "argument must not be a select statement - use operator() instead");
|
||||
|
||||
_context_t context{*this};
|
||||
serialize(x, context);
|
||||
return execute(context.str());
|
||||
}
|
||||
|
||||
template <
|
||||
typename Execute,
|
||||
typename std::enable_if<sqlpp::is_prepared_statement_t<Execute>::value, int>::type = 0>
|
||||
size_t execute(const Execute& x)
|
||||
{
|
||||
static_assert(not sqlpp::is_select_t<Execute>::value, "argument must not be a select statement - use operator() instead");
|
||||
|
||||
operator()(x);
|
||||
return static_cast<size_t>(sqlite3_changes(native_handle()));
|
||||
}
|
||||
|
||||
template <typename Execute>
|
||||
_prepared_statement_t prepare_execute(Execute& x)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user