From 6972758931401ebfd1ecacc860fccd04a30da8b6 Mon Sep 17 00:00:00 2001 From: rbock Date: Fri, 16 May 2014 09:33:48 +0200 Subject: [PATCH] Added extra_tables to recursive_traits --- include/sqlpp11/column.h | 2 ++ include/sqlpp11/parameter.h | 8 +++++++- include/sqlpp11/select.h | 2 +- include/sqlpp11/table.h | 1 + include/sqlpp11/type_traits.h | 10 ++++++++++ include/sqlpp11/vendor/extra_tables.h | 8 ++++++++ 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/include/sqlpp11/column.h b/include/sqlpp11/column.h index 8795a08b..383f94cc 100644 --- a/include/sqlpp11/column.h +++ b/include/sqlpp11/column.h @@ -48,8 +48,10 @@ namespace sqlpp using _traits = make_traits; struct _recursive_traits { + using _parameters = std::tuple<>; using _provided_tables = detail::type_set<>; using _required_tables = detail::type_set; + using _extra_tables = detail::type_set<>; }; using _spec_t = ColumnSpec; diff --git a/include/sqlpp11/parameter.h b/include/sqlpp11/parameter.h index d13afdbf..b3769639 100644 --- a/include/sqlpp11/parameter.h +++ b/include/sqlpp11/parameter.h @@ -37,7 +37,13 @@ namespace sqlpp struct parameter_t: public ValueType::template expression_operators> { using _traits = make_traits; - using _recursive_traits = make_recursive_traits<>; + struct _recursive_traits + { + using _parameters = std::tuple; + using _provided_tables = detail::type_set<>; + using _required_tables = detail::type_set<>; + using _extra_tables = detail::type_set<>; + }; using _instance_t = typename NameType::_name_t::template _member_t; diff --git a/include/sqlpp11/select.h b/include/sqlpp11/select.h index 66eafd90..ee36c6bc 100644 --- a/include/sqlpp11/select.h +++ b/include/sqlpp11/select.h @@ -112,7 +112,7 @@ namespace sqlpp static_assert(is_noop_t::value or sqlpp::is_select_column_list_t::value, "column list of select is neither naught nor a valid column list"); static_assert(is_noop_t::value or sqlpp::is_from_t::value, "from() part of select is neither naught nor a valid from()"); - using _known_tables = detail::make_joined_set_t, provided_tables_of<_extra_tables_t>>; // FIXME, use provided_tables_of; + using _known_tables = detail::make_joined_set_t, extra_tables_of<_extra_tables_t>>; template using _no_unknown_tables = detail::is_subset_of, _known_tables>; diff --git a/include/sqlpp11/table.h b/include/sqlpp11/table.h index a77120ea..5f74da41 100644 --- a/include/sqlpp11/table.h +++ b/include/sqlpp11/table.h @@ -49,6 +49,7 @@ namespace sqlpp using _parameters = std::tuple<>; using _required_tables = detail::type_set<>; using _provided_tables = detail::type_set
; + using _extra_tables = detail::type_set<>; }; static_assert(sizeof...(ColumnSpec), "at least one column required per table"); diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index fe2c901d..66243bc2 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -162,6 +162,12 @@ namespace sqlpp { using type = typename T::_recursive_traits::_provided_tables; }; + + template + struct extra_table_of_impl + { + using type = typename T::_recursive_traits::_extra_tables; + }; } template using value_type_of = typename detail::value_type_of_impl::type; @@ -172,6 +178,9 @@ namespace sqlpp template using provided_tables_of = typename detail::provided_table_of_impl::type; + template + using extra_tables_of = typename detail::extra_table_of_impl::type; + template struct make_traits { @@ -183,6 +192,7 @@ namespace sqlpp { using _required_tables = detail::make_joined_set_t...>; using _provided_tables = detail::make_joined_set_t...>; + using _extra_tables = detail::make_joined_set_t...>; }; } diff --git a/include/sqlpp11/vendor/extra_tables.h b/include/sqlpp11/vendor/extra_tables.h index 36fb431a..040b5c5f 100644 --- a/include/sqlpp11/vendor/extra_tables.h +++ b/include/sqlpp11/vendor/extra_tables.h @@ -40,6 +40,14 @@ namespace sqlpp struct extra_tables_t { using _traits = make_traits; + struct _recursive_traits + { + using _parameters = std::tuple<>; + using _required_tables = ::sqlpp::detail::type_set<>; + using _provided_tables = ::sqlpp::detail::type_set<>; + using _extra_tables = ::sqlpp::detail::type_set; + }; + using _recursive_traits = make_recursive_traits; // FIXME: extra_tables must not require tables!