Added missing checks for aggregate functions

This commit is contained in:
rbock
2015-02-24 08:02:14 +01:00
parent c9401d4b00
commit 57ceefbd0c
4 changed files with 7 additions and 3 deletions

View File

@@ -40,7 +40,7 @@ namespace sqlpp
{
using _traits = make_traits<integral, tag::is_expression, tag::is_selectable>;
using _nodes = detail::type_vector<Expr>;
using _nodes = detail::type_vector<Expr, aggregate_function>;
using _can_be_null = std::false_type;
static_assert(is_noop<Flag>::value or std::is_same<distinct_t, Flag>::value, "count() used with flag other than 'distinct'");
@@ -98,6 +98,7 @@ namespace sqlpp
template<typename T>
auto count(T t) -> count_t<noop, wrap_operand_t<T>>
{
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value, "count() cannot be used on an aggregate function");
static_assert(is_expression_t<wrap_operand_t<T>>::value, "count() requires an expression as argument");
return { t };
}
@@ -105,6 +106,7 @@ namespace sqlpp
template<typename T>
auto count(const distinct_t&, T t) -> count_t<distinct_t, wrap_operand_t<T>>
{
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value, "count() cannot be used on an aggregate function");
static_assert(is_expression_t<wrap_operand_t<T>>::value, "count() requires an expression as argument");
return { t };
}

View File

@@ -84,6 +84,7 @@ namespace sqlpp
template<typename T>
auto max(T t) -> max_t<wrap_operand_t<T>>
{
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value, "max() cannot be used on an aggregate function");
static_assert(is_expression_t<wrap_operand_t<T>>::value, "max() requires an expression as argument");
return { t };
}

View File

@@ -84,6 +84,7 @@ namespace sqlpp
template<typename T>
auto min(T t) -> min_t<wrap_operand_t<T>>
{
static_assert(not contains_aggregate_function_t<wrap_operand_t<T>>::value, "min() cannot be used on an aggregate function");
static_assert(is_expression_t<wrap_operand_t<T>>::value, "min() requires an expression as argument");
return { t };
}