mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-08 22:21:00 -06:00
Enforce having expression to consist of aggregates
This commit is contained in:
@@ -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 <typename Database, typename Expression>
|
||||
struct having_t
|
||||
@@ -139,9 +141,15 @@ namespace sqlpp
|
||||
return t.having;
|
||||
}
|
||||
|
||||
using _consistency_check = typename std::conditional<Policies::template _no_unknown_tables<having_t>::value,
|
||||
consistent_t,
|
||||
assert_no_unknown_tables_in_having_t>::type;
|
||||
using _table_check = typename std::conditional<Policies::template _no_unknown_tables<having_t>::value,
|
||||
consistent_t,
|
||||
assert_no_unknown_tables_in_having_t>::type;
|
||||
|
||||
using _aggregate_check = typename std::conditional<Policies::template _no_non_aggregates<Expression>::value,
|
||||
consistent_t,
|
||||
assert_no_non_aggregates_t>::type;
|
||||
|
||||
using _consistency_check = detail::get_first_if<is_inconsistent_t, consistent_t, _table_check, _aggregate_check>;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -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<Policies::template _no_unknown_tables<select_column_list_t>::value,
|
||||
consistent_t,
|
||||
assert_no_unknown_tables_in_selected_columns_t>::type;
|
||||
using _table_check = typename std::conditional<Policies::template _no_unknown_tables<select_column_list_t>::value,
|
||||
consistent_t,
|
||||
assert_no_unknown_tables_in_selected_columns_t>::type;
|
||||
|
||||
using _aggregate_check = typename std::conditional<Policies::template _no_unknown_aggregates<Columns...>::value,
|
||||
consistent_t,
|
||||
assert_aggregates_t>::type;
|
||||
assert_no_unknown_aggregates_t>::type;
|
||||
|
||||
using _consistency_check = detail::get_first_if<is_inconsistent_t, consistent_t, _column_check, _aggregate_check>;
|
||||
using _consistency_check = detail::get_first_if<is_inconsistent_t, consistent_t, _table_check, _aggregate_check>;
|
||||
};
|
||||
|
||||
// Result methods
|
||||
|
||||
@@ -93,6 +93,10 @@ namespace sqlpp
|
||||
logic::all_t<detail::is_aggregate_expression_impl<_all_provided_aggregates,
|
||||
Expressions>::type::value...>::value>;
|
||||
|
||||
template <typename... Expressions>
|
||||
using _no_non_aggregates = logic::any_t<logic::all_t<
|
||||
detail::is_aggregate_expression_impl<_all_provided_aggregates, Expressions>::type::value...>::value>;
|
||||
|
||||
template <template <typename> class Predicate>
|
||||
using any_t = logic::any_t<Predicate<Policies>::value...>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user