diff --git a/include/sqlpp11/from.h b/include/sqlpp11/from.h index 74babb1e..00a9a2e7 100644 --- a/include/sqlpp11/from.h +++ b/include/sqlpp11/from.h @@ -28,6 +28,7 @@ #define SQLPP_FROM_H #include +#include #include #include #include @@ -60,7 +61,7 @@ namespace sqlpp using _traits = make_traits; using _recursive_traits = make_recursive_traits; - using _is_dynamic = typename std::conditional::value, std::false_type, std::true_type>::type; + using _is_dynamic = is_database; static_assert(_is_dynamic::value or sizeof...(Tables), "at least one table or join argument required in from()"); diff --git a/include/sqlpp11/group_by.h b/include/sqlpp11/group_by.h index 8e369b0c..f5c8bb56 100644 --- a/include/sqlpp11/group_by.h +++ b/include/sqlpp11/group_by.h @@ -62,7 +62,7 @@ namespace sqlpp using _traits = make_traits; using _recursive_traits = make_recursive_traits; - using _is_dynamic = typename std::conditional::value, std::false_type, std::true_type>::type; + using _is_dynamic = is_database; static_assert(_is_dynamic::value or sizeof...(Expressions), "at least one expression (e.g. a column) required in group_by()"); diff --git a/include/sqlpp11/having.h b/include/sqlpp11/having.h index d50f5600..9fc1d410 100644 --- a/include/sqlpp11/having.h +++ b/include/sqlpp11/having.h @@ -61,7 +61,7 @@ namespace sqlpp using _traits = make_traits; using _recursive_traits = make_recursive_traits; - using _is_dynamic = typename std::conditional::value, std::false_type, std::true_type>::type; + using _is_dynamic = is_database; static_assert(_is_dynamic::value or sizeof...(Expressions), "at least one expression argument required in having()"); static_assert(::sqlpp::detail::all_t::value...>::value, "at least one argument is not an expression in having()"); diff --git a/include/sqlpp11/insert_value_list.h b/include/sqlpp11/insert_value_list.h index 831a6752..6a0f804c 100644 --- a/include/sqlpp11/insert_value_list.h +++ b/include/sqlpp11/insert_value_list.h @@ -106,7 +106,7 @@ namespace sqlpp using _traits = make_traits; using _recursive_traits = make_recursive_traits; - using _is_dynamic = typename std::conditional::value, std::false_type, std::true_type>::type; + using _is_dynamic = is_database; template class Target> using copy_assignments_t = Target; // FIXME: Nice idea to copy variadic template arguments? diff --git a/include/sqlpp11/into.h b/include/sqlpp11/into.h index fd2a08e4..3c6c388c 100644 --- a/include/sqlpp11/into.h +++ b/include/sqlpp11/into.h @@ -29,6 +29,7 @@ #include #include +#include #include #include #include diff --git a/include/sqlpp11/noop.h b/include/sqlpp11/noop.h index 74198fd0..e28ae330 100644 --- a/include/sqlpp11/noop.h +++ b/include/sqlpp11/noop.h @@ -33,20 +33,6 @@ namespace sqlpp { -#warning: Need extra include file for no_data - struct no_data_t {}; - - template - struct serializer_t - { - using T = no_data_t; - - static Context& _(const T& t, Context& context) - { - return context; - } - }; - struct noop { using _traits = make_traits; diff --git a/include/sqlpp11/on.h b/include/sqlpp11/on.h index 26b93a9f..69f91c11 100644 --- a/include/sqlpp11/on.h +++ b/include/sqlpp11/on.h @@ -40,7 +40,7 @@ namespace sqlpp using _traits = make_traits; using _recursive_traits = make_recursive_traits; - using _is_dynamic = typename std::conditional::value, std::false_type, std::true_type>::type; + using _is_dynamic = is_database; static_assert(_is_dynamic::value or sizeof...(Expr), "at least one expression argument required in on()"); static_assert(detail::all_t::value...>::value, "at least one argument is not an expression in on()"); diff --git a/include/sqlpp11/order_by.h b/include/sqlpp11/order_by.h index 0f9fdc75..a82ac900 100644 --- a/include/sqlpp11/order_by.h +++ b/include/sqlpp11/order_by.h @@ -62,7 +62,7 @@ namespace sqlpp using _traits = make_traits; using _recursive_traits = make_recursive_traits; - using _is_dynamic = typename std::conditional::value, std::false_type, std::true_type>::type; + using _is_dynamic = is_database; static_assert(_is_dynamic::value or sizeof...(Expressions), "at least one expression (e.g. a column) required in order_by()"); diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index fe832ab8..eb14feb1 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -129,8 +129,6 @@ namespace sqlpp template struct select_column_list_data_t { - using _is_dynamic = typename std::conditional::value, std::false_type, std::true_type>::type; - select_column_list_data_t(Columns... columns): _columns(columns...) {} @@ -159,12 +157,11 @@ namespace sqlpp using _name_t = typename ::sqlpp::detail::select_traits::_name_t; - using _is_dynamic = typename std::conditional::value, std::false_type, std::true_type>::type; + using _is_dynamic = is_database; + static_assert(_is_dynamic::value or sizeof...(Columns), "at least one select expression required"); static_assert(not ::sqlpp::detail::has_duplicates::value, "at least one duplicate argument detected"); - static_assert(::sqlpp::detail::all_t<(is_named_expression_t::value or is_multi_column_t::value)...>::value, "at least one argument is not a named expression"); - static_assert(not ::sqlpp::detail::has_duplicates::value, "at least one duplicate name detected"); struct _column_type {}; @@ -383,9 +380,6 @@ namespace sqlpp static Context& _(const T& t, Context& context) { - // check for at least one expression - static_assert(T::_is_dynamic::value or sizeof...(Columns), "at least one select expression required"); - interpret_tuple(t._columns, ',', context); if (sizeof...(Columns) and not t._dynamic_columns.empty()) context << ','; diff --git a/include/sqlpp11/select_flag_list.h b/include/sqlpp11/select_flag_list.h index 8147e5d2..8932b896 100644 --- a/include/sqlpp11/select_flag_list.h +++ b/include/sqlpp11/select_flag_list.h @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -61,7 +62,7 @@ namespace sqlpp using _traits = make_traits; using _recursive_traits = make_recursive_traits; - using _is_dynamic = typename std::conditional::value, std::false_type, std::true_type>::type; + using _is_dynamic = is_database; static_assert(not ::sqlpp::detail::has_duplicates::value, "at least one duplicate argument detected in select flag list"); diff --git a/include/sqlpp11/single_table.h b/include/sqlpp11/single_table.h index 31d667e2..e2a83a9e 100644 --- a/include/sqlpp11/single_table.h +++ b/include/sqlpp11/single_table.h @@ -29,6 +29,7 @@ #include #include +#include #include #include #include diff --git a/include/sqlpp11/statement.h b/include/sqlpp11/statement.h index 52ddeb68..b5e1bc5a 100644 --- a/include/sqlpp11/statement.h +++ b/include/sqlpp11/statement.h @@ -43,8 +43,6 @@ namespace sqlpp template struct statement_t; -#warning STEPS: -#warning deal with different return types in the connector (select could be a single value, update could be a range of rows) namespace detail { template @@ -115,7 +113,7 @@ namespace sqlpp using _required_tables = _required_tables; using _provided_tables = detail::type_set<>; using _extra_tables = detail::type_set<>; - using _parameters = detail::make_parameter_list_t...>; + using _parameters = detail::make_parameter_tuple_t...>; }; }; } @@ -161,9 +159,7 @@ namespace sqlpp static constexpr size_t _get_static_no_of_parameters() { -#warning need to fix this - return 0; - //return _parameter_list_t::size::value; + return std::tuple_size>::value; } size_t _get_no_of_parameters() const diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 9fd8376b..4cd4fdf2 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -126,7 +126,6 @@ namespace sqlpp SQLPP_IS_VALUE_TRAIT_GENERATOR(into); SQLPP_IS_VALUE_TRAIT_GENERATOR(extra_tables); SQLPP_IS_VALUE_TRAIT_GENERATOR(on); - SQLPP_IS_VALUE_TRAIT_GENERATOR(dynamic); SQLPP_IS_VALUE_TRAIT_GENERATOR(where); SQLPP_IS_VALUE_TRAIT_GENERATOR(group_by); SQLPP_IS_VALUE_TRAIT_GENERATOR(having); @@ -150,6 +149,9 @@ namespace sqlpp SQLPP_CONNECTOR_TRAIT_GENERATOR(null_result_is_trivial_value); SQLPP_CONNECTOR_TRAIT_GENERATOR(assert_result_validity); + template + using is_database = typename std::conditional::value, std::false_type, std::true_type>::type; + template class IsTag> using copy_type_trait = typename std::conditional::value, std::true_type, std::false_type>::type; @@ -186,14 +188,13 @@ namespace sqlpp }; template - struct make_parameter_list_impl + struct make_parameter_tuple_impl { using type = decltype(std::tuple_cat(std::declval()...)); }; -#warning this will lead to confusion with ::sqlpp::make_parameter_list_t in parameter_list.h template - using make_parameter_list_t = typename make_parameter_list_impl::type; + using make_parameter_tuple_t = typename make_parameter_tuple_impl::type; } template using value_type_of = typename detail::value_type_of_impl::type; @@ -222,7 +223,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...>; - using _parameters = detail::make_parameter_list_t...>; + using _parameters = detail::make_parameter_tuple_t...>; }; } diff --git a/include/sqlpp11/update_list.h b/include/sqlpp11/update_list.h index e09be547..a5f9b7a4 100644 --- a/include/sqlpp11/update_list.h +++ b/include/sqlpp11/update_list.h @@ -58,7 +58,7 @@ namespace sqlpp { using _traits = make_traits; using _recursive_traits = make_recursive_traits; - using _is_dynamic = typename std::conditional::value, std::false_type, std::true_type>::type; + using _is_dynamic = is_database; static_assert(_is_dynamic::value or sizeof...(Assignments), "at least one assignment expression required in set()"); diff --git a/include/sqlpp11/using.h b/include/sqlpp11/using.h index 0d345906..b8423bc0 100644 --- a/include/sqlpp11/using.h +++ b/include/sqlpp11/using.h @@ -60,7 +60,7 @@ namespace sqlpp using _traits = make_traits; using _recursive_traits = make_recursive_traits; - using _is_dynamic = typename std::conditional::value, std::false_type, std::true_type>::type; + using _is_dynamic = is_database; static_assert(_is_dynamic::value or sizeof...(Tables), "at least one table argument required in using()"); diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index 8c9446e7..b19e7123 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -61,8 +61,7 @@ namespace sqlpp using _traits = make_traits; using _recursive_traits = make_recursive_traits; -#warning: is_dynamic should be using a template alias (making it easier to replace the logic) - using _is_dynamic = typename std::conditional::value, std::false_type, std::true_type>::type; + using _is_dynamic = is_database; static_assert(_is_dynamic::value or sizeof...(Expressions), "at least one expression argument required in where()"); static_assert(sqlpp::detail::none_t::value...>::value, "at least one argument is an assignment in where()");