diff --git a/include/sqlpp11/core/clause/insert.h b/include/sqlpp11/core/clause/insert.h index 87866118..b51db566 100644 --- a/include/sqlpp11/core/clause/insert.h +++ b/include/sqlpp11/core/clause/insert.h @@ -43,7 +43,7 @@ namespace sqlpp struct insert_t : public statement_name_t { - using _traits = make_traits; + using _traits = make_traits; struct _sqlpp_name_tag { }; @@ -86,6 +86,9 @@ namespace sqlpp }; }; + template<> + struct is_result_clause : public std::true_type {}; + template auto to_sql_string(Context& , const insert_name_t&) -> std::string { diff --git a/include/sqlpp11/core/clause/remove.h b/include/sqlpp11/core/clause/remove.h index ee786267..446b9a32 100644 --- a/include/sqlpp11/core/clause/remove.h +++ b/include/sqlpp11/core/clause/remove.h @@ -42,7 +42,7 @@ namespace sqlpp }; struct remove_t : public statement_name_t { - using _traits = make_traits; + using _traits = make_traits; struct _sqlpp_name_tag { }; @@ -85,6 +85,9 @@ namespace sqlpp }; }; + template<> + struct is_result_clause : public std::true_type {}; + template auto to_sql_string(Context& , const remove_name_t&) -> std::string { diff --git a/include/sqlpp11/core/clause/select_column_list.h b/include/sqlpp11/core/clause/select_column_list.h index ee7372db..2130cda5 100644 --- a/include/sqlpp11/core/clause/select_column_list.h +++ b/include/sqlpp11/core/clause/select_column_list.h @@ -67,7 +67,7 @@ namespace sqlpp template struct select_traits { - using _traits = make_traits; + using _traits = make_traits; }; template @@ -75,7 +75,6 @@ namespace sqlpp { using _traits = make_traits, tag::is_select_column_list, - tag::is_return_value, tag::is_expression, tag::is_selectable>; }; @@ -227,6 +226,24 @@ namespace sqlpp { }; + // If a GROUP BY clause defines known aggregate columns or the SELECT columns contain an aggregate function then ALL + // columns need to be aggregate. + template + struct has_correct_aggregates> + : public std::integral_constant< + bool, + (detail::type_vector_size::value == 0 and + logic::none_t>>::value...>::value) or + logic::all_t>>::value...>::value> + { + }; + + template + struct is_result_clause> : public std::true_type + { + }; + template struct nodes_of> { diff --git a/include/sqlpp11/core/clause/union.h b/include/sqlpp11/core/clause/union.h index 807ba31d..9fe191cf 100644 --- a/include/sqlpp11/core/clause/union.h +++ b/include/sqlpp11/core/clause/union.h @@ -60,7 +60,7 @@ namespace sqlpp template struct union_t { - using _traits = make_traits; + using _traits = make_traits; using _nodes = detail::type_vector; using _data_t = union_data_t; @@ -91,8 +91,6 @@ namespace sqlpp typename Rhs::_consistency_check>; }; - template - using _result_methods_t = typename Lhs::template _result_methods_t; }; SQLPP_PORTABLE_STATIC_ASSERT(assert_union_args_are_statements_t, "arguments for union() must be statements"); diff --git a/include/sqlpp11/core/clause/update.h b/include/sqlpp11/core/clause/update.h index 61d69e1a..f6841f46 100644 --- a/include/sqlpp11/core/clause/update.h +++ b/include/sqlpp11/core/clause/update.h @@ -43,7 +43,7 @@ namespace sqlpp struct update_t : public statement_name_t { - using _traits = make_traits; + using _traits = make_traits; struct _sqlpp_name_tag { }; @@ -86,6 +86,9 @@ namespace sqlpp }; }; + template<> + struct is_result_clause : public std::true_type {}; + template auto to_sql_string(Context& , const update_name_t&) -> std::string { diff --git a/include/sqlpp11/core/detail/get_last.h b/include/sqlpp11/core/detail/get_last.h index d94c0e55..93584193 100644 --- a/include/sqlpp11/core/detail/get_last.h +++ b/include/sqlpp11/core/detail/get_last.h @@ -33,22 +33,23 @@ namespace sqlpp namespace detail { template