mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +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
@ -372,14 +372,28 @@ namespace sqlpp
|
||||
return static_cast<size_t>(sqlite3_changes(native_handle()));
|
||||
}
|
||||
|
||||
template <
|
||||
typename Execute,
|
||||
typename Enable = typename std::enable_if<not std::is_convertible<Execute, std::string>::value, void>::type>
|
||||
size_t execute(const Execute& x)
|
||||
{
|
||||
_context_t context{*this};
|
||||
serialize(x, context);
|
||||
return execute(context.str());
|
||||
template <
|
||||
typename Execute,
|
||||
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>
|
||||
|
Loading…
Reference in New Issue
Block a user