mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-06 05:00:37 -06:00
Fixed parameter determination and added execution of void statements
This commit is contained in:
@@ -55,6 +55,16 @@ namespace sqlpp
|
||||
using _traits = make_traits<no_value_t>;
|
||||
using _recursive_traits = make_recursive_traits<Parts...>;
|
||||
|
||||
custom_query_t(Parts... parts):
|
||||
_parts(parts...)
|
||||
{}
|
||||
|
||||
custom_query_t(const custom_query_t&) = default;
|
||||
custom_query_t(custom_query_t&&) = default;
|
||||
custom_query_t& operator=(const custom_query_t&) = default;
|
||||
custom_query_t& operator=(custom_query_t&&) = default;
|
||||
~custom_query_t() = default;
|
||||
|
||||
static void _check_consistency() {};
|
||||
|
||||
template<typename Db>
|
||||
@@ -69,15 +79,15 @@ namespace sqlpp
|
||||
return _methods_t::_prepare(db, *this);
|
||||
}
|
||||
|
||||
custom_query_t(Parts... parts):
|
||||
_parts(parts...)
|
||||
{}
|
||||
static constexpr size_t _get_static_no_of_parameters()
|
||||
{
|
||||
return std::tuple_size<parameters_of<custom_query_t>>::value;
|
||||
}
|
||||
|
||||
custom_query_t(const custom_query_t&) = default;
|
||||
custom_query_t(custom_query_t&&) = default;
|
||||
custom_query_t& operator=(const custom_query_t&) = default;
|
||||
custom_query_t& operator=(custom_query_t&&) = default;
|
||||
~custom_query_t() = default;
|
||||
size_t _get_no_of_parameters() const
|
||||
{
|
||||
return _get_static_no_of_parameters();
|
||||
}
|
||||
|
||||
std::tuple<Parts...> _parts;
|
||||
};
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace sqlpp
|
||||
-> decltype(db.insert(composite))
|
||||
{
|
||||
Composite::_check_consistency();
|
||||
static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run insert directly with parameters, use prepare instead");
|
||||
static_assert(Composite::_get_static_no_of_parameters() == 0, "cannot run insert directly with parameters, use prepare instead");
|
||||
|
||||
return db.insert(composite);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace sqlpp
|
||||
auto _run(Db& db, const Composite& composite) const -> void
|
||||
{
|
||||
Composite::_check_consistency();
|
||||
static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run execute directly with parameters, use prepare instead");
|
||||
static_assert(Composite::_get_static_no_of_parameters() == 0, "cannot run execute directly with parameters, use prepare instead");
|
||||
|
||||
return db.execute(composite);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace sqlpp
|
||||
-> decltype(db.remove(composite))
|
||||
{
|
||||
Composite::_check_consistency();
|
||||
static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run remove directly with parameters, use prepare instead");
|
||||
static_assert(Composite::_get_static_no_of_parameters() == 0, "cannot run remove directly with parameters, use prepare instead");
|
||||
|
||||
return db.remove(composite);
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ namespace sqlpp
|
||||
-> result_t<decltype(db.select(composite)), _result_row_t<Db>>
|
||||
{
|
||||
Composite::_check_consistency();
|
||||
static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run select directly with parameters, use prepare instead");
|
||||
static_assert(Composite::_get_static_no_of_parameters() == 0, "cannot run select directly with parameters, use prepare instead");
|
||||
|
||||
return {db.select(composite), get_dynamic_names()};
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace sqlpp
|
||||
-> decltype(db.update(composite))
|
||||
{
|
||||
Composite::_check_consistency();
|
||||
static_assert(_statement_t::_get_static_no_of_parameters() == 0, "cannot run update directly with parameters, use prepare instead");
|
||||
static_assert(Composite::_get_static_no_of_parameters() == 0, "cannot run update directly with parameters, use prepare instead");
|
||||
|
||||
return db.update(composite);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user