diff --git a/include/sqlpp11/detail/logic.h b/include/sqlpp11/detail/logic.h index 3cc8a208..a533a4ee 100644 --- a/include/sqlpp11/detail/logic.h +++ b/include/sqlpp11/detail/logic.h @@ -39,23 +39,23 @@ namespace sqlpp template<> struct all_impl<> { - static constexpr bool value = true; + using type = std::true_type; }; template struct all_impl { - static constexpr bool value = all_impl::value; + using type = typename all_impl::type; }; template struct all_impl { - static constexpr bool value = false; + using type = std::false_type; }; template class Predicate, typename... T> - using all_t = all_impl::value...>; + using all_t = typename all_impl::value...>::type; template struct any_impl; @@ -63,24 +63,27 @@ namespace sqlpp template<> struct any_impl<> { - static constexpr bool value = false; + using type = std::false_type; }; template struct any_impl { - static constexpr bool value = any_impl::value; + using type = typename all_impl::type; }; template struct any_impl { - static constexpr bool value = true; + using type = std::true_type; }; template class Predicate, typename... T> - using any_t = any_impl::value...>; + using any_t = typename any_impl::value...>::type; + + template + using identity_t = T; } } diff --git a/include/sqlpp11/detail/type_set.h b/include/sqlpp11/detail/type_set.h index 51a2df20..7c4d15b7 100644 --- a/include/sqlpp11/detail/type_set.h +++ b/include/sqlpp11/detail/type_set.h @@ -145,6 +145,9 @@ namespace sqlpp using type = typename make_type_set::type::template insert::type; }; + template + using make_type_set_t = typename make_type_set::type; + template class Predicate, typename... T> struct make_type_set_if; diff --git a/include/sqlpp11/select.h b/include/sqlpp11/select.h index 925b6186..d1d194a5 100644 --- a/include/sqlpp11/select.h +++ b/include/sqlpp11/select.h @@ -99,7 +99,7 @@ namespace sqlpp template struct _policies_update_impl { -#warning: Need to make sure that Needle is in Policies! + static_assert(detail::is_element_of>::value, "policies update for non-policy class detected"); using type = select_t...>; }; diff --git a/include/sqlpp11/vendor/from.h b/include/sqlpp11/vendor/from.h index 9a354bc8..99bb15dd 100644 --- a/include/sqlpp11/vendor/from.h +++ b/include/sqlpp11/vendor/from.h @@ -70,10 +70,23 @@ namespace sqlpp template void add_from(Table table) { - static_assert(is_table_t::value, "invalid expression argument in add_from()"); -#warning: Need to dispatch to actual add method to prevent error messages from being generated + static_assert(_is_dynamic::value, "add_from must not be called for static from()"); + static_assert(is_table_t
::value, "invalid table argument in add_from()"); + + using ok = ::sqlpp::detail::all_t>; + + _add_from_impl(table, ok()); // dispatch to prevent compile messages after the static_assert + } + + private: + template + void _add_from_impl(Table table, const std::true_type&) + { return static_cast(this)->_from._dynamic_tables.emplace_back(table); } + + template + void _add_from_impl(Table table, const std::false_type&); }; std::tuple _tables; diff --git a/include/sqlpp11/vendor/group_by.h b/include/sqlpp11/vendor/group_by.h index b4764179..ceb78c22 100644 --- a/include/sqlpp11/vendor/group_by.h +++ b/include/sqlpp11/vendor/group_by.h @@ -73,9 +73,21 @@ namespace sqlpp { static_assert(_is_dynamic::value, "add_group_by must not be called for static group_by"); static_assert(is_expression_t::value, "invalid expression argument in add_group_by()"); -#warning: Need to dispatch to actual add method to prevent error messages from being generated + + using ok = ::sqlpp::detail::all_t>; + + _add_group_by_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert + } + + private: + template + void _add_group_by_impl(Expression expression, const std::true_type&) + { return static_cast(this)->_group_by._dynamic_expressions.emplace_back(expression); } + + template + void _add_group_by_impl(Expression expression, const std::false_type&); }; const group_by_t& _group_by() const { return *this; } diff --git a/include/sqlpp11/vendor/having.h b/include/sqlpp11/vendor/having.h index 921ceffa..b88c60d0 100644 --- a/include/sqlpp11/vendor/having.h +++ b/include/sqlpp11/vendor/having.h @@ -71,9 +71,21 @@ namespace sqlpp { static_assert(_is_dynamic::value, "add_having must not be called for static having"); static_assert(is_expression_t::value, "invalid expression argument in add_having()"); -#warning: Need to dispatch to actual add method to prevent error messages from being generated + + using ok = ::sqlpp::detail::all_t>; + + _add_having_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert + } + + private: + template + void _add_having_impl(Expression expression, const std::true_type&) + { return static_cast(this)->_having._dynamic_expressions.emplace_back(expression); } + + template + void _add_having_impl(Expression expression, const std::false_type&); }; _parameter_tuple_t _expressions; diff --git a/include/sqlpp11/vendor/order_by.h b/include/sqlpp11/vendor/order_by.h index 8cf3583a..41fdb5b0 100644 --- a/include/sqlpp11/vendor/order_by.h +++ b/include/sqlpp11/vendor/order_by.h @@ -72,9 +72,21 @@ namespace sqlpp { static_assert(_is_dynamic::value, "add_order_by must not be called for static order_by"); static_assert(is_sort_order_t::value, "invalid expression argument in add_order_by()"); -#warning: Need to dispatch to actual add method to prevent error messages from being generated + + using ok = ::sqlpp::detail::all_t>; + + _add_order_by_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert + } + + private: + template + void _add_order_by_impl(Expression expression, const std::true_type&) + { return static_cast(this)->_order_by._dynamic_expressions.emplace_back(expression); } + + template + void _add_order_by_impl(Expression expression, const std::false_type&); }; _parameter_tuple_t _expressions; diff --git a/include/sqlpp11/vendor/select_column_list.h b/include/sqlpp11/vendor/select_column_list.h index 9d22d10f..34e7b9e5 100644 --- a/include/sqlpp11/vendor/select_column_list.h +++ b/include/sqlpp11/vendor/select_column_list.h @@ -194,9 +194,21 @@ namespace sqlpp { static_assert(_is_dynamic::value, "add_column can only be called for dynamic_column"); static_assert(is_named_expression_t::value, "invalid named expression argument in add_column()"); -#warning: Need to dispatch to actual add method to prevent error messages from being generated + + using ok = ::sqlpp::detail::all_t>; + + _add_column_impl(namedExpression, ok()); // dispatch to prevent compile messages after the static_assert + } + + private: + template + void _add_column_impl(NamedExpression namedExpression, const std::true_type&) + { return static_cast(this)->_column_list._dynamic_columns.emplace_back(namedExpression); } + + template + void _add_column_impl(NamedExpression namedExpression, const std::false_type&); }; diff --git a/include/sqlpp11/vendor/select_flag_list.h b/include/sqlpp11/vendor/select_flag_list.h index 1c8b2c33..9e63819c 100644 --- a/include/sqlpp11/vendor/select_flag_list.h +++ b/include/sqlpp11/vendor/select_flag_list.h @@ -69,9 +69,21 @@ namespace sqlpp { static_assert(_is_dynamic::value, "add_flag must not be called for static select flags"); static_assert(is_select_flag_t::value, "invalid select flag argument in add_flag()"); -#warning: Need to dispatch to actual add method to prevent error messages from being generated + + using ok = ::sqlpp::detail::all_t>; + + _add_flag_impl(flag, ok()); // dispatch to prevent compile messages after the static_assert + } + + private: + template + void _add_flag_impl(Flag flag, const std::true_type&) + { return static_cast(this)->_flag_list._dynamic_flags.emplace_back(flag); } + + template + void _add_flag_impl(Flag flag, const std::false_type&); }; const select_flag_list_t& _flag_list() const { return *this; } diff --git a/include/sqlpp11/vendor/where.h b/include/sqlpp11/vendor/where.h index b82f4e6e..1ec7622f 100644 --- a/include/sqlpp11/vendor/where.h +++ b/include/sqlpp11/vendor/where.h @@ -72,9 +72,21 @@ namespace sqlpp { static_assert(_is_dynamic::value, "add_where can only be called for dynamic_where"); static_assert(is_expression_t::value, "invalid expression argument in add_where()"); -#warning: Need to dispatch to actual add method to prevent error messages from being generated + + using ok = ::sqlpp::detail::all_t>; + + _add_where_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert + } + + private: + template + void _add_where_impl(Expression expression, const std::true_type&) + { return static_cast(this)->_where._dynamic_expressions.emplace_back(expression); } + + template + void _add_where_impl(Expression expression, const std::false_type&); }; _parameter_tuple_t _expressions;