From 31cb9c31ab679dbc22c22e2f941538e7475f8168 Mon Sep 17 00:00:00 2001 From: Roland Bock Date: Fri, 30 Aug 2024 13:28:12 +0200 Subject: [PATCH] Continued required/provided table improvements --- include/sqlpp11/core/basic/join.h | 21 +++----------------- include/sqlpp11/core/basic/join_fwd.h | 8 ++++---- include/sqlpp11/core/basic/table.h | 4 ++-- include/sqlpp11/core/clause/from.h | 7 ++----- include/sqlpp11/core/detail/type_set.h | 16 --------------- include/sqlpp11/core/detail/type_vector.h | 6 ++++++ include/sqlpp11/core/name/char_sequence.h | 11 +++++++--- include/sqlpp11/core/query/statement.h | 2 +- include/sqlpp11/core/type_traits.h | 14 ++++++++----- include/sqlpp11/core/type_traits/tables_of.h | 5 ++--- tests/core/serialize/basic/join.cpp | 1 + 11 files changed, 38 insertions(+), 57 deletions(-) diff --git a/include/sqlpp11/core/basic/join.h b/include/sqlpp11/core/basic/join.h index 9fdc5fa1..79b9f4f3 100644 --- a/include/sqlpp11/core/basic/join.h +++ b/include/sqlpp11/core/basic/join.h @@ -28,6 +28,7 @@ #include #include +#include namespace sqlpp { @@ -57,21 +58,6 @@ namespace sqlpp using type = sqlpp::detail::type_vector; }; - template - struct provided_tables_of, Condition>> - { - using type = detail::make_joined_set_t, detail::type_set>>; - }; - -#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>`. - - template - struct is_dynamic : public std::false_type {}; - template - struct is_dynamic> : public std::true_type {}; - template struct provided_tables_of> { @@ -83,8 +69,8 @@ namespace sqlpp { using type = typename std::conditional< is_dynamic::value, - provided_static_tables_of, - detail::type_vector_cat_t, provided_static_tables_of>>::type; + provided_static_tables_of_t, + detail::type_vector_cat_t, provided_static_tables_of_t>>::type; }; template @@ -141,7 +127,6 @@ namespace sqlpp } #warning: Verify that the Expr does not require tables other than Lhs, Rhs - //and detail::make_joined_set_t, provided_tables_of_t>::is_superset_of::value template struct are_table_requirements_satisfied : std::integral_constant #include #include -#include +#include namespace sqlpp { @@ -69,9 +69,9 @@ namespace sqlpp template using check_join_args = sqlpp::enable_if_t::value and is_table>::value and - required_tables_of_t::size::value == 0 and required_tables_of_t::size::value == 0 and - detail::is_disjunct_from>, - detail::make_name_of_set_t>>::value>; + required_tables_of_t::empty() and required_tables_of_t::empty() and + sqlpp::detail::transform_t, make_char_sequence>::contains_none( + sqlpp::detail::transform_t, make_char_sequence>{})>; template > auto join(Lhs lhs, Rhs rhs) -> pre_join_t; diff --git a/include/sqlpp11/core/basic/table.h b/include/sqlpp11/core/basic/table.h index 19128f10..62ddeeaa 100644 --- a/include/sqlpp11/core/basic/table.h +++ b/include/sqlpp11/core/basic/table.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include namespace sqlpp @@ -66,7 +66,7 @@ namespace sqlpp template struct provided_tables_of> { - using type = sqlpp::detail::type_set>; + using type = sqlpp::detail::type_vector>; }; template diff --git a/include/sqlpp11/core/clause/from.h b/include/sqlpp11/core/clause/from.h index c3e5e0e2..a58ac405 100644 --- a/include/sqlpp11/core/clause/from.h +++ b/include/sqlpp11/core/clause/from.h @@ -76,7 +76,6 @@ namespace sqlpp "from() argument is a pre join, please use an explicit on() condition or unconditionally()"); SQLPP_PORTABLE_STATIC_ASSERT(assert_from_table_t, "from() argument has to be a table or join expression"); SQLPP_PORTABLE_STATIC_ASSERT(assert_from_dependency_free_t, "at least one table depends on another table in from()"); - SQLPP_PORTABLE_STATIC_ASSERT(assert_from_no_duplicates_t, "at least one duplicate table name detected in from()"); template struct check_from @@ -84,10 +83,8 @@ namespace sqlpp using type = static_combined_check_t< static_check_t::value, assert_from_not_pre_join_t>, static_check_t::value, assert_from_table_t>, - static_check_t::size::value == 0, assert_from_dependency_free_t>, - static_check_t::size::value == - detail::make_name_of_set_t>::size::value, - assert_from_no_duplicates_t>>; + static_check_t::size::value == 0, assert_from_dependency_free_t> + >; }; template diff --git a/include/sqlpp11/core/detail/type_set.h b/include/sqlpp11/core/detail/type_set.h index 27b7665b..cd93b1fd 100644 --- a/include/sqlpp11/core/detail/type_set.h +++ b/include/sqlpp11/core/detail/type_set.h @@ -260,21 +260,5 @@ namespace sqlpp template