diff --git a/include/sqlpp11/union.h b/include/sqlpp11/union.h index 80070abd..2bac56c7 100644 --- a/include/sqlpp11/union.h +++ b/include/sqlpp11/union.h @@ -135,6 +135,16 @@ namespace sqlpp 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"); + template + struct check_union + { + using type = static_combined_check_t< + static_check_t::value...>::value, assert_union_args_are_statements_t>>; + }; + template + using check_union_t = typename check_union::type; + // NO UNION YET struct no_union_t { @@ -187,12 +197,6 @@ namespace sqlpp using _database_t = typename Policies::_database_t; - // workaround for msvc bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2173269 - // template - // using _check = logic::all_t::value...>; - template - using _check = typename logic::all::value...>::type; - template using _new_statement_t = union_statement_t; @@ -200,7 +204,8 @@ namespace sqlpp template auto union_distinct(Rhs rhs) const - -> _new_statement_t<_check, union_t, Rhs>> + -> _new_statement_t, Rhs>, + union_t, Rhs>> { 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"); @@ -213,12 +218,12 @@ namespace sqlpp "both arguments in a union have to have the same result columns (type and name)"); static_assert(is_static_result_row_t<_result_row_t>::value, "unions must not have dynamically added columns"); - return _union_impl(_check, Rhs>{}, rhs); + return _union_impl(check_union_t, Rhs>{}, rhs); } template - auto union_all(Rhs rhs) const - -> _new_statement_t<_check, union_t, Rhs>> + auto union_all(Rhs rhs) const -> _new_statement_t, Rhs>, + union_t, Rhs>> { 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"); @@ -231,11 +236,11 @@ namespace sqlpp "both arguments in a union have to have the same result columns (type and name)"); static_assert(is_static_result_row_t<_result_row_t>::value, "unions must not have dynamically added columns"); - return _union_impl(_check, Rhs>{}, rhs); + return _union_impl(check_union_t, Rhs>{}, rhs); } private: - template + template auto _union_impl(Check, Rhs rhs) const -> Check; template diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index de3f952b..359b38f3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2013-2015, Roland Bock +# Copyright (c) 2013-2016, Roland Bock # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, @@ -30,21 +30,21 @@ target_compile_options(sqlpp11_testing INTERFACE -Wall -Wextra -pedantic) endif () set(test_names - #BooleanExpression - #CustomQuery - #DateTime - #Interpret - #Insert - #Remove - #Update - #Select - #SelectType - #Function - #Prepared - #Minimalistic - #Result + BooleanExpression + CustomQuery + DateTime + Interpret + Insert + Remove + Update + Select + SelectType + Function + Prepared + Minimalistic + Result Union - #With + With ) create_test_sourcelist(test_sources test_main.cpp ${test_names})