diff --git a/include/sqlpp11/any.h b/include/sqlpp11/any.h index 8585de1d..23ad6db0 100644 --- a/include/sqlpp11/any.h +++ b/include/sqlpp11/any.h @@ -39,19 +39,6 @@ namespace sqlpp using _traits = make_traits, tag::is_multi_expression>; using _nodes = detail::type_vector; - - static_assert(is_select_t; + + static_assert(is_select_t; - struct _alias_t - { - static constexpr const char _literal[] = "some_"; - using _name_t = sqlpp::make_char_sequence; - template - struct _member_t - { - T some; - T& operator()() { return some; } - const T& operator()() const { return some; } - }; - }; - some_t(Select select): _select(select) {} diff --git a/include/sqlpp11/sum.h b/include/sqlpp11/sum.h index b766d2e3..0211706b 100644 --- a/include/sqlpp11/sum.h +++ b/include/sqlpp11/sum.h @@ -32,17 +32,8 @@ namespace sqlpp { - template - struct sum_t: - public expression_operators, value_type_of>, - public alias_operators> + struct sum_alias_t { - using _traits = make_traits, tag::is_expression, tag::is_selectable>; - using _nodes = detail::type_vector; - - static_assert(is_noop::value or std::is_same::value, "sum() used with flag other than 'distinct'"); - static_assert(is_numeric_t::value, "sum() requires a numeric expression as argument"); - struct _alias_t { static constexpr const char _literal[] = "sum_"; @@ -55,6 +46,20 @@ namespace sqlpp const T& operator()() const { return sum; } }; }; + }; + + template + struct sum_t: + public expression_operators, value_type_of>, + public alias_operators> + { + using _traits = make_traits, tag::is_expression, tag::is_selectable>; + using _nodes = detail::type_vector; + + static_assert(is_noop::value or std::is_same::value, "sum() used with flag other than 'distinct'"); + static_assert(is_numeric_t::value, "sum() requires a numeric expression as argument"); + + using _auto_alias_t = sum_alias_t; sum_t(Expr expr): _expr(expr) diff --git a/tests/Function.cpp b/tests/Function.cpp index ac62a789..1956257a 100644 --- a/tests/Function.cpp +++ b/tests/Function.cpp @@ -25,6 +25,7 @@ #include "Sample.h" #include "MockDb.h" +#include #include #include #include @@ -256,11 +257,11 @@ int Function(int, char**) { using TI = decltype(avg(t.alpha)); using TF = decltype(avg(f.omega)); - static_assert(sqlpp::is_selectable_t::value, "type requirement"); + static_assert(sqlpp::has_auto_alias_t::value, "type requirement"); static_assert(sqlpp::is_numeric_t::value, "type requirement"); static_assert(not sqlpp::is_integral_t::value, "type requirement"); static_assert(sqlpp::is_floating_point_t::value, "type requirement"); - static_assert(sqlpp::is_selectable_t::value, "type requirement"); + static_assert(sqlpp::has_auto_alias_t::value, "type requirement"); static_assert(sqlpp::is_numeric_t::value, "type requirement"); static_assert(not sqlpp::is_integral_t::value, "type requirement"); static_assert(sqlpp::is_floating_point_t::value, "type requirement"); @@ -271,15 +272,15 @@ int Function(int, char**) using TI = decltype(count(t.alpha)); using TT = decltype(count(t.beta)); using TF = decltype(count(f.omega)); - static_assert(sqlpp::is_selectable_t::value, "type requirement"); + static_assert(sqlpp::has_auto_alias_t::value, "type requirement"); static_assert(sqlpp::is_numeric_t::value, "type requirement"); static_assert(sqlpp::is_integral_t::value, "type requirement"); static_assert(not sqlpp::is_floating_point_t::value, "type requirement"); - static_assert(sqlpp::is_selectable_t::value, "type requirement"); + static_assert(sqlpp::has_auto_alias_t::value, "type requirement"); static_assert(sqlpp::is_numeric_t::value, "type requirement"); static_assert(sqlpp::is_integral_t::value, "type requirement"); static_assert(not sqlpp::is_floating_point_t::value, "type requirement"); - static_assert(sqlpp::is_selectable_t::value, "type requirement"); + static_assert(sqlpp::has_auto_alias_t::value, "type requirement"); static_assert(sqlpp::is_numeric_t::value, "type requirement"); static_assert(sqlpp::is_integral_t::value, "type requirement"); static_assert(not sqlpp::is_floating_point_t::value, "type requirement"); @@ -292,15 +293,15 @@ int Function(int, char**) using TI = decltype(max(t.alpha)); using TF = decltype(max(f.omega)); using TT = decltype(max(t.beta)); - static_assert(sqlpp::is_selectable_t::value, "type requirement"); + static_assert(sqlpp::has_auto_alias_t::value, "type requirement"); static_assert(sqlpp::is_numeric_t::value, "type requirement"); static_assert(sqlpp::is_integral_t::value, "type requirement"); static_assert(not sqlpp::is_floating_point_t::value, "type requirement"); - static_assert(sqlpp::is_selectable_t::value, "type requirement"); + static_assert(sqlpp::has_auto_alias_t::value, "type requirement"); static_assert(sqlpp::is_numeric_t::value, "type requirement"); static_assert(not sqlpp::is_integral_t::value, "type requirement"); static_assert(sqlpp::is_floating_point_t::value, "type requirement"); - static_assert(sqlpp::is_selectable_t::value, "type requirement"); + static_assert(sqlpp::has_auto_alias_t::value, "type requirement"); static_assert(not sqlpp::is_numeric_t::value, "type requirement"); static_assert(sqlpp::is_text_t::value, "type requirement"); } @@ -310,7 +311,7 @@ int Function(int, char**) using TI = decltype(min(t.alpha)); using TF = decltype(min(f.omega)); using TT = decltype(min(t.beta)); - static_assert(sqlpp::is_selectable_t::value, "type requirement"); + static_assert(sqlpp::has_auto_alias_t::value, "type requirement"); static_assert(sqlpp::is_numeric_t::value, "type requirement"); static_assert(sqlpp::is_integral_t::value, "type requirement"); static_assert(not sqlpp::is_floating_point_t::value, "type requirement"); @@ -327,7 +328,7 @@ int Function(int, char**) { using TI = decltype(sum(t.alpha)); using TF = decltype(sum(f.omega)); - static_assert(sqlpp::is_selectable_t::value, "type requirement"); + static_assert(sqlpp::has_auto_alias_t::value, "type requirement"); static_assert(sqlpp::is_numeric_t::value, "type requirement"); static_assert(sqlpp::is_integral_t::value, "type requirement"); static_assert(not sqlpp::is_floating_point_t::value, "type requirement"); diff --git a/tests/Select.cpp b/tests/Select.cpp index 42fe4393..7eddc76c 100644 --- a/tests/Select.cpp +++ b/tests/Select.cpp @@ -53,6 +53,7 @@ int Select(int, char**) const auto tab_a = f.as(sqlpp::alias::a); getColumn(db, t.alpha); + select(count(t.alpha)); for (const auto& row : db(select(sqlpp::value(false).as(sqlpp::alias::a)))) {