0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-16 04:47:18 +08:00

Add type_vector::transform

plus minor refactoring
This commit is contained in:
Roland Bock 2024-08-28 10:44:14 +02:00
parent c0ad5e0696
commit 6e7d05d6db
5 changed files with 17 additions and 16 deletions

View File

@ -63,6 +63,10 @@ namespace sqlpp
using type = detail::make_joined_set_t<provided_tables_of_t<Lhs>, detail::type_set<dynamic_t<Rhs>>>;
};
#warning: We need to quarantee that no tables are required by join and dynamic provision vs requirements need to be checked upon calling `on`.
#warning: We should mix dynamic and optional into the provided_tables_of (instead of having separate traits for each).
#warning: it might be great to search for missing tables and return something like `missing_table_for<column_t<SomeSpec>>`.
template <typename Lhs, typename JoinType, typename Rhs, typename Condition>
struct provided_optional_tables_of<join_t<Lhs, JoinType, Rhs, Condition>>
{

View File

@ -232,7 +232,7 @@ namespace sqlpp
struct has_correct_aggregates<KnownAggregateColumns, select_column_list_t<Columns...>>
: public std::integral_constant<
bool,
(detail::type_vector_size<KnownAggregateColumns>::value == 0 and
(KnownAggregateColumns::empty() and
logic::none<contains_aggregate_function<remove_dynamic_t<remove_as_t<Columns>>>::value...>::value) or
logic::all<is_aggregate_expression<KnownAggregateColumns,
remove_dynamic_t<remove_as_t<Columns>>>::value...>::value>

View File

@ -38,6 +38,15 @@ namespace sqlpp
{
template<typename X>
using contains = std::integral_constant<bool, ::sqlpp::logic::any<std::is_same<T, X>::value...>::value>;
template <template <typename> class Transform>
using transform = type_vector<typename Transform<T>::type...>;
static constexpr bool size = sizeof...(T);
static constexpr bool empty() {
return size == 0;
}
};
template <typename... T>
@ -73,17 +82,5 @@ namespace sqlpp
template <typename... T>
using type_vector_cat_t = typename type_vector_cat_impl<T...>::type;
template <typename T>
struct type_vector_size
{
static_assert(wrong_t<type_vector_size>::value,
"type_vector_size needs to be called with a type_vector argument");
};
template <typename... T>
struct type_vector_size<type_vector<T...>>
{
static constexpr std::size_t value = sizeof...(T);
};
} // namespace detail
} // namespace sqlpp

View File

@ -69,7 +69,7 @@ namespace sqlpp
using _nodes = detail::type_vector<Parts...>;
using _parameter_check =
typename std::conditional<detail::type_vector_size<parameters_of<custom_query_t>>::value == 0,
typename std::conditional<parameters_of<custom_query_t>::empty(),
consistent_t,
assert_no_parameters_t>::type;
using _run_check = detail::get_first_if<is_inconsistent_t, consistent_t, _parameter_check>;

View File

@ -150,7 +150,7 @@ namespace sqlpp
using _table_check =
typename std::conditional<_required_tables::size::value == 0, consistent_t, assert_no_unknown_tables_t>::type;
using _parameter_check = typename std::
conditional<detail::type_vector_size<_parameters>::value == 0, consistent_t, assert_no_parameters_t>::type;
conditional<_parameters::empty(), consistent_t, assert_no_parameters_t>::type;
};
} // namespace detail
@ -233,7 +233,7 @@ namespace sqlpp
static constexpr size_t _get_static_no_of_parameters()
{
return detail::type_vector_size<parameters_of<statement_t>>::value;
return parameters_of<statement_t>::size;
}
size_t _get_no_of_parameters() const