mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-07 21:50:34 -06:00
Fixed run_check and prepared_check for custom query and prepared statemtents
This commit is contained in:
@@ -56,6 +56,12 @@ namespace sqlpp
|
||||
using _traits = make_traits<no_value_t>;
|
||||
using _recursive_traits = make_recursive_traits<Parts...>;
|
||||
|
||||
using _parameter_check = typename std::conditional<std::tuple_size<typename _recursive_traits::_parameters>::value == 0,
|
||||
consistent_t, assert_no_parameters_t>::type;
|
||||
using _run_check = detail::get_first_if<is_inconsistent_t, consistent_t,
|
||||
_parameter_check>;
|
||||
using _prepare_check = consistent_t;
|
||||
|
||||
custom_query_t(Parts... parts):
|
||||
_parts(parts...)
|
||||
{}
|
||||
@@ -70,20 +76,17 @@ namespace sqlpp
|
||||
custom_query_t& operator=(custom_query_t&&) = default;
|
||||
~custom_query_t() = default;
|
||||
|
||||
using _consistency_check = consistent_t;
|
||||
|
||||
template<typename Db>
|
||||
auto _run(Db& db) const -> decltype(std::declval<_methods_t>()._run(db, *this))
|
||||
{
|
||||
static_assert(_get_static_no_of_parameters() == 0, "cannot run execute directly with parameters, use prepare instead");
|
||||
_run_check{};
|
||||
_run_check::_();
|
||||
return _methods_t::_run(db, *this);
|
||||
}
|
||||
|
||||
template<typename Db>
|
||||
auto _prepare(Db& db) const -> decltype(std::declval<_methods_t>()._prepare(db, *this))
|
||||
{
|
||||
_prepare_check{};
|
||||
_prepare_check::_();
|
||||
return _methods_t::_prepare(db, *this);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ namespace sqlpp
|
||||
using _parameter_list_t = make_parameter_list_t<Statement>;
|
||||
using _prepared_statement_t = typename Db::_prepared_statement_t;
|
||||
|
||||
using _run_check = consistent_t;
|
||||
|
||||
auto _run(Db& db) const
|
||||
-> void
|
||||
{
|
||||
|
||||
@@ -38,6 +38,8 @@ namespace sqlpp
|
||||
using _parameter_list_t = make_parameter_list_t<Insert>;
|
||||
using _prepared_statement_t = typename Db::_prepared_statement_t;
|
||||
|
||||
using _run_check = consistent_t;
|
||||
|
||||
auto _run(Db& db) const
|
||||
-> size_t
|
||||
{
|
||||
|
||||
@@ -38,6 +38,8 @@ namespace sqlpp
|
||||
using _parameter_list_t = make_parameter_list_t<Remove>;
|
||||
using _prepared_statement_t = typename Db::_prepared_statement_t;
|
||||
|
||||
using _run_check = consistent_t;
|
||||
|
||||
auto _run(Db& db) const
|
||||
-> size_t
|
||||
{
|
||||
|
||||
@@ -40,6 +40,8 @@ namespace sqlpp
|
||||
using _dynamic_names_t = typename Statement::_dynamic_names_t;
|
||||
using _prepared_statement_t = typename Database::_prepared_statement_t;
|
||||
|
||||
using _run_check = consistent_t;
|
||||
|
||||
auto _run(Database& db) const
|
||||
-> result_t<decltype(db.run_prepared_select(*this)), _result_row_t>
|
||||
{
|
||||
|
||||
@@ -38,6 +38,8 @@ namespace sqlpp
|
||||
using _parameter_list_t = make_parameter_list_t<Update>;
|
||||
using _prepared_statement_t = typename Db::_prepared_statement_t;
|
||||
|
||||
using _run_check = consistent_t;
|
||||
|
||||
auto _run(Db& db) const
|
||||
-> size_t
|
||||
{
|
||||
|
||||
@@ -38,12 +38,9 @@ MockDb::_serializer_context_t printer;
|
||||
|
||||
int main()
|
||||
{
|
||||
//test::TabFoo f;
|
||||
test::TabFoo f;
|
||||
test::TabBar t;
|
||||
|
||||
db(select(all_of(t)).from(t));
|
||||
|
||||
#if 0
|
||||
select(t.alpha).flags(sqlpp::all).from(t);
|
||||
for (const auto& row : db(select(all_of(t)).from(t).where(true)))
|
||||
{
|
||||
@@ -101,7 +98,6 @@ int main()
|
||||
std::cerr << serialize(stat, printer).str() << std::endl;
|
||||
|
||||
select(sqlpp::value(7).as(t.alpha));
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user