diff --git a/include/sqlpp11/vendor/select_column_list.h b/include/sqlpp11/vendor/select_column_list.h index 9760da5d..2c3d6042 100644 --- a/include/sqlpp11/vendor/select_column_list.h +++ b/include/sqlpp11/vendor/select_column_list.h @@ -198,8 +198,13 @@ namespace sqlpp static_assert(_is_dynamic::value, "add_column can only be called for dynamic_column"); static_assert(is_named_expression_t::value, "invalid named expression argument in add_column()"); static_assert(TableCheckRequired::value or Policies::template _no_unknown_tables::value, "named expression uses tables unknown to this statement in add_column()"); + using column_names = ::sqlpp::detail::make_type_set_t; + static_assert(not ::sqlpp::detail::is_element_of::value, "a column of this name is present in the select already"); - using ok = ::sqlpp::detail::all_t>; + using ok = ::sqlpp::detail::all_t + >; _add_column_impl(namedExpression, ok()); // dispatch to prevent compile messages after the static_assert } diff --git a/tests/SelectTest.cpp b/tests/SelectTest.cpp index c54c7c2d..c82f1dc2 100644 --- a/tests/SelectTest.cpp +++ b/tests/SelectTest.cpp @@ -70,8 +70,7 @@ int main() auto s = dynamic_select(db).dynamic_columns(all_of(t)).dynamic_flags().dynamic_from(t).extra_tables(f,t).dynamic_where().dynamic_group_by(t.alpha).dynamic_order_by().dynamic_having(t.gamma).dynamic_limit().dynamic_offset(); s.add_flag(sqlpp::distinct); -#warning: this should fail because t.beta has been selected already - s.add_column(t.beta); + s.add_column(f.omega); s.add_from(f); s.add_where(t.alpha > 7); s.add_having(t.alpha > 7);