mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-05 04:30:43 -06:00
Moved limit-methods to limit classes
This commit is contained in:
@@ -130,7 +130,8 @@ namespace sqlpp
|
||||
typename 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>>,
|
||||
Limit::template _methods_t<detail::select_policies_t<Database, FlagList, ColumnList, From, Where, GroupBy, Having, OrderBy, Limit, Offset>>
|
||||
{
|
||||
using _database_t = Database;
|
||||
using _is_dynamic = typename std::conditional<std::is_same<Database, void>::value, std::false_type, std::true_type>::type;
|
||||
@@ -283,22 +284,6 @@ namespace sqlpp
|
||||
return { *this, vendor::order_by_t<_database_t, Args...>{args...} };
|
||||
}
|
||||
|
||||
template<typename Arg>
|
||||
auto limit(Arg arg)
|
||||
-> _policies_update_t<vendor::no_limit_t, vendor::limit_t<typename vendor::wrap_operand<Arg>::type>>
|
||||
{
|
||||
static_assert(is_noop_t<Limit>::value, "cannot call limit()/dynamic_limit() twice");
|
||||
return { *this, vendor::limit_t<typename vendor::wrap_operand<Arg>::type>{{arg}} };
|
||||
}
|
||||
|
||||
auto dynamic_limit()
|
||||
-> _policies_update_t<vendor::no_limit_t, vendor::dynamic_limit_t<_database_t>>
|
||||
{
|
||||
static_assert(is_noop_t<Limit>::value, "cannot call limit()/dynamic_limit() twice");
|
||||
static_assert(not std::is_same<_database_t, void>::value, "dynamic_limit must not be called in a static statement");
|
||||
return { *this, vendor::dynamic_limit_t<_database_t>{} };
|
||||
}
|
||||
|
||||
template<typename Arg>
|
||||
auto offset(Arg arg)
|
||||
-> _policies_update_t<vendor::no_offset_t, vendor::offset_t<typename vendor::wrap_operand<Arg>::type>>
|
||||
|
||||
40
include/sqlpp11/vendor/limit.h
vendored
40
include/sqlpp11/vendor/limit.h
vendored
@@ -53,6 +53,11 @@ namespace sqlpp
|
||||
limit_t& operator=(limit_t&&) = default;
|
||||
~limit_t() = default;
|
||||
|
||||
template<typename Policies>
|
||||
struct _methods_t
|
||||
{
|
||||
};
|
||||
|
||||
Limit _value;
|
||||
};
|
||||
|
||||
@@ -61,6 +66,7 @@ namespace sqlpp
|
||||
{
|
||||
using _is_limit = std::true_type;
|
||||
using _is_dynamic = std::true_type;
|
||||
using _table_set = ::sqlpp::detail::type_set<>;
|
||||
|
||||
dynamic_limit_t():
|
||||
_value(noop())
|
||||
@@ -88,6 +94,18 @@ namespace sqlpp
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
template<typename Policies>
|
||||
struct _methods_t
|
||||
{
|
||||
template<typename Limit>
|
||||
void set_limit(Limit value)
|
||||
{
|
||||
using arg_t = typename wrap_operand<Limit>::type;
|
||||
static_cast<typename Policies::_select_t*>(this)->_limit._value = arg_t{value};
|
||||
static_cast<typename Policies::_select_t*>(this)->_limit._initialized = true;
|
||||
}
|
||||
};
|
||||
|
||||
bool _initialized = false;
|
||||
interpretable_t<Database> _value;
|
||||
};
|
||||
@@ -96,6 +114,28 @@ namespace sqlpp
|
||||
{
|
||||
using _is_noop = std::true_type;
|
||||
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_limit_t, T>;
|
||||
|
||||
template<typename Arg>
|
||||
auto limit(Arg arg)
|
||||
-> _new_select_t<limit_t<typename wrap_operand<Arg>::type>>
|
||||
{
|
||||
return { *static_cast<typename Policies::_select_t*>(this), limit_t<typename wrap_operand<Arg>::type>{{arg}} };
|
||||
}
|
||||
|
||||
auto dynamic_limit()
|
||||
-> _new_select_t<dynamic_limit_t<_database_t>>
|
||||
{
|
||||
static_assert(not std::is_same<_database_t, void>::value, "dynamic_limit must not be called in a static statement");
|
||||
return { *static_cast<typename Policies::_select_t*>(this), dynamic_limit_t<_database_t>{} };
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Interpreters
|
||||
|
||||
1
include/sqlpp11/vendor/where.h
vendored
1
include/sqlpp11/vendor/where.h
vendored
@@ -116,6 +116,7 @@ namespace sqlpp
|
||||
using _database_t = typename Policies::_database_t;
|
||||
template<typename T>
|
||||
using _new_select_t = typename Policies::template _policies_update_t<no_where_t, T>;
|
||||
|
||||
template<typename... Args>
|
||||
auto where(Args... args)
|
||||
-> _new_select_t<where_t<void, Args...>>
|
||||
|
||||
Reference in New Issue
Block a user