diff --git a/include/sqlpp11/core/basic/join.h b/include/sqlpp11/core/basic/join.h index 2182ebae..461ceb3b 100644 --- a/include/sqlpp11/core/basic/join.h +++ b/include/sqlpp11/core/basic/join.h @@ -77,10 +77,10 @@ namespace sqlpp struct provided_optional_tables_of> { using type = detail::type_vector_cat_t< - typename std::conditional::contains(), + typename std::conditional::contains::value, provided_tables_of_t, detail::type_vector<>>::type, - typename std::conditional::contains(), + typename std::conditional::contains::value, provided_tables_of_t, detail::type_vector<>>::type>; }; @@ -142,9 +142,9 @@ namespace sqlpp #warning: Verify that the Expr does not require tables other than Lhs, Rhs template struct are_table_requirements_satisfied - : std::integral_constant{}) and - AllTableTypeVector::contains_all(required_tables_of_t{})> + : public std::integral_constant>::value and + AllTableTypeVector::template contains_all>::value> { }; diff --git a/include/sqlpp11/core/clause/cte.h b/include/sqlpp11/core/clause/cte.h index 7ee3c801..d72ca54b 100644 --- a/include/sqlpp11/core/clause/cte.h +++ b/include/sqlpp11/core/clause/cte.h @@ -118,7 +118,7 @@ namespace sqlpp template struct cte_base { - using type = member_t, column_t>>; + using type = member_t>>; }; template @@ -229,11 +229,8 @@ namespace sqlpp template auto to_sql_string(Context& context, const cte_t& t) -> std::string { - using T = cte_t; - context << name_tag_of_t::template char_ptr() << " AS ("; - to_sql_string(context, t._statement); - context << ")"; - return context; + return name_to_sql_string(context, name_tag_of_t::name) + " AS (" + + to_sql_string(context, t._statement) + ")"; } // The cte_t is displayed as NameTagProviderName except within the with: @@ -250,7 +247,7 @@ namespace sqlpp template auto as(Statement statement) -> make_cte_t { - static_assert(required_tables_of_t::size::value == 0, + static_assert(required_tables_of_t::empty(), "common table expression must not use unknown tables"); static_assert(not required_ctes_of::template count(), "common table expression must not self-reference in the first part, use union_all/union_distinct " @@ -270,12 +267,11 @@ namespace sqlpp template auto to_sql_string(Context& context, const cte_ref_t&) -> std::string { - context << name_tag_of_t>::template char_ptr(); - return context; + return name_to_sql_string(context, name_tag_of_t::name); } template - auto cte(const NameTagProvider & /*unused*/) -> cte_ref_t + auto cte(const NameTagProvider& /*unused*/) -> cte_ref_t { return {}; } diff --git a/include/sqlpp11/core/clause/limit.h b/include/sqlpp11/core/clause/limit.h index f94678cb..ce57a845 100644 --- a/include/sqlpp11/core/clause/limit.h +++ b/include/sqlpp11/core/clause/limit.h @@ -80,7 +80,7 @@ namespace sqlpp { #warning: document that limits can be integral (not just unsigned integral) using type = - static_combined_check_t::value, assert_limit_is_integral>>; + static_combined_check_t::value or is_unsigned_integral::value, assert_limit_is_integral>>; }; template using check_limit_t = typename check_limit>::type; diff --git a/include/sqlpp11/core/clause/offset.h b/include/sqlpp11/core/clause/offset.h index 76683499..e22cffa3 100644 --- a/include/sqlpp11/core/clause/offset.h +++ b/include/sqlpp11/core/clause/offset.h @@ -78,7 +78,7 @@ namespace sqlpp struct check_offset { using type = - static_combined_check_t::value, assert_offset_is_integral>>; + static_combined_check_t::value or is_unsigned_integral::value, assert_offset_is_integral>>; }; template using check_offset_t = typename check_offset>::type; diff --git a/include/sqlpp11/core/clause/select_flag_list.h b/include/sqlpp11/core/clause/select_flag_list.h index 5577f3a0..59beb64b 100644 --- a/include/sqlpp11/core/clause/select_flag_list.h +++ b/include/sqlpp11/core/clause/select_flag_list.h @@ -137,11 +137,7 @@ namespace sqlpp template auto to_sql_string(Context& context, const select_flag_list_data_t& t) -> std::string { - auto flags = tuple_to_sql_string(context, t._flags, tuple_operand_no_dynamic{" "}); - if (flags.empty()) { - return flags; - } - return flags + " "; + return tuple_to_sql_string(context, t._flags, tuple_operand_no_dynamic{""}); } template diff --git a/include/sqlpp11/core/clause/select_flags.h b/include/sqlpp11/core/clause/select_flags.h index ad35769e..46b37445 100644 --- a/include/sqlpp11/core/clause/select_flags.h +++ b/include/sqlpp11/core/clause/select_flags.h @@ -45,7 +45,7 @@ namespace sqlpp template auto to_sql_string(Context& , const all_t&) -> std::string { - return "ALL"; + return "ALL "; } struct distinct_t @@ -59,7 +59,7 @@ namespace sqlpp template auto to_sql_string(Context& , const distinct_t&) -> std::string { - return "DISTINCT"; + return "DISTINCT "; } } // namespace sqlpp diff --git a/include/sqlpp11/core/detail/type_vector.h b/include/sqlpp11/core/detail/type_vector.h index f59ec846..a0960582 100644 --- a/include/sqlpp11/core/detail/type_vector.h +++ b/include/sqlpp11/core/detail/type_vector.h @@ -76,27 +76,32 @@ namespace sqlpp } template - static constexpr bool contains() - { - return ::sqlpp::logic::any::value...>::value; - } + struct contains : public ::sqlpp::logic::any::value...> { + }; + + template + struct contains_not : public ::sqlpp::logic::none::value...> { + }; + + template + struct contains_all; template - static constexpr bool contains_all(type_vector) + struct contains_all> : public ::sqlpp::logic::all::value...> { - return ::sqlpp::logic::all()...>::value; - } + }; +#warning turn into structs template static constexpr bool contains_any(type_vector) { - return ::sqlpp::logic::any()...>::value; + return ::sqlpp::logic::any::value...>::value; } template static constexpr bool contains_none(type_vector) { - return ::sqlpp::logic::none()...>::value; + return ::sqlpp::logic::none::value...>::value; } static constexpr size_t size() @@ -155,5 +160,18 @@ namespace sqlpp template class Transform> using transform_t = typename transform::type; + template class Predicate> + struct copy_if; + + template