Loosen union constraints a bit more

This commit is contained in:
rbock
2016-10-11 16:09:49 +02:00
parent 4dad08653a
commit ae37d063a4
2 changed files with 4 additions and 7 deletions

View File

@@ -46,7 +46,10 @@ namespace sqlpp
static constexpr auto is_compatible(field_spec_t<N, V, C, T>) -> bool
{
using rhs = field_spec_t<N, V, C, T>;
return std::is_same<_traits, typename rhs::_traits>::value and
return std::is_same<ValueType, V>::value and // We might need to know that float can hold int, too
(CanBeNull or CanBeNull == C) and // The left hand side determines the result row and therefore must allow
// NULL if the right hand side allows it
(NullIsTrivialValue or NullIsTrivialValue == T) and
std::is_same<typename _alias_t::_name_t, typename rhs::_alias_t::_name_t>::value;
}
};

View File

@@ -218,9 +218,6 @@ namespace sqlpp
constexpr auto vec_rhs = detail::type_vector<rhs_result_row_t>{};
static_assert(lhs_result_row_t::is_compatible(vec_rhs),
"both arguments in a union have to have the same result columns (type and name)");
static_assert(
is_static_result_row_t<lhs_result_row_t>::value && is_static_result_row_t<rhs_result_row_t>::value,
"unions must not have dynamically added columns");
return _union_impl<void, union_distinct_t>(check_union_t<derived_statement_t<Policies>, Rhs>{}, rhs);
}
@@ -240,9 +237,6 @@ namespace sqlpp
constexpr auto vec_rhs = detail::type_vector<rhs_result_row_t>{};
static_assert(lhs_result_row_t::is_compatible(vec_rhs),
"both arguments in a union have to have the same result columns (type and name)");
static_assert(
is_static_result_row_t<lhs_result_row_t>::value && is_static_result_row_t<rhs_result_row_t>::value,
"unions must not have dynamically added columns");
return _union_impl<void, union_all_t>(check_union_t<derived_statement_t<Policies>, Rhs>{}, rhs);
}