diff --git a/include/sqlpp11/core/basic/table_as.h b/include/sqlpp11/core/basic/table_as.h index 924ea8f7..28c1e3b3 100644 --- a/include/sqlpp11/core/basic/table_as.h +++ b/include/sqlpp11/core/basic/table_as.h @@ -40,7 +40,6 @@ namespace sqlpp public enable_join> { using _nodes = detail::type_vector<>; - using _required_ctes = required_ctes_of; static_assert(required_tables_of_t::empty(), "table aliases must not depend on external tables"); diff --git a/include/sqlpp11/core/clause/cte.h b/include/sqlpp11/core/clause/cte.h index 36752dcf..04083c82 100644 --- a/include/sqlpp11/core/clause/cte.h +++ b/include/sqlpp11/core/clause/cte.h @@ -41,7 +41,7 @@ namespace sqlpp struct cte_union_t { using _nodes = detail::type_vector<>; - using _required_ctes = detail::make_joined_set_t, required_ctes_of>; + using _required_ctes = detail::type_vector_cat_t, required_ctes_of_t>; using _parameters = detail::type_vector_cat_t, parameters_of>; cte_union_t(Lhs lhs, Rhs rhs) : _lhs(lhs), _rhs(rhs) @@ -58,6 +58,21 @@ namespace sqlpp Rhs _rhs; }; + template + struct required_ctes_of> + { + using type = detail::type_vector_cat_t, required_ctes_of_t>; + }; + + template + struct required_static_ctes_of> + { + using type = typename std::conditional< + is_dynamic::value, + provided_static_ctes_of_t, + detail::type_vector_cat_t, provided_static_ctes_of_t>>::type; + }; + // Interpreters template auto to_sql_string(Context& context, const cte_union_t& t) -> std::string @@ -169,7 +184,7 @@ namespace sqlpp public enable_join> { #warning: Need to test this. - constexpr static bool _is_recursive = required_ctes_of::template count>(); + constexpr static bool _is_recursive = required_ctes_of_t::template contains>::value; using _column_tuple_t = std::tuple, FieldSpecs>...>; @@ -252,6 +267,17 @@ namespace sqlpp { }; + template + struct provided_ctes_of> + { + using type = detail::type_vector>; + }; + + template + struct provided_static_ctes_of> : public provided_ctes_of> + { + }; + template auto to_sql_string(Context& context, const cte_t& t) -> std::string { @@ -269,7 +295,7 @@ namespace sqlpp { static_assert(required_tables_of_t::empty(), "common table expression must not use unknown tables"); - static_assert(not required_ctes_of::template count(), + static_assert(not required_ctes_of_t::template contains::value, "common table expression must not self-reference in the first part, use union_all/union_distinct " "for recursion"); @@ -295,6 +321,17 @@ namespace sqlpp { }; + template + struct required_ctes_of> + { + using type = sqlpp::detail::type_vector>; + }; + + template + struct required_static_ctes_of> : public required_ctes_of> + { + }; + template auto to_sql_string(Context& context, const cte_ref_t&) -> std::string { diff --git a/include/sqlpp11/core/query/statement.h b/include/sqlpp11/core/query/statement.h index 894ca31f..91a72c90 100644 --- a/include/sqlpp11/core/query/statement.h +++ b/include/sqlpp11/core/query/statement.h @@ -75,14 +75,16 @@ namespace sqlpp template using _new_statement_t = typename _policies_update_t::type; - using _all_required_ctes = detail::make_joined_set_t...>; - using _all_provided_ctes = detail::make_joined_set_t...>; + using _all_required_ctes = detail::type_vector_cat_t...>; + using _all_provided_ctes = detail::type_vector_cat_t...>; using _all_required_tables = detail::type_vector_cat_t...>; using _all_provided_tables = detail::type_vector_cat_t...>; using _all_provided_optional_tables = detail::type_vector_cat_t...>; +#warning: provided_aggregates_of needs to be replaced with type_vector, too using _all_provided_aggregates = detail::make_joined_set_t...>; using _required_tables_of = detail::copy_if_t<_all_required_tables, _all_provided_tables::template contains_not>; + using _required_ctes_of = detail::copy_if_t<_all_required_ctes, _all_provided_ctes::template contains_not>; template static constexpr bool _no_unknown_tables = _all_provided_tables::template contains_all>::value; @@ -110,12 +112,6 @@ namespace sqlpp template