mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Some cleanup
This commit is contained in:
parent
7f94002bec
commit
d2b59c0f59
@ -53,13 +53,13 @@ namespace sqlpp
|
||||
using _table_set = typename Table::_table_set;
|
||||
|
||||
template<typename Needle, typename Replacement, typename... Policies>
|
||||
struct _policies_update_impl
|
||||
struct _policies_update_t
|
||||
{
|
||||
using type = insert_t<Database, vendor::policy_update_t<Policies, Needle, Replacement>...>;
|
||||
};
|
||||
|
||||
template<typename Needle, typename Replacement>
|
||||
using _policies_update_t = typename _policies_update_impl<Needle, Replacement, Table, InsertValueList>::type;
|
||||
using _new_statement_t = typename _policies_update_t<Needle, Replacement, Table, InsertValueList>::type;
|
||||
|
||||
using _parameter_tuple_t = std::tuple<Table, InsertValueList>;
|
||||
using _parameter_list_t = typename make_parameter_list_t<insert_t>::type;
|
||||
@ -82,7 +82,7 @@ namespace sqlpp
|
||||
|
||||
// type update functions
|
||||
auto default_values()
|
||||
-> _policies_update_t<vendor::no_insert_value_list_t, vendor::insert_default_values_t>
|
||||
-> _new_statement_t<vendor::no_insert_value_list_t, vendor::insert_default_values_t>
|
||||
{
|
||||
static_assert(is_noop_t<InsertValueList>::value, "cannot combine default_values() with other methods");
|
||||
return { *this, vendor::insert_default_values_t{} };
|
||||
@ -90,7 +90,7 @@ namespace sqlpp
|
||||
|
||||
template<typename... Args>
|
||||
auto columns(Args... args)
|
||||
-> _policies_update_t<vendor::no_insert_value_list_t, vendor::column_list_t<Args...>>
|
||||
-> _new_statement_t<vendor::no_insert_value_list_t, vendor::column_list_t<Args...>>
|
||||
{
|
||||
static_assert(is_noop_t<InsertValueList>::value, "cannot combine columns() with other methods");
|
||||
return { *this, vendor::column_list_t<Args...>{args...} };
|
||||
@ -98,7 +98,7 @@ namespace sqlpp
|
||||
|
||||
template<typename... Args>
|
||||
auto set(Args... args)
|
||||
-> _policies_update_t<vendor::no_insert_value_list_t, vendor::insert_list_t<void, Args...>>
|
||||
-> _new_statement_t<vendor::no_insert_value_list_t, vendor::insert_list_t<void, Args...>>
|
||||
{
|
||||
static_assert(is_noop_t<InsertValueList>::value, "cannot combine set() with other methods");
|
||||
return { *this, vendor::insert_list_t<void, Args...>{args...} };
|
||||
@ -106,7 +106,7 @@ namespace sqlpp
|
||||
|
||||
template<typename... Args>
|
||||
auto dynamic_set(Args... args)
|
||||
-> _policies_update_t<vendor::no_insert_value_list_t, vendor::insert_list_t<_database_t, Args...>>
|
||||
-> _new_statement_t<vendor::no_insert_value_list_t, vendor::insert_list_t<_database_t, Args...>>
|
||||
{
|
||||
static_assert(is_noop_t<InsertValueList>::value, "cannot combine dynamic_set() with other methods");
|
||||
static_assert(_is_dynamic::value, "dynamic_set must not be called in a static statement");
|
||||
|
@ -66,13 +66,13 @@ namespace sqlpp
|
||||
{};
|
||||
|
||||
template<typename Needle, typename Replacement, typename... Policies>
|
||||
struct _policies_update_impl
|
||||
struct _policies_update_t
|
||||
{
|
||||
using type = remove_t<Db, vendor::policy_update_t<Policies, Needle, Replacement>...>;
|
||||
};
|
||||
|
||||
template<typename Needle, typename Replacement>
|
||||
using _policies_update_t = typename _policies_update_impl<Needle, Replacement, Table, Using, Where>::type;
|
||||
using _new_statement_t = typename _policies_update_t<Needle, Replacement, Table, Using, Where>::type;
|
||||
|
||||
};
|
||||
}
|
||||
|
@ -97,14 +97,14 @@ namespace sqlpp
|
||||
{};
|
||||
|
||||
template<typename Needle, typename Replacement, typename... Policies>
|
||||
struct _policies_update_impl
|
||||
struct _policies_update_t
|
||||
{
|
||||
static_assert(detail::is_element_of<Needle, make_type_set_t<Policies...>>::value, "policies update for non-policy class detected");
|
||||
using type = select_t<Db, vendor::policy_update_t<Policies, Needle, Replacement>...>;
|
||||
};
|
||||
|
||||
template<typename Needle, typename Replacement>
|
||||
using _policies_update_t = typename _policies_update_impl<Needle, Replacement, FlagList, ColumnList, From, Where, GroupBy, Having, OrderBy, Limit, Offset>::type;
|
||||
using _new_statement_t = typename _policies_update_t<Needle, Replacement, FlagList, ColumnList, From, Where, GroupBy, Having, OrderBy, Limit, Offset>::type;
|
||||
|
||||
static_assert(is_noop_t<ColumnList>::value or sqlpp::is_select_column_list_t<ColumnList>::value, "column list of select is neither naught nor a valid column list");
|
||||
static_assert(is_noop_t<From>::value or sqlpp::is_from_t<From>::value, "from() part of select is neither naught nor a valid from()");
|
||||
|
@ -65,13 +65,13 @@ namespace sqlpp
|
||||
using _is_dynamic = typename std::conditional<std::is_same<Database, void>::value, std::false_type, std::true_type>::type;
|
||||
|
||||
template<typename Needle, typename Replacement, typename... Policies>
|
||||
struct _policies_update_impl
|
||||
struct _policies_update_t
|
||||
{
|
||||
using type = update_t<Database, vendor::policy_update_t<Policies, Needle, Replacement>...>;
|
||||
};
|
||||
|
||||
template<typename Needle, typename Replacement>
|
||||
using _policies_update_t = typename _policies_update_impl<Needle, Replacement, Table, UpdateList, Where>::type;
|
||||
using _new_statement_t = typename _policies_update_t<Needle, Replacement, Table, UpdateList, Where>::type;
|
||||
|
||||
using _parameter_tuple_t = std::tuple<Table, UpdateList, Where>;
|
||||
using _parameter_list_t = typename make_parameter_list_t<update_t>::type;
|
||||
@ -96,7 +96,7 @@ namespace sqlpp
|
||||
// type update functions
|
||||
template<typename... Args>
|
||||
auto set(Args... args)
|
||||
-> _policies_update_t<vendor::no_update_list_t, vendor::update_list_t<void, Args...>>
|
||||
-> _new_statement_t<vendor::no_update_list_t, vendor::update_list_t<void, Args...>>
|
||||
{
|
||||
static_assert(is_noop_t<UpdateList>::value, "cannot call set()/dynamic_set() twice");
|
||||
return { *this, vendor::update_list_t<void, Args...>{args...} };
|
||||
@ -104,7 +104,7 @@ namespace sqlpp
|
||||
|
||||
template<typename... Args>
|
||||
auto dynamic_set(Args... args)
|
||||
-> _policies_update_t<vendor::no_update_list_t, vendor::update_list_t<_database_t, Args...>>
|
||||
-> _new_statement_t<vendor::no_update_list_t, vendor::update_list_t<_database_t, Args...>>
|
||||
{
|
||||
static_assert(is_noop_t<UpdateList>::value, "cannot call set()/dynamic_set() twice");
|
||||
static_assert(_is_dynamic::value, "dynamic_set must not be called in a static statement");
|
||||
@ -113,7 +113,7 @@ namespace sqlpp
|
||||
|
||||
template<typename... Args>
|
||||
auto where(Args... args)
|
||||
-> _policies_update_t<vendor::no_where_t, vendor::where_t<void, Args...>>
|
||||
-> _new_statement_t<vendor::no_where_t, vendor::where_t<void, Args...>>
|
||||
{
|
||||
static_assert(is_noop_t<Where>::value, "cannot call where()/dynamic_where() twice");
|
||||
return { *this, vendor::where_t<void, Args...>{args...} };
|
||||
@ -121,7 +121,7 @@ namespace sqlpp
|
||||
|
||||
template<typename... Args>
|
||||
auto dynamic_where(Args... args)
|
||||
-> _policies_update_t<vendor::no_where_t, vendor::where_t<_database_t, Args...>>
|
||||
-> _new_statement_t<vendor::no_where_t, vendor::where_t<_database_t, Args...>>
|
||||
{
|
||||
static_assert(is_noop_t<Where>::value, "cannot call where()/dynamic_where() twice");
|
||||
static_assert(not std::is_same<_database_t, void>::value, "dynamic_where must not be called in a static statement");
|
||||
|
6
include/sqlpp11/vendor/from.h
vendored
6
include/sqlpp11/vendor/from.h
vendored
@ -103,18 +103,18 @@ namespace sqlpp
|
||||
{
|
||||
using _database_t = typename Policies::_database_t;
|
||||
template<typename T>
|
||||
using _new_select_t = typename Policies::template _policies_update_t<no_from_t, T>;
|
||||
using _new_statement_t = typename Policies::template _new_statement_t<no_from_t, T>;
|
||||
|
||||
template<typename... Args>
|
||||
auto from(Args... args)
|
||||
-> _new_select_t<from_t<void, Args...>>
|
||||
-> _new_statement_t<from_t<void, Args...>>
|
||||
{
|
||||
return { *static_cast<typename Policies::_statement_t*>(this), from_t<void, Args...>{args...} };
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
auto dynamic_from(Args... args)
|
||||
-> _new_select_t<from_t<_database_t, Args...>>
|
||||
-> _new_statement_t<from_t<_database_t, Args...>>
|
||||
{
|
||||
static_assert(not std::is_same<_database_t, void>::value, "dynamic_from must not be called in a static statement");
|
||||
return { *static_cast<typename Policies::_statement_t*>(this), vendor::from_t<_database_t, Args...>{args...} };
|
||||
|
6
include/sqlpp11/vendor/group_by.h
vendored
6
include/sqlpp11/vendor/group_by.h
vendored
@ -105,18 +105,18 @@ namespace sqlpp
|
||||
{
|
||||
using _database_t = typename Policies::_database_t;
|
||||
template<typename T>
|
||||
using _new_select_t = typename Policies::template _policies_update_t<no_group_by_t, T>;
|
||||
using _new_statement_t = typename Policies::template _new_statement_t<no_group_by_t, T>;
|
||||
|
||||
template<typename... Args>
|
||||
auto group_by(Args... args)
|
||||
-> _new_select_t<group_by_t<void, Args...>>
|
||||
-> _new_statement_t<group_by_t<void, Args...>>
|
||||
{
|
||||
return { *static_cast<typename Policies::_statement_t*>(this), group_by_t<void, Args...>{args...} };
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
auto dynamic_group_by(Args... args)
|
||||
-> _new_select_t<group_by_t<_database_t, Args...>>
|
||||
-> _new_statement_t<group_by_t<_database_t, Args...>>
|
||||
{
|
||||
static_assert(not std::is_same<_database_t, void>::value, "dynamic_group_by must not be called in a static statement");
|
||||
return { *static_cast<typename Policies::_statement_t*>(this), vendor::group_by_t<_database_t, Args...>{args...} };
|
||||
|
6
include/sqlpp11/vendor/having.h
vendored
6
include/sqlpp11/vendor/having.h
vendored
@ -102,18 +102,18 @@ namespace sqlpp
|
||||
{
|
||||
using _database_t = typename Policies::_database_t;
|
||||
template<typename T>
|
||||
using _new_select_t = typename Policies::template _policies_update_t<no_having_t, T>;
|
||||
using _new_statement_t = typename Policies::template _new_statement_t<no_having_t, T>;
|
||||
|
||||
template<typename... Args>
|
||||
auto having(Args... args)
|
||||
-> _new_select_t<having_t<void, Args...>>
|
||||
-> _new_statement_t<having_t<void, Args...>>
|
||||
{
|
||||
return { *static_cast<typename Policies::_statement_t*>(this), having_t<void, Args...>{args...} };
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
auto dynamic_having(Args... args)
|
||||
-> _new_select_t<having_t<_database_t, Args...>>
|
||||
-> _new_statement_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::_statement_t*>(this), vendor::having_t<_database_t, Args...>{args...} };
|
||||
|
6
include/sqlpp11/vendor/limit.h
vendored
6
include/sqlpp11/vendor/limit.h
vendored
@ -113,17 +113,17 @@ namespace sqlpp
|
||||
{
|
||||
using _database_t = typename Policies::_database_t;
|
||||
template<typename T>
|
||||
using _new_select_t = typename Policies::template _policies_update_t<no_limit_t, T>;
|
||||
using _new_statement_t = typename Policies::template _new_statement_t<no_limit_t, T>;
|
||||
|
||||
template<typename Arg>
|
||||
auto limit(Arg arg)
|
||||
-> _new_select_t<limit_t<typename wrap_operand<Arg>::type>>
|
||||
-> _new_statement_t<limit_t<typename wrap_operand<Arg>::type>>
|
||||
{
|
||||
return { *static_cast<typename Policies::_statement_t*>(this), limit_t<typename wrap_operand<Arg>::type>{{arg}} };
|
||||
}
|
||||
|
||||
auto dynamic_limit()
|
||||
-> _new_select_t<dynamic_limit_t<_database_t>>
|
||||
-> _new_statement_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::_statement_t*>(this), dynamic_limit_t<_database_t>{} };
|
||||
|
6
include/sqlpp11/vendor/offset.h
vendored
6
include/sqlpp11/vendor/offset.h
vendored
@ -112,17 +112,17 @@ namespace sqlpp
|
||||
{
|
||||
using _database_t = typename Policies::_database_t;
|
||||
template<typename T>
|
||||
using _new_select_t = typename Policies::template _policies_update_t<no_offset_t, T>;
|
||||
using _new_statement_t = typename Policies::template _new_statement_t<no_offset_t, T>;
|
||||
|
||||
template<typename Arg>
|
||||
auto offset(Arg arg)
|
||||
-> _new_select_t<offset_t<typename wrap_operand<Arg>::type>>
|
||||
-> _new_statement_t<offset_t<typename wrap_operand<Arg>::type>>
|
||||
{
|
||||
return { *static_cast<typename Policies::_statement_t*>(this), offset_t<typename wrap_operand<Arg>::type>{{arg}} };
|
||||
}
|
||||
|
||||
auto dynamic_offset()
|
||||
-> _new_select_t<dynamic_offset_t<_database_t>>
|
||||
-> _new_statement_t<dynamic_offset_t<_database_t>>
|
||||
{
|
||||
static_assert(not std::is_same<_database_t, void>::value, "dynamic_offset must not be called in a static statement");
|
||||
return { *static_cast<typename Policies::_statement_t*>(this), dynamic_offset_t<_database_t>{} };
|
||||
|
6
include/sqlpp11/vendor/order_by.h
vendored
6
include/sqlpp11/vendor/order_by.h
vendored
@ -103,18 +103,18 @@ namespace sqlpp
|
||||
{
|
||||
using _database_t = typename Policies::_database_t;
|
||||
template<typename T>
|
||||
using _new_select_t = typename Policies::template _policies_update_t<no_order_by_t, T>;
|
||||
using _new_statement_t = typename Policies::template _new_statement_t<no_order_by_t, T>;
|
||||
|
||||
template<typename... Args>
|
||||
auto order_by(Args... args)
|
||||
-> _new_select_t<order_by_t<void, Args...>>
|
||||
-> _new_statement_t<order_by_t<void, Args...>>
|
||||
{
|
||||
return { *static_cast<typename Policies::_statement_t*>(this), order_by_t<void, Args...>{args...} };
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
auto dynamic_order_by(Args... args)
|
||||
-> _new_select_t<order_by_t<_database_t, Args...>>
|
||||
-> _new_statement_t<order_by_t<_database_t, Args...>>
|
||||
{
|
||||
static_assert(not std::is_same<_database_t, void>::value, "dynamic_order_by must not be called in a static statement");
|
||||
return { *static_cast<typename Policies::_statement_t*>(this), vendor::order_by_t<_database_t, Args...>{args...} };
|
||||
|
6
include/sqlpp11/vendor/select_column_list.h
vendored
6
include/sqlpp11/vendor/select_column_list.h
vendored
@ -237,11 +237,11 @@ namespace sqlpp
|
||||
{
|
||||
using _database_t = typename Policies::_database_t;
|
||||
template<typename T>
|
||||
using _new_select_t = typename Policies::template _policies_update_t<no_select_column_list_t, T>;
|
||||
using _new_statement_t = typename Policies::template _new_statement_t<no_select_column_list_t, T>;
|
||||
|
||||
template<typename... Args>
|
||||
auto columns(Args... args)
|
||||
-> _new_select_t<select_column_list_t<void, Args...>>
|
||||
-> _new_statement_t<select_column_list_t<void, Args...>>
|
||||
{
|
||||
#warning need to handle all_of_t here
|
||||
return { *static_cast<typename Policies::_statement_t*>(this), select_column_list_t<void, Args...>{args...} };
|
||||
@ -249,7 +249,7 @@ namespace sqlpp
|
||||
|
||||
template<typename... Args>
|
||||
auto dynamic_columns(Args... args)
|
||||
-> _new_select_t<select_column_list_t<_database_t, Args...>>
|
||||
-> _new_statement_t<select_column_list_t<_database_t, Args...>>
|
||||
{
|
||||
static_assert(not std::is_same<_database_t, void>::value, "dynamic_columns must not be called in a static statement");
|
||||
return { *static_cast<typename Policies::_statement_t*>(this), vendor::select_column_list_t<_database_t, Args...>{args...} };
|
||||
|
6
include/sqlpp11/vendor/select_flag_list.h
vendored
6
include/sqlpp11/vendor/select_flag_list.h
vendored
@ -100,18 +100,18 @@ namespace sqlpp
|
||||
{
|
||||
using _database_t = typename Policies::_database_t;
|
||||
template<typename T>
|
||||
using _new_select_t = typename Policies::template _policies_update_t<no_select_flag_list_t, T>;
|
||||
using _new_statement_t = typename Policies::template _new_statement_t<no_select_flag_list_t, T>;
|
||||
|
||||
template<typename... Args>
|
||||
auto flags(Args... args)
|
||||
-> _new_select_t<select_flag_list_t<void, Args...>>
|
||||
-> _new_statement_t<select_flag_list_t<void, Args...>>
|
||||
{
|
||||
return { *static_cast<typename Policies::_statement_t*>(this), select_flag_list_t<void, Args...>{args...} };
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
auto dynamic_flags(Args... args)
|
||||
-> _new_select_t<select_flag_list_t<_database_t, Args...>>
|
||||
-> _new_statement_t<select_flag_list_t<_database_t, Args...>>
|
||||
{
|
||||
static_assert(not std::is_same<_database_t, void>::value, "dynamic_flags must not be called in a static statement");
|
||||
return { *static_cast<typename Policies::_statement_t*>(this), vendor::select_flag_list_t<_database_t, Args...>{args...} };
|
||||
|
6
include/sqlpp11/vendor/using.h
vendored
6
include/sqlpp11/vendor/using.h
vendored
@ -101,18 +101,18 @@ namespace sqlpp
|
||||
{
|
||||
using _database_t = typename Policies::_database_t;
|
||||
template<typename T>
|
||||
using _new_select_t = typename Policies::template _policies_update_t<no_using_t, T>;
|
||||
using _new_statement_t = typename Policies::template _new_statement_t<no_using_t, T>;
|
||||
|
||||
template<typename... Args>
|
||||
auto using_(Args... args)
|
||||
-> _new_select_t<using_t<void, Args...>>
|
||||
-> _new_statement_t<using_t<void, Args...>>
|
||||
{
|
||||
return { *static_cast<typename Policies::_statement_t*>(this), using_t<void, Args...>{args...} };
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
auto dynamic_using(Args... args)
|
||||
-> _new_select_t<using_t<_database_t, Args...>>
|
||||
-> _new_statement_t<using_t<_database_t, Args...>>
|
||||
{
|
||||
static_assert(not std::is_same<_database_t, void>::value, "dynamic_using must not be called in a static statement");
|
||||
return { *static_cast<typename Policies::_statement_t*>(this), vendor::using_t<_database_t, Args...>{args...} };
|
||||
|
6
include/sqlpp11/vendor/where.h
vendored
6
include/sqlpp11/vendor/where.h
vendored
@ -128,18 +128,18 @@ 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>;
|
||||
using _new_statement_t = typename Policies::template _new_statement_t<no_where_t, T>;
|
||||
|
||||
template<typename... Args>
|
||||
auto where(Args... args)
|
||||
-> _new_select_t<where_t<void, Args...>>
|
||||
-> _new_statement_t<where_t<void, Args...>>
|
||||
{
|
||||
return { *static_cast<typename Policies::_statement_t*>(this), where_t<void, Args...>{args...} };
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
auto dynamic_where(Args... args)
|
||||
-> _new_select_t<where_t<_database_t, Args...>>
|
||||
-> _new_statement_t<where_t<_database_t, Args...>>
|
||||
{
|
||||
static_assert(not std::is_same<_database_t, void>::value, "dynamic_where must not be called in a static statement");
|
||||
return { *static_cast<typename Policies::_statement_t*>(this), vendor::where_t<_database_t, Args...>{args...} };
|
||||
|
Loading…
Reference in New Issue
Block a user