diff --git a/include/sqlpp11/avg.h b/include/sqlpp11/avg.h index 2854a8d6..50ca491c 100644 --- a/include/sqlpp11/avg.h +++ b/include/sqlpp11/avg.h @@ -34,7 +34,8 @@ namespace sqlpp namespace vendor { template - struct avg_t: public floating_point::template expression_operators> + struct avg_t: public floating_point::template expression_operators>, + public alias_operators> { using _traits = make_traits; using _recursive_traits = make_recursive_traits; diff --git a/include/sqlpp11/basic_expression_operators.h b/include/sqlpp11/basic_expression_operators.h index e306542d..d1f06749 100644 --- a/include/sqlpp11/basic_expression_operators.h +++ b/include/sqlpp11/basic_expression_operators.h @@ -139,7 +139,11 @@ namespace sqlpp static_assert(detail::all_t<_is_valid_comparison_operand>::value...>::value, "at least one operand of in() is not valid"); return { *static_cast(this), vendor::wrap_operand_t{t}... }; } + }; + template + struct alias_operators + { template expression_alias_t as(const alias_provider&) { diff --git a/include/sqlpp11/count.h b/include/sqlpp11/count.h index eec747be..838189a6 100644 --- a/include/sqlpp11/count.h +++ b/include/sqlpp11/count.h @@ -35,7 +35,8 @@ namespace sqlpp namespace vendor { template - struct count_t: public sqlpp::detail::integral::template expression_operators> + struct count_t: public sqlpp::detail::integral::template expression_operators>, + public alias_operators> { using _traits = make_traits<::sqlpp::detail::integral, ::sqlpp::tag::expression, ::sqlpp::tag::named_expression>; using _recursive_traits = make_recursive_traits; diff --git a/include/sqlpp11/detail/pick_arg.h b/include/sqlpp11/detail/pick_arg.h index ca9f5296..10cd512b 100644 --- a/include/sqlpp11/detail/pick_arg.h +++ b/include/sqlpp11/detail/pick_arg.h @@ -34,22 +34,22 @@ namespace sqlpp namespace detail { template - Target pick_arg_impl(Statement statement, Term term, const std::true_type&) + typename Target::_data_t pick_arg_impl(Statement statement, Term term, const std::true_type&) { return term; }; template - Target pick_arg_impl(Statement statement, Term term, const std::false_type&) + typename Target::_data_t pick_arg_impl(Statement statement, Term term, const std::false_type&) { - return static_cast(statement); + return Target::_get_member(statement)._data; }; // Returns a statement's term either by picking the term from the statement or using the new term template - Target pick_arg(Statement statement, Term term) + typename Target::_data_t pick_arg(Statement statement, Term term) { - return pick_arg_impl(statement, term, std::is_same()); + return pick_arg_impl(statement, term, std::is_same()); }; } } diff --git a/include/sqlpp11/exists.h b/include/sqlpp11/exists.h index 7469af47..8d767754 100644 --- a/include/sqlpp11/exists.h +++ b/include/sqlpp11/exists.h @@ -34,7 +34,8 @@ namespace sqlpp namespace vendor { template - struct exists_t: public boolean::template expression_operators> + struct exists_t: public boolean::template expression_operators>, + public alias_operators> { using _traits = make_traits; using _recursive_traits = make_recursive_traits