Cleaning up static asserts for .where(true)

This commit is contained in:
rbock
2016-02-27 19:31:02 +01:00
parent 8079015d2c
commit f774dca912
2 changed files with 22 additions and 30 deletions

View File

@@ -217,9 +217,9 @@ namespace sqlpp
SQLPP_PORTABLE_STATIC_ASSERT(assert_where_t, "calling where() or uncontionally() required");
SQLPP_PORTABLE_STATIC_ASSERT(assert_where_expressions_t,
"at least one argument is not a boolean expression in where()");
SQLPP_PORTABLE_STATIC_ASSERT(assert_where_boolean_t, "at least one argument is not a boolean expression in where()");
SQLPP_PORTABLE_STATIC_ASSERT(assert_where_boolean_expression_t,
"at least one argument is not a sqlpp::boolean expression in where(). Please use "
".unconditionally() instead of .where(true), or sqlpp::value(bool)");
SQLPP_PORTABLE_STATIC_ASSERT(assert_where_no_aggregate_functions_t,
"at least one aggregate function used in where()");
SQLPP_PORTABLE_STATIC_ASSERT(assert_where_static_count_args_t, "missing argument in where()");
@@ -230,8 +230,9 @@ namespace sqlpp
// https://connect.microsoft.com/VisualStudio/feedback/details/2173198
// template <typename... Expressions>
// using check_where_t = static_combined_check_t<
// static_check_t<logic::all_t<is_expression_t<Expressions>::value...>::value, assert_where_expressions_t>,
// static_check_t<logic::all_t<is_boolean_t<Expressions>::value...>::value, assert_where_boolean_t>,
// static_check_t<logic::all_t<is_expression_t<Expressions>::value...>::value,
// assert_where_boolean_expressions_t>,
// static_check_t<logic::all_t<is_boolean_t<Expressions>::value...>::value, assert_where_boolean_expression_t>,
// static_check_t<logic::all_t<(not contains_aggregate_function_t<Expressions>::value)...>::value,
// assert_where_no_aggregate_functions_t>>;
template <typename... Expressions>
@@ -239,8 +240,8 @@ namespace sqlpp
{
using type = static_combined_check_t<
static_check_t<logic::all_t<detail::is_expression_impl<Expressions>::type::value...>::value,
assert_where_expressions_t>,
static_check_t<logic::all_t<is_boolean_t<Expressions>::value...>::value, assert_where_boolean_t>,
assert_where_boolean_expression_t>,
static_check_t<logic::all_t<is_boolean_t<Expressions>::value...>::value, assert_where_boolean_expression_t>,
static_check_t<logic::all_t<(not detail::contains_aggregate_function_impl<Expressions>::type::value)...>::value,
assert_where_no_aggregate_functions_t>>;
};
@@ -328,15 +329,6 @@ namespace sqlpp
assert_where_t,
consistent_t>::type;
template <typename T = void>
auto where(bool) const -> bad_statement
{
static_assert(wrong_t<T>::value,
".where(bool) is not allowed any more. Please use unconditionally() to replace "
".where(true). Use sqlpp::value(bool) if you really want to use a bool here");
return {};
}
auto unconditionally() const -> _new_statement_t<std::true_type, where_t<void, unconditional_t>>
{
return {static_cast<const derived_statement_t<Policies>&>(*this), where_data_t<void, unconditional_t>{}};