mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 04:47:18 +08:00
Moved having-methods to having-classes
This commit is contained in:
parent
eb9eab369a
commit
a541d8e187
@ -131,6 +131,7 @@ namespace sqlpp
|
|||||||
>
|
>
|
||||||
struct select_t: public detail::select_helper_t<ColumnList, From>::_value_type::template expression_operators<select_t<Database, FlagList, ColumnList, From, Where, GroupBy, Having, OrderBy, Limit, Offset>>,
|
struct select_t: public detail::select_helper_t<ColumnList, From>::_value_type::template expression_operators<select_t<Database, FlagList, ColumnList, From, Where, GroupBy, Having, OrderBy, Limit, Offset>>,
|
||||||
Where::template _methods_t<detail::select_policies_t<Database, FlagList, ColumnList, From, Where, GroupBy, Having, OrderBy, Limit, Offset>>,
|
Where::template _methods_t<detail::select_policies_t<Database, FlagList, ColumnList, From, Where, GroupBy, Having, OrderBy, Limit, Offset>>,
|
||||||
|
Having::template _methods_t<detail::select_policies_t<Database, FlagList, ColumnList, From, Where, GroupBy, Having, OrderBy, Limit, Offset>>,
|
||||||
OrderBy::template _methods_t<detail::select_policies_t<Database, FlagList, ColumnList, From, Where, GroupBy, Having, OrderBy, Limit, Offset>>,
|
OrderBy::template _methods_t<detail::select_policies_t<Database, FlagList, ColumnList, From, Where, GroupBy, Having, OrderBy, Limit, Offset>>,
|
||||||
Limit::template _methods_t<detail::select_policies_t<Database, FlagList, ColumnList, From, Where, GroupBy, Having, OrderBy, Limit, Offset>>,
|
Limit::template _methods_t<detail::select_policies_t<Database, FlagList, ColumnList, From, Where, GroupBy, Having, OrderBy, Limit, Offset>>,
|
||||||
Offset::template _methods_t<detail::select_policies_t<Database, FlagList, ColumnList, From, Where, GroupBy, Having, OrderBy, Limit, Offset>>
|
Offset::template _methods_t<detail::select_policies_t<Database, FlagList, ColumnList, From, Where, GroupBy, Having, OrderBy, Limit, Offset>>
|
||||||
@ -252,23 +253,6 @@ namespace sqlpp
|
|||||||
return { *this, vendor::group_by_t<_database_t, Args...>{args...} };
|
return { *this, vendor::group_by_t<_database_t, Args...>{args...} };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
|
||||||
auto having(Args... args)
|
|
||||||
-> _policies_update_t<vendor::no_having_t, vendor::having_t<void, Args...>>
|
|
||||||
{
|
|
||||||
static_assert(is_noop_t<Having>::value, "cannot call having()/dynamic_having() twice");
|
|
||||||
return { *this, vendor::having_t<void, Args...>{args...} };
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename... Args>
|
|
||||||
auto dynamic_having(Args... args)
|
|
||||||
-> _policies_update_t<vendor::no_having_t, vendor::having_t<_database_t, Args...>>
|
|
||||||
{
|
|
||||||
static_assert(is_noop_t<Having>::value, "cannot call having()/dynamic_having() twice");
|
|
||||||
static_assert(not std::is_same<_database_t, void>::value, "dynamic_having must not be called in a static statement");
|
|
||||||
return { *this, vendor::having_t<_database_t, Args...>{args...} };
|
|
||||||
}
|
|
||||||
|
|
||||||
// value adding methods
|
// value adding methods
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void add_flag(Args... args)
|
void add_flag(Args... args)
|
||||||
@ -302,14 +286,6 @@ namespace sqlpp
|
|||||||
return _group_by.add_group_by(*this, args...);
|
return _group_by.add_group_by(*this, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
|
||||||
void add_having(Args... args)
|
|
||||||
{
|
|
||||||
static_assert(is_having_t<Having>::value, "cannot call add_having() before dynamic_having()");
|
|
||||||
static_assert(is_dynamic_t<Having>::value, "cannot call add_having() before dynamic_having()");
|
|
||||||
return _having.add_having(*this, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
// PseudoTable
|
// PseudoTable
|
||||||
template<typename AliasProvider>
|
template<typename AliasProvider>
|
||||||
struct _pseudo_table_t
|
struct _pseudo_table_t
|
||||||
|
40
include/sqlpp11/vendor/having.h
vendored
40
include/sqlpp11/vendor/having.h
vendored
@ -51,6 +51,8 @@ namespace sqlpp
|
|||||||
|
|
||||||
using _parameter_list_t = typename make_parameter_list_t<_parameter_tuple_t>::type;
|
using _parameter_list_t = typename make_parameter_list_t<_parameter_tuple_t>::type;
|
||||||
|
|
||||||
|
using _table_set = typename ::sqlpp::detail::make_joined_set<typename Expressions::_table_set...>::type;
|
||||||
|
|
||||||
having_t(Expressions... expressions):
|
having_t(Expressions... expressions):
|
||||||
_expressions(expressions...)
|
_expressions(expressions...)
|
||||||
{}
|
{}
|
||||||
@ -61,12 +63,17 @@ namespace sqlpp
|
|||||||
having_t& operator=(having_t&&) = default;
|
having_t& operator=(having_t&&) = default;
|
||||||
~having_t() = default;
|
~having_t() = default;
|
||||||
|
|
||||||
template<typename Expression>
|
template<typename Policies>
|
||||||
void add(Expression expr)
|
struct _methods_t
|
||||||
{
|
{
|
||||||
static_assert(is_expression_t<Expression>::value, "invalid expression argument in add_having()");
|
template<typename Expression>
|
||||||
_dynamic_expressions.emplace_back(expr);
|
void add_having(Expression expression)
|
||||||
}
|
{
|
||||||
|
static_assert(is_expression_t<Expression>::value, "invalid expression argument in add_having()");
|
||||||
|
#warning: Need to dispatch to actual add method to prevent error messages from being generated
|
||||||
|
return static_cast<typename Policies::_select_t*>(this)->_having._dynamic_expressions.emplace_back(expression);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
_parameter_tuple_t _expressions;
|
_parameter_tuple_t _expressions;
|
||||||
vendor::interpretable_list_t<Database> _dynamic_expressions;
|
vendor::interpretable_list_t<Database> _dynamic_expressions;
|
||||||
@ -76,6 +83,29 @@ namespace sqlpp
|
|||||||
{
|
{
|
||||||
using _is_noop = std::true_type;
|
using _is_noop = std::true_type;
|
||||||
using _table_set = ::sqlpp::detail::type_set<>;
|
using _table_set = ::sqlpp::detail::type_set<>;
|
||||||
|
|
||||||
|
template<typename Policies>
|
||||||
|
struct _methods_t
|
||||||
|
{
|
||||||
|
using _database_t = typename Policies::_database_t;
|
||||||
|
template<typename T>
|
||||||
|
using _new_select_t = typename Policies::template _policies_update_t<no_having_t, T>;
|
||||||
|
|
||||||
|
template<typename... Args>
|
||||||
|
auto having(Args... args)
|
||||||
|
-> _new_select_t<having_t<void, Args...>>
|
||||||
|
{
|
||||||
|
return { *static_cast<typename Policies::_select_t*>(this), having_t<void, Args...>{args...} };
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename... Args>
|
||||||
|
auto dynamic_having(Args... args)
|
||||||
|
-> _new_select_t<having_t<_database_t, Args...>>
|
||||||
|
{
|
||||||
|
static_assert(not std::is_same<_database_t, void>::value, "dynamic_having must not be called in a static statement");
|
||||||
|
return { *static_cast<typename Policies::_select_t*>(this), vendor::having_t<_database_t, Args...>{args...} };
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Interpreters
|
// Interpreters
|
||||||
|
Loading…
Reference in New Issue
Block a user