From 2cafb562666e62fd7d56a7d5a85a48ffd59e8e45 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 4 Sep 2016 10:44:14 +0200 Subject: [PATCH] Improved a few assert wrapper names --- include/sqlpp11/having.h | 2 +- include/sqlpp11/where.h | 31 ++++++++------- test_static_asserts/having.cpp | 2 +- test_static_asserts/unwrapped_bool.cpp | 2 +- test_static_asserts/where.cpp | 52 +++++++++++++------------- tests/Update.cpp | 6 +-- 6 files changed, 49 insertions(+), 46 deletions(-) diff --git a/include/sqlpp11/having.h b/include/sqlpp11/having.h index f8e0cfb7..a5fcfa6c 100644 --- a/include/sqlpp11/having.h +++ b/include/sqlpp11/having.h @@ -264,7 +264,7 @@ namespace sqlpp return _having_impl<_database_t>(Check{}, expression); } - auto dynamic_having() const -> _new_statement_t, + auto dynamic_having() const -> _new_statement_t, having_t<_database_t, boolean_operand>> { return dynamic_having(::sqlpp::value(true)); diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index c77af5d3..516841e7 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -209,16 +209,17 @@ namespace sqlpp }; }; - SQLPP_PORTABLE_STATIC_ASSERT(assert_where_t, "calling where() or unconditionally() required"); + SQLPP_PORTABLE_STATIC_ASSERT(assert_where_or_unconditionally_called_t, + "calling where() or unconditionally() required"); - SQLPP_PORTABLE_STATIC_ASSERT(assert_where_not_cpp_bool_t, + SQLPP_PORTABLE_STATIC_ASSERT(assert_where_arg_is_not_cpp_bool_t, "where() argument has to be an sqlpp boolean expression. Please use " ".unconditionally() instead of .where(true), or sqlpp::value(bool)"); - SQLPP_PORTABLE_STATIC_ASSERT(assert_where_boolean_expression_t, + SQLPP_PORTABLE_STATIC_ASSERT(assert_where_arg_is_boolean_expression_t, "where() argument has to be an sqlpp boolean expression."); - SQLPP_PORTABLE_STATIC_ASSERT(assert_where_no_aggregate_functions_t, + SQLPP_PORTABLE_STATIC_ASSERT(assert_where_arg_contains_no_aggregate_functions_t, "at least one aggregate function used in where()"); - SQLPP_PORTABLE_STATIC_ASSERT(assert_where_dynamic_statement_dynamic_t, + SQLPP_PORTABLE_STATIC_ASSERT(assert_where_dynamic_used_with_dynamic_statement_t, "dynamic_where() must not be called in a static statement"); // workaround for msvc bugs https://connect.microsoft.com/VisualStudio/Feedback/Details/2086629 & @@ -226,20 +227,22 @@ namespace sqlpp // template // using check_where_t = static_combined_check_t< // static_check_t::value...>::value, - // assert_where_not_cpp_bool_t>, + // assert_where_arg_is_not_cpp_bool_t>, // static_check_t::value...>::value, // assert_where_boolean_expressions_t>, - // static_check_t::value...>::value, assert_where_boolean_expression_t>, + // static_check_t::value...>::value, + // assert_where_arg_is_boolean_expression_t>, // static_check_t::value)...>::value, - // assert_where_no_aggregate_functions_t>>; + // assert_where_arg_contains_no_aggregate_functions_t>>; template struct check_where { using type = static_combined_check_t< - static_check_t::value, assert_where_not_cpp_bool_t>, - static_check_t::value, assert_where_boolean_expression_t>, - static_check_t::value, assert_where_boolean_expression_t>, - static_check_t::value, assert_where_no_aggregate_functions_t>>; + static_check_t::value, assert_where_arg_is_not_cpp_bool_t>, + static_check_t::value, assert_where_arg_is_boolean_expression_t>, + static_check_t::value, assert_where_arg_is_boolean_expression_t>, + static_check_t::value, + assert_where_arg_contains_no_aggregate_functions_t>>; }; template @@ -250,7 +253,7 @@ namespace sqlpp template using check_where_dynamic_t = static_combined_check_t< - static_check_t::value, assert_where_dynamic_statement_dynamic_t>, + static_check_t::value, assert_where_dynamic_used_with_dynamic_statement_t>, check_where_t>; // NO WHERE YET @@ -311,7 +314,7 @@ namespace sqlpp using _consistency_check = typename std::conditional 0), - assert_where_t, + assert_where_or_unconditionally_called_t, consistent_t>::type; auto unconditionally() const -> _new_statement_t> diff --git a/test_static_asserts/having.cpp b/test_static_asserts/having.cpp index d7d9bc1b..fac7d24f 100644 --- a/test_static_asserts/having.cpp +++ b/test_static_asserts/having.cpp @@ -138,7 +138,7 @@ namespace static_assert(ExpectedCheckResult::value, "Unexpected check result"); using ReturnType = decltype(select(all_of(t)).from(t).dynamic_having()); - using ExpectedReturnType = std::is_same; + using ExpectedReturnType = std::is_same; print_type_on_error(ExpectedReturnType{}); static_assert(ExpectedReturnType::value, "Unexpected return type"); } diff --git a/test_static_asserts/unwrapped_bool.cpp b/test_static_asserts/unwrapped_bool.cpp index fe190c75..245f5014 100644 --- a/test_static_asserts/unwrapped_bool.cpp +++ b/test_static_asserts/unwrapped_bool.cpp @@ -103,7 +103,7 @@ namespace void where() { where_check(t.gamma); - where_check(true); + where_check(true); } } diff --git a/test_static_asserts/where.cpp b/test_static_asserts/where.cpp index 360a782c..e437d2f8 100644 --- a/test_static_asserts/where.cpp +++ b/test_static_asserts/where.cpp @@ -79,26 +79,26 @@ namespace where_static_check(t.gamma == true); // Try assignment as condition - where_static_check(t.gamma = true); + where_static_check(t.gamma = true); // Try non-boolean expression - where_static_check(t.alpha); + where_static_check(t.alpha); // Try builtin bool - where_static_check(true); - where_static_check(17 > 3); + where_static_check(true); + where_static_check(17 > 3); // Try some other types as expressions - where_static_check("true"); - where_static_check(17); - where_static_check('c'); - where_static_check(nullptr); - where_static_check(t.alpha.as(t.beta)); + where_static_check("true"); + where_static_check(17); + where_static_check('c'); + where_static_check(nullptr); + where_static_check(t.alpha.as(t.beta)); // Try using aggregate functions in where - where_static_check(count(t.alpha) > 0); - where_static_check(t.gamma and count(t.alpha) > 0); - where_static_check( + where_static_check(count(t.alpha) > 0); + where_static_check(t.gamma and count(t.alpha) > 0); + where_static_check( case_when(count(t.alpha) > 0).then(t.gamma).else_(not t.gamma)); } @@ -109,36 +109,36 @@ namespace where_dynamic_check(t.gamma == true); // Try assignment as condition - where_dynamic_check(t.gamma = true); + where_dynamic_check(t.gamma = true); // Try non-boolean expression - where_dynamic_check(t.alpha); + where_dynamic_check(t.alpha); // Try builtin bool - where_dynamic_check(true); - where_dynamic_check(17 > 3); + where_dynamic_check(true); + where_dynamic_check(17 > 3); // Try some other types as expressions - where_dynamic_check("true"); - where_dynamic_check(17); - where_dynamic_check('c'); - where_dynamic_check(nullptr); - where_dynamic_check(t.alpha.as(t.beta)); + where_dynamic_check("true"); + where_dynamic_check(17); + where_dynamic_check('c'); + where_dynamic_check(nullptr); + where_dynamic_check(t.alpha.as(t.beta)); // Try using aggregate functions in where - where_dynamic_check(count(t.alpha) > 0); - where_dynamic_check(t.gamma and count(t.alpha) > 0); - where_dynamic_check( + where_dynamic_check(count(t.alpha) > 0); + where_dynamic_check(t.gamma and count(t.alpha) > 0); + where_dynamic_check( case_when(count(t.alpha) > 0).then(t.gamma).else_(not t.gamma)); // Try dynamic_where on a non-dynamic remove using CheckResult = sqlpp::check_where_dynamic_t; - using ExpectedCheckResult = std::is_same; + using ExpectedCheckResult = std::is_same; print_type_on_error(ExpectedCheckResult{}); static_assert(ExpectedCheckResult::value, "Unexpected check result"); using ReturnType = decltype(remove_from(t).dynamic_where()); - using ExpectedReturnType = std::is_same; + using ExpectedReturnType = std::is_same; print_type_on_error(ExpectedReturnType{}); static_assert(ExpectedReturnType::value, "Unexpected return type"); } diff --git a/tests/Update.cpp b/tests/Update.cpp index f02e2ae0..7a4bf569 100644 --- a/tests/Update.cpp +++ b/tests/Update.cpp @@ -23,11 +23,11 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "MockDb.h" +#include "Sample.h" +#include "is_regular.h" #include #include -#include "Sample.h" -#include "MockDb.h" -#include "is_regular.h" int Update(int, char* []) {