From 2266787e94de83e7f11b9ad7b4911310a4b1f735 Mon Sep 17 00:00:00 2001 From: rbock Date: Thu, 26 Jun 2014 14:35:49 +0200 Subject: [PATCH] Fixed another few warnings --- include/sqlpp11/insert_value_list.h | 68 ++++++++++++----------------- include/sqlpp11/update_list.h | 6 +-- 2 files changed, 30 insertions(+), 44 deletions(-) diff --git a/include/sqlpp11/insert_value_list.h b/include/sqlpp11/insert_value_list.h index f4b86616..f02d7a47 100644 --- a/include/sqlpp11/insert_value_list.h +++ b/include/sqlpp11/insert_value_list.h @@ -116,24 +116,6 @@ namespace sqlpp template class Target, template class Wrap> using copy_wrapped_assignments_t = Target...>; - static_assert(_is_dynamic::value or sizeof...(Assignments), "at least one assignment required in set()"); - - static_assert(not ::sqlpp::detail::has_duplicates::value, "at least one duplicate argument detected in set()"); - - static_assert(sqlpp::detail::all_t::value...>::value, "at least one argument is not an assignment in set()"); - - static_assert(sqlpp::detail::none_t::value...>::value, "at least one assignment is prohibited by its column definition in set()"); - -#warning: Need to reactivate these checks - /* - using _column_required_tables = typename ::sqlpp::detail::make_joined_set::type; - using _value_required_tables = typename ::sqlpp::detail::make_joined_set::type; - using _provided_tables = ::sqlpp::detail::type_set<>; - using _required_tables = typename ::sqlpp::detail::make_joined_set<_column_required_tables, _value_required_tables>::type; - static_assert(sizeof...(Assignments) ? (_column_required_tables::size::value == 1) : true, "set() contains assignments for tables from several columns"); - static_assert(::sqlpp::detail::is_subset_of<_value_required_tables, _column_required_tables>::value, "set() contains values from foreign tables"); - */ - // Data using _data_t = insert_list_data_t; @@ -152,14 +134,14 @@ namespace sqlpp { static_assert(_is_dynamic::value, "add must not be called for static from()"); static_assert(is_assignment_t::value, "add() arguments require to be assigments"); + using _assigned_columns = detail::make_type_set_t; + static_assert(not detail::is_element_of::value, "Must not assign value to column twice"); static_assert(not must_not_insert_t::value, "add() argument must not be used in insert"); static_assert(not TableCheckRequired::value or Policies::template _no_unknown_tables::value, "add() contains a column from a foreign table"); using ok = ::sqlpp::detail::all_t< _is_dynamic::value, - is_assignment_t::value, - not must_not_insert_t::value, - (not TableCheckRequired::value or Policies::template _no_unknown_tables::value)>; + is_assignment_t::value>; _add_impl(assignment, ok()); // dispatch to prevent compile messages after the static_assert } @@ -217,7 +199,6 @@ namespace sqlpp column_list_data_t& operator=(column_list_data_t&&) = default; ~column_list_data_t() = default; -#warning need to define just one version of value_tuple_t using _value_tuple_t = std::tuple...>; std::tuple...> _columns; std::vector<_value_tuple_t> _insert_values; @@ -237,7 +218,7 @@ namespace sqlpp static_assert(::sqlpp::detail::none_t::value...>::value, "at least one column argument has a must_not_insert flag in its definition"); - using _value_tuple_t = std::tuple...>; + using _value_tuple_t = typename column_list_data_t::_value_tuple_t; static_assert(required_tables_of::size::value == 1, "columns from multiple tables in columns()"); @@ -299,17 +280,9 @@ namespace sqlpp { static void _check_consistency() {} }; - - /* - bool empty() const - { - return _insert_values.empty(); - } - */ - }; - // NO HAVING YET + // NO INSERT COLUMNS/VALUES YET struct no_insert_value_list_t { using _traits = make_traits; @@ -364,19 +337,34 @@ namespace sqlpp return { *static_cast(this), column_list_data_t{args...} }; } - template - auto set(Args... args) - -> _new_statement_t> + template + auto set(Assignments... assignments) + -> _new_statement_t> { - return { *static_cast(this), insert_list_data_t{args...} }; + static_assert(sizeof...(Assignments), "at least one assignment expression required in set()"); + return _set_impl(assignments...); } - template - auto dynamic_set(Args... args) - -> _new_statement_t> + template + auto dynamic_set(Assignments... assignments) + -> _new_statement_t> { static_assert(not std::is_same<_database_t, void>::value, "dynamic_set must not be called in a static statement"); - return { *static_cast(this), insert_list_data_t<_database_t, Args...>{args...} }; + return _set_impl<_database_t>(assignments...); + } + private: + template + auto _set_impl(Assignments... assignments) + -> _new_statement_t> + { + static_assert(not ::sqlpp::detail::has_duplicates::value, "at least one duplicate argument detected in set()"); + static_assert(sqlpp::detail::all_t::value...>::value, "at least one argument is not an assignment in set()"); + static_assert(sqlpp::detail::none_t::value...>::value, "at least one assignment is prohibited by its column definition in set()"); + + using _column_required_tables = typename ::sqlpp::detail::make_joined_set...>::type; + static_assert(sizeof...(Assignments) ? (_column_required_tables::size::value == 1) : true, "set() contains assignments for columns from several tables"); + + return { *static_cast(this), insert_list_data_t{assignments...} }; } }; }; diff --git a/include/sqlpp11/update_list.h b/include/sqlpp11/update_list.h index 1f058a1a..903bac66 100644 --- a/include/sqlpp11/update_list.h +++ b/include/sqlpp11/update_list.h @@ -194,10 +194,8 @@ namespace sqlpp static_assert(::sqlpp::detail::all_t::value...>::value, "at least one argument is not an assignment in set()"); static_assert(::sqlpp::detail::none_t::value...>::value, "at least one assignment is prohibited by its column definition in set()"); - using _column_table_set = typename ::sqlpp::detail::make_joined_set...>::type; - using _value_table_set = typename ::sqlpp::detail::make_joined_set...>::type; - static_assert(sizeof...(Assignments) ? (_column_table_set::size::value == 1) : true, "set() contains assignments for columns from more than one table"); - static_assert(::sqlpp::detail::is_subset_of<_value_table_set, _column_table_set>::value, "set() contains values from foreign tables"); + using _column_required_tables = typename ::sqlpp::detail::make_joined_set...>::type; + static_assert(sizeof...(Assignments) ? (_column_required_tables::size::value == 1) : true, "set() contains assignments for columns from more than one table"); return { *static_cast(this), update_list_data_t{assignments...} }; }