diff --git a/include/sqlpp11/result_row.h b/include/sqlpp11/result_row.h index f9e21fcf..628edc76 100644 --- a/include/sqlpp11/result_row.h +++ b/include/sqlpp11/result_row.h @@ -265,6 +265,21 @@ namespace sqlpp } } }; + + template + struct is_static_result_row_impl + { + using type = std::false_type; + }; + + template + struct is_static_result_row_impl> + { + using type = std::true_type; + }; + + template + using is_static_result_row_t = typename is_static_result_row_impl::type; } #endif diff --git a/include/sqlpp11/union.h b/include/sqlpp11/union.h index d68ab63b..575f2b08 100644 --- a/include/sqlpp11/union.h +++ b/include/sqlpp11/union.h @@ -33,6 +33,7 @@ #include #include #include +#include #include namespace sqlpp @@ -176,9 +177,12 @@ namespace sqlpp { static_assert(is_statement_t::value, "argument of union call has to be a statement"); static_assert(has_policy_t::value, "argument of union call has to be a select"); - static_assert(has_result_row_t::value, "argument of a union has to be a (complete) select statement"); - static_assert(has_result_row_t>::value, "left hand side argument of a union has to be a (complete) select statement"); - static_assert(std::is_same>, get_result_row_t>::value, "both select statements in a union have to have the same result columns (type and name)"); + static_assert(has_result_row_t::value, "argument of a union has to be a complete select statement"); + static_assert(has_result_row_t>::value, "left hand side argument of a union has to be a complete select statement or union"); + static_assert(std::is_same>, get_result_row_t>::value, "both arguments in a union have to have the same result columns (type and name)"); + + using _result_row_t = get_result_row_t; + static_assert(is_static_result_row_t<_result_row_t>::value, "unions must not have dynamically added columns"); return _union_impl(_check, Rhs>{}, rhs); }