diff --git a/include/sqlpp11/having.h b/include/sqlpp11/having.h index 8939acd1..367bba6c 100644 --- a/include/sqlpp11/having.h +++ b/include/sqlpp11/having.h @@ -59,6 +59,8 @@ namespace sqlpp assert_no_unknown_tables_in_having_t, "at least one having-expression requires a table which is otherwise not known in the statement"); + SQLPP_PORTABLE_STATIC_ASSERT(assert_no_non_aggregates_t, "having expression not built out of aggregate expressions"); + // HAVING template struct having_t @@ -139,9 +141,15 @@ namespace sqlpp return t.having; } - using _consistency_check = typename std::conditional::value, - consistent_t, - assert_no_unknown_tables_in_having_t>::type; + using _table_check = typename std::conditional::value, + consistent_t, + assert_no_unknown_tables_in_having_t>::type; + + using _aggregate_check = typename std::conditional::value, + consistent_t, + assert_no_non_aggregates_t>::type; + + using _consistency_check = detail::get_first_if; }; }; diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index cf0da031..36ed87a2 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -91,7 +91,7 @@ namespace sqlpp SQLPP_PORTABLE_STATIC_ASSERT( assert_no_unknown_tables_in_selected_columns_t, "at least one selected column requires a table which is otherwise not known in the statement"); - SQLPP_PORTABLE_STATIC_ASSERT(assert_aggregates_t, + SQLPP_PORTABLE_STATIC_ASSERT(assert_no_unknown_aggregates_t, "not all columns are made of aggregates, despite group_by or similar"); // SELECTED COLUMNS @@ -195,16 +195,15 @@ namespace sqlpp return t.selected_columns; } - using _column_check = - typename std::conditional::value, - consistent_t, - assert_no_unknown_tables_in_selected_columns_t>::type; + using _table_check = typename std::conditional::value, + consistent_t, + assert_no_unknown_tables_in_selected_columns_t>::type; using _aggregate_check = typename std::conditional::value, consistent_t, - assert_aggregates_t>::type; + assert_no_unknown_aggregates_t>::type; - using _consistency_check = detail::get_first_if; + using _consistency_check = detail::get_first_if; }; // Result methods diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index f338222b..cc51ca6e 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -93,6 +93,10 @@ namespace sqlpp logic::all_t::type::value...>::value>; + template + using _no_non_aggregates = logic::any_t::type::value...>::value>; + template