diff --git a/include/sqlpp11/having.h b/include/sqlpp11/having.h index e95877ea..6a2b397f 100644 --- a/include/sqlpp11/having.h +++ b/include/sqlpp11/having.h @@ -37,10 +37,10 @@ namespace sqlpp { // HAVING DATA - template + template struct having_data_t { - having_data_t(Expressions... expressions) : _expressions(expressions...) + having_data_t(Expression expression) : _expression(expression) { } @@ -50,7 +50,7 @@ namespace sqlpp having_data_t& operator=(having_data_t&&) = default; ~having_data_t() = default; - std::tuple _expressions; + Expression _expression; interpretable_list_t _dynamic_expressions; }; @@ -59,16 +59,16 @@ namespace sqlpp "at least one having-expression requires a table which is otherwise not known in the statement"); // HAVING - template + template struct having_t { using _traits = make_traits; - using _nodes = detail::type_vector; + using _nodes = detail::type_vector; using _is_dynamic = is_database; // Data - using _data_t = having_data_t; + using _data_t = having_data_t; // Member implementation with data and methods template @@ -80,36 +80,36 @@ namespace sqlpp { } - template - void add_ntc(Expression expression) + template + void add_ntc(Expr expression) { - add(expression); + add(expression); } - template - void add(Expression expression) + template + void add(Expr expression) { static_assert(_is_dynamic::value, "having::add() can only be called for dynamic_having"); - static_assert(is_expression_t::value, "invalid expression argument in having::add()"); - static_assert(not TableCheckRequired::value or Policies::template _no_unknown_tables::value, + static_assert(is_expression_t::value, "invalid expression argument in having::add()"); + static_assert(not TableCheckRequired::value or Policies::template _no_unknown_tables::value, "expression uses tables unknown to this statement in having::add()"); - using _serialize_check = sqlpp::serialize_check_t; + using _serialize_check = sqlpp::serialize_check_t; _serialize_check::_(); - using ok = logic::all_t<_is_dynamic::value, is_expression_t::value, _serialize_check::type::value>; + using ok = logic::all_t<_is_dynamic::value, is_expression_t::value, _serialize_check::type::value>; _add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert } private: - template - void _add_impl(Expression expression, const std::true_type&) + template + void _add_impl(Expr expression, const std::true_type&) { return _data._dynamic_expressions.emplace_back(expression); } - template - void _add_impl(Expression expression, const std::false_type&); + template + void _add_impl(Expr expression, const std::false_type&); public: _data_t _data; @@ -119,7 +119,7 @@ namespace sqlpp template struct _base_t { - using _data_t = having_data_t; + using _data_t = having_data_t; // workaround for msvc bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2091069 template @@ -216,54 +216,50 @@ namespace sqlpp using _consistency_check = consistent_t; - template - auto having(Expressions... expressions) const - -> _new_statement_t<_check, having_t> + template + auto having(Expression expression) const -> _new_statement_t<_check, having_t> { - static_assert(_check::value, "at least one argument is not an expression in having()"); - static_assert(sizeof...(Expressions), "at least one expression argument required in having()"); + static_assert(_check::value, "at least one argument is not an expression in having()"); - return _having_impl(_check{}, expressions...); + return _having_impl(_check{}, expression); } - template - auto dynamic_having(Expressions... expressions) const - -> _new_statement_t<_check, having_t<_database_t, Expressions...>> + template + auto dynamic_having(Expression expression) const + -> _new_statement_t<_check, having_t<_database_t, Expression>> { - static_assert(_check::value, "at least one argument is not an expression in having()"); + static_assert(_check::value, "at least one argument is not an expression in having()"); static_assert(not std::is_same<_database_t, void>::value, "dynamic_having must not be called in a static statement"); - return _having_impl<_database_t>(_check{}, expressions...); + return _having_impl<_database_t>(_check{}, expression); } private: - template - auto _having_impl(const std::false_type&, Expressions... expressions) const -> bad_statement; + template + auto _having_impl(const std::false_type&, Expression expression) const -> bad_statement; - template - auto _having_impl(const std::true_type&, Expressions... expressions) const - -> _new_statement_t> + template + auto _having_impl(const std::true_type&, Expression expression) const + -> _new_statement_t> { return {static_cast&>(*this), - having_data_t{expressions...}}; + having_data_t{expression}}; } }; }; // Interpreters - template - struct serializer_t> + template + struct serializer_t> { - using _serialize_check = serialize_check_of; - using T = having_data_t; + using _serialize_check = serialize_check_of; + using T = having_data_t; static Context& _(const T& t, Context& context) { - if (sizeof...(Expressions) == 0 and t._dynamic_expressions.empty()) - return context; context << " HAVING "; - interpret_tuple(t._expressions, " AND ", context); - if (sizeof...(Expressions) and not t._dynamic_expressions.empty()) + serialize(t._expression, context); + if (not t._dynamic_expressions.empty()) context << " AND "; interpret_list(t._dynamic_expressions, " AND ", context); return context;