From e152e291076e9873ed425d0569c44f79ac5cd387 Mon Sep 17 00:00:00 2001 From: rbock Date: Thu, 17 Sep 2015 11:46:37 +0200 Subject: [PATCH] run_check and prepare_check now contain the serialize check --- include/sqlpp11/type_traits.h | 64 +++++++++++++++++++---------------- tests/MockDb.h | 23 +++++-------- 2 files changed, 43 insertions(+), 44 deletions(-) diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 12cf8a22..7ce3e9af 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -321,36 +321,6 @@ namespace sqlpp template using consistency_check_t = typename consistency_check::type; - template - struct run_check - { - using type = assert_run_statement_or_prepared_t; - }; - - template - struct run_check::value or is_prepared_statement_t::value>::type> - { - using type = typename T::_run_check; - }; - - template - using run_check_t = typename run_check::type; - - template - struct prepare_check - { - using type = assert_prepare_statement_t; - }; - - template - struct prepare_check::value>::type> - { - using type = typename T::_prepare_check; - }; - - template - using prepare_check_t = typename prepare_check::type; - template struct serialize_check { @@ -366,6 +336,40 @@ namespace sqlpp template using serialize_check_t = typename serialize_check::type; + template + struct run_check + { + using type = assert_run_statement_or_prepared_t; + }; + + template + struct run_check::value or is_prepared_statement_t::value>::type> + { + using type = + detail::get_first_if>; + }; + + template + using run_check_t = typename run_check::type; + + template + struct prepare_check + { + using type = assert_prepare_statement_t; + }; + + template + struct prepare_check::value>::type> + { + using type = detail:: + get_first_if>; + }; + + template + using prepare_check_t = typename prepare_check::type; + template struct has_result_row_impl { diff --git a/tests/MockDb.h b/tests/MockDb.h index 1b6c405b..88a1c47a 100644 --- a/tests/MockDb.h +++ b/tests/MockDb.h @@ -115,16 +115,13 @@ struct MockDbT : public sqlpp::connection } template - auto _run(const T& t, const std::false_type&) -> decltype(t._run(*this)); + auto _run(const T& t, const std::false_type&) -> void; template - auto operator()(const T& t) -> decltype(t._run(*this)) + auto operator()(const T& t) -> decltype(this->_run(t, typename sqlpp::run_check_t<_serializer_context_t, T>::type{})) { - sqlpp::run_check_t::_(); - sqlpp::serialize_check_t<_serializer_context_t, T>::_(); - using _ok = sqlpp::logic::all_t::type::value, - sqlpp::serialize_check_t<_serializer_context_t, T>::type::value>; - return _run(t, _ok{}); + sqlpp::run_check_t<_serializer_context_t, T>::_(); + return _run(t, typename sqlpp::run_check_t<_serializer_context_t, T>::type{}); } size_t execute(const std::string&) @@ -189,16 +186,14 @@ struct MockDbT : public sqlpp::connection } template - auto _prepare(const T& t, const std::false_type&) -> decltype(t._prepare(*this)); + auto _prepare(const T& t, const std::false_type&) -> void; template - auto prepare(const T& t) -> decltype(t._prepare(*this)) + auto prepare(const T& t) + -> decltype(this->_prepare(t, typename sqlpp::prepare_check_t<_serializer_context_t, T>::type{})) { - sqlpp::prepare_check_t::_(); - sqlpp::serialize_check_t<_serializer_context_t, T>::_(); - using _ok = sqlpp::logic::all_t::type::value, - sqlpp::serialize_check_t<_serializer_context_t, T>::type::value>; - return _prepare(t, _ok{}); + sqlpp::prepare_check_t<_serializer_context_t, T>::_(); + return _prepare(t, typename sqlpp::prepare_check_t<_serializer_context_t, T>::type{}); } template