From e39444b0f70e613b0008fdc760d773538a50d7f2 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 19 May 2014 06:42:45 +0200 Subject: [PATCH] Added tags missing and return_value missing indicates that a statement part has yet to be added (e.g. columns in a select). return_value indicates that a statement part can be used as a return value. --- include/sqlpp11/detail/type_set.h | 3 +++ include/sqlpp11/select.h | 4 ++-- include/sqlpp11/type_traits.h | 2 ++ include/sqlpp11/vendor/select_column_list.h | 6 +++--- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/sqlpp11/detail/type_set.h b/include/sqlpp11/detail/type_set.h index 64a2b005..ecc51a23 100644 --- a/include/sqlpp11/detail/type_set.h +++ b/include/sqlpp11/detail/type_set.h @@ -157,6 +157,9 @@ namespace sqlpp using type = typename make_type_set_if::type::template insert_if::type; }; + template class Predicate, typename... T> + using make_type_set_if_t = typename make_type_set_if::type; + template class Predicate, typename... T> struct make_type_set_if_not { diff --git a/include/sqlpp11/select.h b/include/sqlpp11/select.h index da752636..2f5dc271 100644 --- a/include/sqlpp11/select.h +++ b/include/sqlpp11/select.h @@ -145,9 +145,9 @@ namespace sqlpp >::type; using _value_type = typename std::conditional< - is_select_column_list_t<_column_list_t>::value and is_subset_of, provided_tables_of<_from_t>>::value, + detail::make_type_set_if_t::size::value == 0, value_type_of<_column_list_t>, - no_value_t // If something is selected that requires a table, then we require a from for this to be a value + no_value_t // if a required statement part is missing (columns in a select), then the statement cannot be used as a value >::type; using _traits = make_traits<_value_type>; diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 66243bc2..a1f231c5 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -106,6 +106,8 @@ namespace sqlpp SQLPP_IS_COLUMN_TRAIT_GENERATOR(trivial_value_is_null); SQLPP_IS_VALUE_TRAIT_GENERATOR(noop); + SQLPP_IS_VALUE_TRAIT_GENERATOR(missing); + SQLPP_IS_VALUE_TRAIT_GENERATOR(return_value); SQLPP_IS_VALUE_TRAIT_GENERATOR(table); SQLPP_IS_VALUE_TRAIT_GENERATOR(join); SQLPP_IS_VALUE_TRAIT_GENERATOR(pseudo_table); diff --git a/include/sqlpp11/vendor/select_column_list.h b/include/sqlpp11/vendor/select_column_list.h index 1f160d16..ce98c227 100644 --- a/include/sqlpp11/vendor/select_column_list.h +++ b/include/sqlpp11/vendor/select_column_list.h @@ -47,14 +47,14 @@ namespace sqlpp template struct get_first_argument_if_unique { - using _traits = make_traits; + using _traits = make_traits; struct _name_t {}; }; template struct get_first_argument_if_unique { - using _traits = make_traits, tag::select_column_list, tag::expression, tag::named_expression>; + using _traits = make_traits, tag::select_column_list, tag::return_value, tag::expression, tag::named_expression>; using _name_t = typename T::_name_t; }; } @@ -239,7 +239,7 @@ namespace sqlpp { struct no_select_column_list_t { - using _traits = make_traits; + using _traits = make_traits; using _recursive_traits = make_recursive_traits<>; template