From 68021772c26f68c267725c7a5d6a41538d38e5a3 Mon Sep 17 00:00:00 2001 From: Roland Bock Date: Sun, 1 Aug 2021 12:54:46 +0200 Subject: [PATCH] Finished replacing serializer_t --- include/sqlpp11/all_of.h | 12 +-- include/sqlpp11/any.h | 18 ++-- include/sqlpp11/assignment.h | 18 ++-- include/sqlpp11/bad_expression.h | 8 +- include/sqlpp11/boolean_expression.h | 12 +-- include/sqlpp11/case.h | 26 ++--- include/sqlpp11/cte.h | 53 ++++------ include/sqlpp11/custom_query.h | 14 +-- include/sqlpp11/default_value.h | 14 +-- include/sqlpp11/for_update.h | 14 +-- include/sqlpp11/from.h | 2 - include/sqlpp11/functions.h | 46 ++++----- include/sqlpp11/group_by.h | 5 +- include/sqlpp11/having.h | 27 ++---- include/sqlpp11/hidden.h | 12 +-- include/sqlpp11/in.h | 76 ++++++--------- include/sqlpp11/insert.h | 14 +-- include/sqlpp11/insert_value.h | 32 +++--- include/sqlpp11/insert_value_list.h | 118 ++++++++++------------- include/sqlpp11/into.h | 16 +-- include/sqlpp11/is_equal_to_or_null.h | 20 ++-- include/sqlpp11/limit.h | 38 +++----- include/sqlpp11/named_interpretable.h | 2 +- include/sqlpp11/null.h | 14 +-- include/sqlpp11/offset.h | 34 +++---- include/sqlpp11/order_by.h | 33 +++---- include/sqlpp11/over.h | 16 +-- include/sqlpp11/parameter.h | 14 +-- include/sqlpp11/parameterized_verbatim.h | 18 ++-- include/sqlpp11/remove.h | 14 +-- include/sqlpp11/result_field.h | 24 ++--- include/sqlpp11/schema.h | 14 +-- include/sqlpp11/schema_qualified_table.h | 18 ++-- include/sqlpp11/select_flag_list.h | 33 +++---- include/sqlpp11/select_flags.h | 39 +++----- include/sqlpp11/serializer.h | 17 +--- include/sqlpp11/simple_column.h | 14 +-- include/sqlpp11/single_table.h | 14 +-- include/sqlpp11/some.h | 18 ++-- include/sqlpp11/sort_order.h | 28 +++--- include/sqlpp11/trim.h | 18 ++-- include/sqlpp11/type_traits.h | 22 +---- include/sqlpp11/union_data.h | 22 ++--- include/sqlpp11/union_flags.h | 24 ++--- include/sqlpp11/update.h | 15 +-- include/sqlpp11/update_list.h | 27 ++---- include/sqlpp11/using.h | 33 +++---- include/sqlpp11/verbatim.h | 14 +-- include/sqlpp11/verbatim_table.h | 14 +-- include/sqlpp11/where.h | 5 +- include/sqlpp11/with.h | 23 ++--- include/sqlpp11/without_table_check.h | 18 ++-- tests/CMakeLists.txt | 30 +++--- tests/Sample.h | 16 --- tests/Select.cpp | 2 - 55 files changed, 416 insertions(+), 826 deletions(-) diff --git a/include/sqlpp11/all_of.h b/include/sqlpp11/all_of.h index bc1e6619..bf9e71bd 100644 --- a/include/sqlpp11/all_of.h +++ b/include/sqlpp11/all_of.h @@ -47,17 +47,9 @@ namespace sqlpp SQLPP_PORTABLE_STATIC_ASSERT(assert_no_stand_alone_all_of_t, "all_of(table) seems to be used outside of select"); + // FIXME: Do we need this? template - struct serializer_t> - { - using _serialize_check = assert_no_stand_alone_all_of_t; - using T = all_of_t; - - static Context& _(const T& /*unused*/, const Context& /*unused*/) - { - _serialize_check{}; - } - }; + Context& serialize(const all_of_t
& t, Context& context); } // namespace sqlpp #endif diff --git a/include/sqlpp11/any.h b/include/sqlpp11/any.h index d8e86d04..d0ea8b1c 100644 --- a/include/sqlpp11/any.h +++ b/include/sqlpp11/any.h @@ -53,19 +53,13 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const any_t; - - static Context& _(const T& t, Context& context) - { - context << "ANY("; - serialize(t._select, context); - context << ")"; - return context; - } - }; + context << "ANY("; + serialize(t._select, context); + context << ")"; + return context; + } template auto any(T t) -> any_t> diff --git a/include/sqlpp11/assignment.h b/include/sqlpp11/assignment.h index ba46b2c6..0e4c0a91 100644 --- a/include/sqlpp11/assignment.h +++ b/include/sqlpp11/assignment.h @@ -62,19 +62,13 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const assignment_t& t, Context& context) { - using T = assignment_t; - using _serialize_check = serialize_check_of; - - static Context& _(const T& t, Context& context) - { - serialize(simple_column(t._lhs), context); - context << "="; - serialize_operand(t._rhs, context); - return context; - } - }; + serialize(simple_column(t._lhs), context); + context << "="; + serialize_operand(t._rhs, context); + return context; + } } // namespace sqlpp #endif diff --git a/include/sqlpp11/bad_expression.h b/include/sqlpp11/bad_expression.h index c8c37712..97aaca9d 100644 --- a/include/sqlpp11/bad_expression.h +++ b/include/sqlpp11/bad_expression.h @@ -46,13 +46,7 @@ namespace sqlpp }; template - struct serializer_t> - { - using _serialize_check = assert_valid_operands; - using T = bad_expression; - - static Context& _(const T&, Context&); - }; + Context serialize(const bad_expression& t, Context& context); } // namespace sqlpp #endif diff --git a/include/sqlpp11/boolean_expression.h b/include/sqlpp11/boolean_expression.h index 8da7fc7a..d4580710 100644 --- a/include/sqlpp11/boolean_expression.h +++ b/include/sqlpp11/boolean_expression.h @@ -68,16 +68,10 @@ namespace sqlpp } template - struct serializer_t> + Context& serialize(const boolean_expression_t& t, Context& context) { - using _serialize_check = consistent_t; - using T = boolean_expression_t; - - static Context& _(const T& t, Context& context) - { - return serialize(t._expr, context); - } - }; + return serialize(t._expr, context); + } } // namespace sqlpp #endif diff --git a/include/sqlpp11/case.h b/include/sqlpp11/case.h index beface1a..12b0e2ae 100644 --- a/include/sqlpp11/case.h +++ b/include/sqlpp11/case.h @@ -151,23 +151,17 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const case_t& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = case_t; - - static Context& _(const T& t, Context& context) - { - context << "(CASE WHEN "; - serialize(t._when, context); - context << " THEN "; - serialize(t._then, context); - context << " ELSE "; - serialize(t._else, context); - context << " END)"; - return context; - } - }; + context << "(CASE WHEN "; + serialize(t._when, context); + context << " THEN "; + serialize(t._then, context); + context << " ELSE "; + serialize(t._else, context); + context << " END)"; + return context; + } namespace detail { diff --git a/include/sqlpp11/cte.h b/include/sqlpp11/cte.h index eaa1129e..2fd4a9d4 100644 --- a/include/sqlpp11/cte.h +++ b/include/sqlpp11/cte.h @@ -63,21 +63,15 @@ namespace sqlpp // Interpreters template - struct serializer_t> + Context& serialize(const cte_union_t& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = cte_union_t; - - static Context& _(const T& t, Context& context) - { - serialize(t._lhs, context); - context << " UNION "; - serialize(Flag{}, context); - context << " "; - serialize(t._rhs, context); - return context; - } - }; + serialize(t._lhs, context); + context << " UNION "; + serialize(Flag{}, context); + context << " "; + serialize(t._rhs, context); + return context; + } template struct cte_t; @@ -229,19 +223,14 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const cte_t& t, Context& context) { - using _serialize_check = serialize_check_of; using T = cte_t; - - static Context& _(const T& t, Context& context) - { - context << name_of::template char_ptr() << " AS ("; - serialize(t._statement, context); - context << ")"; - return context; - } - }; + context << name_of::template char_ptr() << " AS ("; + serialize(t._statement, context); + context << ")"; + return context; + } // The cte_t is displayed as AliasProviderName except within the with: // - the with needs the @@ -273,17 +262,11 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const cte_ref_t&, Context& context) { - using _serialize_check = consistent_t; - using T = cte_ref_t; - - static Context& _(const T& /*unused*/, Context& context) - { - context << name_of::template char_ptr(); - return context; - } - }; + context << name_of>::template char_ptr(); + return context; + } template auto cte(const AliasProvider & /*unused*/) -> cte_ref_t diff --git a/include/sqlpp11/custom_query.h b/include/sqlpp11/custom_query.h index 7099f306..620da6ad 100644 --- a/include/sqlpp11/custom_query.h +++ b/include/sqlpp11/custom_query.h @@ -123,17 +123,11 @@ namespace sqlpp }; template - struct serializer_t> + Context serialize(const custom_query_t& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = custom_query_t; - - static Context& _(const T& t, Context& context) - { - interpret_tuple_without_braces(t._parts, " ", context); - return context; - } - }; + interpret_tuple_without_braces(t._parts, " ", context); + return context; + } template auto custom_query(Parts... parts) -> custom_query_t...> diff --git a/include/sqlpp11/default_value.h b/include/sqlpp11/default_value.h index 264b4687..9ac64144 100644 --- a/include/sqlpp11/default_value.h +++ b/include/sqlpp11/default_value.h @@ -38,17 +38,11 @@ namespace sqlpp }; template - struct serializer_t + Context& serialize(const default_value_t&, Context& context) { - using _serialize_check = consistent_t; - using Operand = default_value_t; - - static Context& _(const Operand& /*unused*/, Context& context) - { - context << "DEFAULT"; - return context; - } - }; + context << "DEFAULT"; + return context; + } constexpr default_value_t default_value = {}; } // namespace sqlpp diff --git a/include/sqlpp11/for_update.h b/include/sqlpp11/for_update.h index aeff3c3d..ca908722 100644 --- a/include/sqlpp11/for_update.h +++ b/include/sqlpp11/for_update.h @@ -157,17 +157,11 @@ namespace sqlpp // Interpreters template - struct serializer_t + Context& serialize(const for_update_data_t&, Context& context) { - using _serialize_check = serialize_check_of; - using T = for_update_data_t; - - static Context& _(const T& /*unused*/, Context& context) - { - context << " FOR UPDATE "; - return context; - } - }; + context << " FOR UPDATE "; + return context; + } template auto for_update(T&& t) -> decltype(statement_t().for_update(std::forward(t))) diff --git a/include/sqlpp11/from.h b/include/sqlpp11/from.h index 1226edf5..8f3e950e 100644 --- a/include/sqlpp11/from.h +++ b/include/sqlpp11/from.h @@ -85,8 +85,6 @@ namespace sqlpp assert_from_add_unique_names>, static_check_t::value, assert_from_add_no_required_tables> - // FIXME: Replace this with consistency check? - // sqlpp::serialize_check_t, DynamicJoin> >; }; diff --git a/include/sqlpp11/functions.h b/include/sqlpp11/functions.h index 97a7d525..0f9563da 100644 --- a/include/sqlpp11/functions.h +++ b/include/sqlpp11/functions.h @@ -96,35 +96,29 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const value_list_t& t, Context& context) { - using _serialize_check = serialize_check_of>; - using T = value_list_t; - - static Context& _(const T& t, Context& context) + if (t._container.size() == 1) { - if (t._container.size() == 1) - { - return serialize(value(*begin(t._container)), context); - } - - bool first = true; - for (const auto& entry : t._container) - { - if (first) - { - first = false; - } - else - { - context << ','; - } - - serialize_operand(value(entry), context); - } - return context; + return serialize(value(*begin(t._container)), context); } - }; + + bool first = true; + for (const auto& entry : t._container) + { + if (first) + { + first = false; + } + else + { + context << ','; + } + + serialize_operand(value(entry), context); + } + return context; + } template auto value_list(Container c) -> value_list_t diff --git a/include/sqlpp11/group_by.h b/include/sqlpp11/group_by.h index 81ab2fb6..0de5ffca 100644 --- a/include/sqlpp11/group_by.h +++ b/include/sqlpp11/group_by.h @@ -90,10 +90,7 @@ namespace sqlpp static_assert(is_expression_t::value, "invalid expression argument in group_by::add()"); static_assert(Policies::template _no_unknown_tables::value, "expression uses tables unknown to this statement in group_by::add()"); - using _serialize_check = sqlpp::serialize_check_t; - _serialize_check{}; - - using ok = logic::all_t<_is_dynamic::value, is_expression_t::value, _serialize_check::type::value>; + using ok = logic::all_t<_is_dynamic::value, is_expression_t::value>; _add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert } diff --git a/include/sqlpp11/having.h b/include/sqlpp11/having.h index ff377052..3f6dc8bf 100644 --- a/include/sqlpp11/having.h +++ b/include/sqlpp11/having.h @@ -91,10 +91,7 @@ namespace sqlpp static_assert(is_expression_t::value, "invalid expression argument in having::add()"); static_assert(Policies::template _no_unknown_tables::value, "expression uses tables unknown to this statement in having::add()"); - using _serialize_check = sqlpp::serialize_check_t; - _serialize_check{}; - - using ok = logic::all_t<_is_dynamic::value, is_expression_t::value, _serialize_check::type::value>; + using ok = logic::all_t<_is_dynamic::value, is_expression_t::value>; _add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert } @@ -292,23 +289,17 @@ namespace sqlpp // Interpreters template - struct serializer_t> + Context& serialize(const having_data_t& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = having_data_t; - - static Context& _(const T& t, Context& context) + context << " HAVING "; + serialize(t._expression, context); + if (not t._dynamic_expressions.empty()) { - context << " HAVING "; - serialize(t._expression, context); - if (not t._dynamic_expressions.empty()) - { - context << " AND "; - } - interpret_list(t._dynamic_expressions, " AND ", context); - return context; + context << " AND "; } - }; + interpret_list(t._dynamic_expressions, " AND ", context); + return context; + } template auto having(T&& t) -> decltype(statement_t().having(std::forward(t))) diff --git a/include/sqlpp11/hidden.h b/include/sqlpp11/hidden.h index fa31d8c9..ed332c2f 100644 --- a/include/sqlpp11/hidden.h +++ b/include/sqlpp11/hidden.h @@ -46,16 +46,10 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const hidden_t&, Context& context) { - using _serialize_check = consistent_t; - using T = hidden_t; - - static Context& _(const T& /*unused*/, Context& context) - { - return context; - } - }; + return context; + } template auto hidden(Clause part) -> hidden_t diff --git a/include/sqlpp11/in.h b/include/sqlpp11/in.h index 3f1c7fbb..feb4054b 100644 --- a/include/sqlpp11/in.h +++ b/include/sqlpp11/in.h @@ -73,67 +73,49 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const in_t& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = in_t; - - static Context& _(const T& t, Context& context) + serialize(t._operand, context); + context << " IN("; + if (sizeof...(Args) == 1) { - serialize(t._operand, context); - context << " IN("; - if (sizeof...(Args) == 1) - { - serialize(std::get<0>(t._args), context); - } - else - { - interpret_tuple(t._args, ',', context); - } - context << ')'; - return context; + serialize(std::get<0>(t._args), context); } - }; + else + { + interpret_tuple(t._args, ',', context); + } + context << ')'; + return context; + } template - struct serializer_t> + Context& serialize(const in_t&, Context& context) { - using _serialize_check = consistent_t; - using T = in_t; - - static Context& _(const T& /*unused*/, Context& context) - { - serialize(boolean_operand{false}, context); - return context; - } - }; + serialize(boolean_operand{false}, context); + return context; + } template struct value_list_t; template - struct serializer_t>> + Context& serialize(const in_t>& t, Context& context) { - using _serialize_check = serialize_check_of>; - using T = in_t>; - - static Context& _(const T& t, Context& context) + const auto& value_list = std::get<0>(t._args); + if (value_list._container.empty()) { - const auto& value_list = std::get<0>(t._args); - if (value_list._container.empty()) - { - serialize(boolean_operand{false}, context); - } - else - { - serialize(t._operand, context); - context << " IN("; - serialize(value_list, context); - context << ')'; - } - return context; + serialize(boolean_operand{false}, context); } - }; + else + { + serialize(t._operand, context); + context << " IN("; + serialize(value_list, context); + context << ')'; + } + return context; + } } // namespace sqlpp #endif diff --git a/include/sqlpp11/insert.h b/include/sqlpp11/insert.h index e1672cff..965065f1 100644 --- a/include/sqlpp11/insert.h +++ b/include/sqlpp11/insert.h @@ -89,18 +89,12 @@ namespace sqlpp }; template - struct serializer_t + Context& serialize(const insert_name_t&, Context& context) { - using _serialize_check = consistent_t; - using T = insert_name_t; + context << "INSERT"; - static Context& _(const T& /*unused*/, Context& context) - { - context << "INSERT"; - - return context; - } - }; + return context; + } template using blank_insert_t = statement_t; diff --git a/include/sqlpp11/insert_value.h b/include/sqlpp11/insert_value.h index 861e8e43..22c09e7a 100644 --- a/include/sqlpp11/insert_value.h +++ b/include/sqlpp11/insert_value.h @@ -96,28 +96,22 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const insert_value_t& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = insert_value_t; - - static Context& _(const T& t, Context& context) + if (t._is_null) { - if (t._is_null) - { - context << "NULL"; - } - else if (t._is_default) - { - context << "DEFAULT"; - } - else - { - serialize_operand(t._value, context); - } - return context; + context << "NULL"; } - }; + else if (t._is_default) + { + context << "DEFAULT"; + } + else + { + serialize_operand(t._value, context); + } + return context; + } } // namespace sqlpp #endif diff --git a/include/sqlpp11/insert_value_list.h b/include/sqlpp11/insert_value_list.h index 56c36104..70934309 100644 --- a/include/sqlpp11/insert_value_list.h +++ b/include/sqlpp11/insert_value_list.h @@ -290,10 +290,7 @@ namespace sqlpp static_assert(not must_not_insert_t>::value, "add() argument must not be used in insert"); static_assert(Policies::template _no_unknown_tables::value, "add() contains a column from a foreign table"); - using _serialize_check = sqlpp::serialize_check_t; - _serialize_check{}; - - using ok = logic::all_t<_is_dynamic::value, is_assignment_t::value, _serialize_check::type::value>; + using ok = logic::all_t<_is_dynamic::value, is_assignment_t::value>; _add_impl(assignment, ok()); // dispatch to prevent compile messages after the static_assert } @@ -604,87 +601,70 @@ namespace sqlpp // Interpreters template - struct serializer_t + Context& serialize(const insert_default_values_data_t&, Context& context) { - using _serialize_check = consistent_t; - using T = insert_default_values_data_t; + context << " DEFAULT VALUES"; + return context; + } - static Context& _(const T& /*unused*/, Context& context) - { - context << " DEFAULT VALUES"; - return context; - } - }; template - struct serializer_t> + Context& serialize(const column_list_data_t& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = column_list_data_t; - - static Context& _(const T& t, Context& context) + context << " ("; + interpret_tuple(t._columns, ",", context); + context << ")"; + bool first = true; + for (const auto& row : t._insert_values) { - context << " ("; - interpret_tuple(t._columns, ",", context); - context << ")"; - bool first = true; - for (const auto& row : t._insert_values) + if (first) { - if (first) - { - context << " VALUES "; - first = false; - } - else - { - context << ','; - } - context << '('; - interpret_tuple(row, ",", context); - context << ')'; - } - - return context; - } - }; - - template - struct serializer_t> - { - using _serialize_check = serialize_check_of; - using T = insert_list_data_t; - - static Context& _(const T& t, Context& context) - { - if (sizeof...(Assignments) + t._dynamic_columns.size() == 0) - { - serialize(insert_default_values_data_t(), context); + context << " VALUES "; + first = false; } else { - context << " ("; - interpret_tuple(t._columns, ",", context); - if (sizeof...(Assignments) and not t._dynamic_columns.empty()) + context << ','; + } + context << '('; + interpret_tuple(row, ",", context); + context << ')'; + } + + return context; + } + + template + Context& serialize(const insert_list_data_t& t, Context& context) + { + if (sizeof...(Assignments) + t._dynamic_columns.size() == 0) + { + serialize(insert_default_values_data_t(), context); + } + else + { + context << " ("; + interpret_tuple(t._columns, ",", context); + if (sizeof...(Assignments) and not t._dynamic_columns.empty()) + { + context << ','; + } + interpret_list(t._dynamic_columns, ',', context); + context << ")"; + if (sizeof...(Assignments) or not t._dynamic_values.empty()) + { + context << " VALUES("; + interpret_tuple(t._values, ",", context); + if (sizeof...(Assignments) and not t._dynamic_values.empty()) { context << ','; } - interpret_list(t._dynamic_columns, ',', context); + interpret_list(t._dynamic_values, ',', context); context << ")"; - if (sizeof...(Assignments) or not t._dynamic_values.empty()) - { - context << " VALUES("; - interpret_tuple(t._values, ",", context); - if (sizeof...(Assignments) and not t._dynamic_values.empty()) - { - context << ','; - } - interpret_list(t._dynamic_values, ',', context); - context << ")"; - } } - return context; } - }; + return context; + } template auto insert_set(Assignments... assignments) diff --git a/include/sqlpp11/into.h b/include/sqlpp11/into.h index cdf90ec1..07e3b87f 100644 --- a/include/sqlpp11/into.h +++ b/include/sqlpp11/into.h @@ -192,18 +192,12 @@ namespace sqlpp // Interpreters template - struct serializer_t> + Context& serialize(const into_data_t& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = into_data_t; - - static Context& _(const T& t, Context& context) - { - context << " INTO "; - serialize(t._table, context); - return context; - } - }; + context << " INTO "; + serialize(t._table, context); + return context; + } template auto into(T&& t) -> decltype(statement_t().into(std::forward(t))) diff --git a/include/sqlpp11/is_equal_to_or_null.h b/include/sqlpp11/is_equal_to_or_null.h index 4f29f1fc..b04bae0b 100644 --- a/include/sqlpp11/is_equal_to_or_null.h +++ b/include/sqlpp11/is_equal_to_or_null.h @@ -54,21 +54,15 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const is_equal_to_or_null_t& t, Context& context) { - using _serialize_check = consistent_t; - using Operand = is_equal_to_or_null_t; + if (t._value._is_null) + serialize(t._expr.is_null(), context); + else + serialize(t._expr == t._value, context); - static Context& _(const Operand& t, Context& context) - { - if (t._value._is_null) - serialize(t._expr.is_null(), context); - else - serialize(t._expr == t._value, context); - - return context; - } - }; + return context; + } template auto is_equal_to_or_null(Expr expr, value_or_null_t value) -> is_equal_to_or_null_t diff --git a/include/sqlpp11/limit.h b/include/sqlpp11/limit.h index 481037e1..25f94fc5 100644 --- a/include/sqlpp11/limit.h +++ b/include/sqlpp11/limit.h @@ -287,35 +287,23 @@ namespace sqlpp // Interpreters template - struct serializer_t> + Context& serialize(const dynamic_limit_data_t& t, Context& context) { - using _serialize_check = consistent_t; - using T = dynamic_limit_data_t; - - static Context& _(const T& t, Context& context) - { - if (t._initialized) - { - context << " LIMIT "; - serialize(t._value, context); - } - return context; - } - }; - - template - struct serializer_t> - { - using _serialize_check = serialize_check_of; - using T = limit_data_t; - - static Context& _(const T& t, Context& context) + if (t._initialized) { context << " LIMIT "; - serialize_operand(t._value, context); - return context; + serialize(t._value, context); } - }; + return context; + } + + template + Context& serialize(const limit_data_t& t, Context& context) + { + context << " LIMIT "; + serialize_operand(t._value, context); + return context; + } template auto limit(T&& t) -> decltype(statement_t().limit(std::forward(t))) diff --git a/include/sqlpp11/named_interpretable.h b/include/sqlpp11/named_interpretable.h index e85120b2..544bb9e3 100644 --- a/include/sqlpp11/named_interpretable.h +++ b/include/sqlpp11/named_interpretable.h @@ -79,7 +79,7 @@ namespace sqlpp _serializer_context_t& interpret(_serializer_context_t& context) const { - interpret(_t, context); + serialize(_t, context); return context; } diff --git a/include/sqlpp11/null.h b/include/sqlpp11/null.h index 7e8f8431..41754df7 100644 --- a/include/sqlpp11/null.h +++ b/include/sqlpp11/null.h @@ -38,17 +38,11 @@ namespace sqlpp }; template - struct serializer_t + Context& serialize(const null_t&, Context& context) { - using _serialize_check = consistent_t; - using Operand = null_t; - - static Context& _(const Operand& /*unused*/, Context& context) - { - context << "NULL"; - return context; - } - }; + context << "NULL"; + return context; + } constexpr null_t null = {}; } // namespace sqlpp diff --git a/include/sqlpp11/offset.h b/include/sqlpp11/offset.h index 943946de..f72681cd 100644 --- a/include/sqlpp11/offset.h +++ b/include/sqlpp11/offset.h @@ -301,35 +301,23 @@ namespace sqlpp // Interpreters template - struct serializer_t> + Context& serialize(const offset_data_t& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = offset_data_t; - - static Context& _(const T& t, Context& context) - { - context << " OFFSET "; - serialize_operand(t._value, context); - return context; - } - }; + context << " OFFSET "; + serialize_operand(t._value, context); + return context; + } template - struct serializer_t> + Context& serialize(const dynamic_offset_data_t& t, Context& context) { - using _serialize_check = consistent_t; - using T = dynamic_offset_data_t; - - static Context& _(const T& t, Context& context) + if (t._initialized) { - if (t._initialized) - { - context << " OFFSET "; - serialize(t._value, context); - } - return context; + context << " OFFSET "; + serialize(t._value, context); } - }; + return context; + } template auto offset(T&& t) -> decltype(statement_t().offset(std::forward(t))) diff --git a/include/sqlpp11/order_by.h b/include/sqlpp11/order_by.h index d1ef5da4..f1577dcf 100644 --- a/include/sqlpp11/order_by.h +++ b/include/sqlpp11/order_by.h @@ -88,10 +88,7 @@ namespace sqlpp static_assert(is_sort_order_t::value, "invalid expression argument in order_by::add()"); static_assert(Policies::template _no_unknown_tables::value, "expression uses tables unknown to this statement in order_by::add()"); - using _serialize_check = sqlpp::serialize_check_t; - _serialize_check{}; - - using ok = logic::all_t<_is_dynamic::value, is_sort_order_t::value, _serialize_check::type::value>; + using ok = logic::all_t<_is_dynamic::value, is_sort_order_t::value>; _add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert } @@ -250,27 +247,21 @@ namespace sqlpp // Interpreters template - struct serializer_t> + Context& serialize(const order_by_data_t& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = order_by_data_t; - - static Context& _(const T& t, Context& context) + if (sizeof...(Expressions) == 0 and t._dynamic_expressions.empty()) { - if (sizeof...(Expressions) == 0 and t._dynamic_expressions.empty()) - { - return context; - } - context << " ORDER BY "; - interpret_tuple(t._expressions, ',', context); - if (sizeof...(Expressions) and not t._dynamic_expressions.empty()) - { - context << ','; - } - interpret_list(t._dynamic_expressions, ',', context); return context; } - }; + context << " ORDER BY "; + interpret_tuple(t._expressions, ',', context); + if (sizeof...(Expressions) and not t._dynamic_expressions.empty()) + { + context << ','; + } + interpret_list(t._dynamic_expressions, ',', context); + return context; + } template auto order_by(T&&... t) -> decltype(statement_t().order_by(std::forward(t)...)) diff --git a/include/sqlpp11/over.h b/include/sqlpp11/over.h index 6a598e1e..cb5d82a8 100644 --- a/include/sqlpp11/over.h +++ b/include/sqlpp11/over.h @@ -56,18 +56,12 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const over_t& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = over_t; - - static Context& _(const T& t, Context& context) - { - serialize_operand(t._aggregate_expression, context); - context << " OVER()"; - return context; - } - }; + serialize_operand(t._aggregate_expression, context); + context << " OVER()"; + return context; + } } // namespace sqlpp #endif diff --git a/include/sqlpp11/parameter.h b/include/sqlpp11/parameter.h index fc26d9bc..8e4cee27 100644 --- a/include/sqlpp11/parameter.h +++ b/include/sqlpp11/parameter.h @@ -57,17 +57,11 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const parameter_t&, Context& context) { - using _serialize_check = consistent_t; - using T = parameter_t; - - static Context& _(const T& /*unused*/, Context& context) - { - context << "?"; - return context; - } - }; + context << "?"; + return context; + } template auto parameter(const NamedExpr & /*unused*/) -> parameter_t, NamedExpr> diff --git a/include/sqlpp11/parameterized_verbatim.h b/include/sqlpp11/parameterized_verbatim.h index 438a89ef..b0bcc364 100644 --- a/include/sqlpp11/parameterized_verbatim.h +++ b/include/sqlpp11/parameterized_verbatim.h @@ -59,19 +59,13 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const parameterized_verbatim_t& t, Context& context) { - using _serialize_check = consistent_t; - using T = parameterized_verbatim_t; - - static Context& _(const T& t, Context& context) - { - context << t._verbatim_lhs; - serialize(t._expr, context); - context << t._verbatim_rhs; - return context; - } - }; + context << t._verbatim_lhs; + serialize(t._expr, context); + context << t._verbatim_rhs; + return context; + } template auto parameterized_verbatim(std::string lhs, Expr expr, std::string rhs) diff --git a/include/sqlpp11/remove.h b/include/sqlpp11/remove.h index 44bd1c52..209f6cdf 100644 --- a/include/sqlpp11/remove.h +++ b/include/sqlpp11/remove.h @@ -88,18 +88,12 @@ namespace sqlpp }; template - struct serializer_t + Context& serialize(const remove_name_t&, Context& context) { - using _serialize_check = consistent_t; - using T = remove_name_t; + context << "DELETE"; - static Context& _(const T& /*unused*/, Context& context) - { - context << "DELETE"; - - return context; - } - }; + return context; + } template using blank_remove_t = statement_t>; diff --git a/include/sqlpp11/result_field.h b/include/sqlpp11/result_field.h index 31ae307b..2c98f990 100644 --- a/include/sqlpp11/result_field.h +++ b/include/sqlpp11/result_field.h @@ -42,24 +42,18 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const result_field_t& t, Context& context) { - using _serialize_check = consistent_t; - using T = result_field_t; - - static Context& _(const T& t, Context& context) + if (t.is_null()) { - if (t.is_null()) - { - context << "NULL"; - } - else - { - serialize(wrap_operand_t>(t.value()), context); - } - return context; + context << "NULL"; } - }; + else + { + serialize(wrap_operand_t>(t.value()), context); + } + return context; + } template inline std::ostream& operator<<(std::ostream& os, const result_field_t& rf) diff --git a/include/sqlpp11/schema.h b/include/sqlpp11/schema.h index c5a94af1..dc260cac 100644 --- a/include/sqlpp11/schema.h +++ b/include/sqlpp11/schema.h @@ -40,17 +40,11 @@ namespace sqlpp }; template - struct serializer_t + Context& serialize(const schema_t& t, Context& context) { - using _serialize_check = consistent_t; - using T = schema_t; - - static Context& _(const T& t, Context& context) - { - context << t._name; - return context; - } - }; + context << t._name; + return context; + } } // namespace sqlpp #endif diff --git a/include/sqlpp11/schema_qualified_table.h b/include/sqlpp11/schema_qualified_table.h index f586d747..e92da9e8 100644 --- a/include/sqlpp11/schema_qualified_table.h +++ b/include/sqlpp11/schema_qualified_table.h @@ -63,19 +63,13 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const schema_qualified_table_t
& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = schema_qualified_table_t
; - - static Context& _(const T& t, Context& context) - { - serialize(t._schema, context); - context << '.'; - serialize(t._table, context); - return context; - } - }; + serialize(t._schema, context); + context << '.'; + serialize(t._table, context); + return context; + } template auto schema_qualified_table(schema_t schema, Table table) -> schema_qualified_table_t
diff --git a/include/sqlpp11/select_flag_list.h b/include/sqlpp11/select_flag_list.h index 0420b200..5c27ca73 100644 --- a/include/sqlpp11/select_flag_list.h +++ b/include/sqlpp11/select_flag_list.h @@ -84,10 +84,7 @@ namespace sqlpp static_assert(is_select_flag_t::value, "invalid select flag argument in select_flags::add()"); static_assert(Policies::template _no_unknown_tables::value, "flag uses tables unknown to this statement in select_flags::add()"); - using _serialize_check = sqlpp::serialize_check_t; - _serialize_check{}; - - using ok = logic::all_t<_is_dynamic::value, is_select_flag_t::value, _serialize_check::type::value>; + using ok = logic::all_t<_is_dynamic::value, is_select_flag_t::value>; _add_impl(flag, ok()); // dispatch to prevent compile messages after the static_assert } @@ -240,26 +237,20 @@ namespace sqlpp // Interpreters template - struct serializer_t> + Context& serialize(const select_flag_list_data_t& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = select_flag_list_data_t; - - static Context& _(const T& t, Context& context) + interpret_tuple(t._flags, ' ', context); + if (sizeof...(Flags) != 0u) { - interpret_tuple(t._flags, ' ', context); - if (sizeof...(Flags) != 0u) - { - context << ' '; - } - interpret_list(t._dynamic_flags, ',', context); - if (not t._dynamic_flags.empty()) - { - context << ' '; - } - return context; + context << ' '; } - }; + interpret_list(t._dynamic_flags, ',', context); + if (not t._dynamic_flags.empty()) + { + context << ' '; + } + return context; + } template auto select_flags(T&& t) -> decltype(statement_t().flags(std::forward(t))) diff --git a/include/sqlpp11/select_flags.h b/include/sqlpp11/select_flags.h index 52616b1a..d906f5a1 100644 --- a/include/sqlpp11/select_flags.h +++ b/include/sqlpp11/select_flags.h @@ -43,16 +43,11 @@ namespace sqlpp static constexpr all_t all = {}; template - struct serializer_t + Context& serialize(const all_t&, Context& context) { - using _serialize_check = consistent_t; - - static Context& _(const all_t& /*unused*/, Context& context) - { - context << "ALL"; - return context; - } - }; + context << "ALL"; + return context; + } struct distinct_t { @@ -62,16 +57,11 @@ namespace sqlpp static constexpr distinct_t distinct = {}; template - struct serializer_t + Context& serialize(const distinct_t&, Context& context) { - using _serialize_check = consistent_t; - - static Context& _(const distinct_t& /*unused*/, Context& context) - { - context << "DISTINCT"; - return context; - } - }; + context << "DISTINCT"; + return context; + } struct straight_join_t { @@ -81,16 +71,11 @@ namespace sqlpp static constexpr straight_join_t straight_join = {}; template - struct serializer_t + Context& serialize(const straight_join_t&, Context& context) { - using _serialize_check = consistent_t; - - static Context& _(const straight_join_t& /*unused*/, Context& context) - { - context << "STRAIGHT_JOIN"; - return context; - } - }; + context << "STRAIGHT_JOIN"; + return context; + } } // namespace sqlpp #endif diff --git a/include/sqlpp11/serializer.h b/include/sqlpp11/serializer.h index 8fdce92b..6267398f 100644 --- a/include/sqlpp11/serializer.h +++ b/include/sqlpp11/serializer.h @@ -27,29 +27,16 @@ #ifndef SQLPP11_SERIALIZER_H #define SQLPP11_SERIALIZER_H -#include -#include +#include namespace sqlpp { - SQLPP_PORTABLE_STATIC_ASSERT(assert_serializer_specialization_t, "missing serializer specialization"); - + // FIXME: Move to type_traits.h, for instance template std::integral_constant get_quote_left(const Context&); template std::integral_constant get_quote_right(const Context&); - - template - struct serializer_t - { - using _serialize_check = assert_serializer_specialization_t; - - static void _(const T& t, Context& /*unused*/) - { - _serialize_check{t}; - } - }; } // namespace sqlpp #endif diff --git a/include/sqlpp11/simple_column.h b/include/sqlpp11/simple_column.h index 547da05c..f7573b14 100644 --- a/include/sqlpp11/simple_column.h +++ b/include/sqlpp11/simple_column.h @@ -49,17 +49,11 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const simple_column_t&, Context& context) { - using _serialize_check = serialize_check_of; - using T = simple_column_t; - - static Context& _(const T& /*unused*/, Context& context) - { - context << name_of::template char_ptr(); - return context; - } - }; + context << name_of::_column_t>::template char_ptr(); + return context; + } template simple_column_t simple_column(Column c) diff --git a/include/sqlpp11/single_table.h b/include/sqlpp11/single_table.h index 34c3b5b3..0c0cc897 100644 --- a/include/sqlpp11/single_table.h +++ b/include/sqlpp11/single_table.h @@ -192,17 +192,11 @@ namespace sqlpp // Interpreters template - struct serializer_t> + Context& serialize(const single_table_data_t& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = single_table_data_t; - - static Context& _(const T& t, Context& context) - { - serialize(t._table, context); - return context; - } - }; + serialize(t._table, context); + return context; + } } // namespace sqlpp #endif diff --git a/include/sqlpp11/some.h b/include/sqlpp11/some.h index 2c0ced17..e03c036d 100644 --- a/include/sqlpp11/some.h +++ b/include/sqlpp11/some.h @@ -53,19 +53,13 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const some_t; - - static Context& _(const T& t, Context& context) - { - context << "SOME("; - serialize(t._select, context); - context << ")"; - return context; - } - }; + context << "SOME("; + serialize(t._select, context); + context << ")"; + return context; + } template auto some(T t) -> some_t> diff --git a/include/sqlpp11/sort_order.h b/include/sqlpp11/sort_order.h index 538fc3fe..10795ef7 100644 --- a/include/sqlpp11/sort_order.h +++ b/include/sqlpp11/sort_order.h @@ -50,26 +50,20 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const sort_order_t& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = sort_order_t; - - static Context& _(const T& t, Context& context) + serialize_operand(t._expression, context); + switch (t._sort_type) { - serialize_operand(t._expression, context); - switch (t._sort_type) - { - case sort_type::asc: - context << " ASC"; - break; - default: - context << " DESC"; - break; - } - return context; + case sort_type::asc: + context << " ASC"; + break; + default: + context << " DESC"; + break; } - }; + return context; + } } // namespace sqlpp #endif diff --git a/include/sqlpp11/trim.h b/include/sqlpp11/trim.h index 43b009a7..6bb40657 100644 --- a/include/sqlpp11/trim.h +++ b/include/sqlpp11/trim.h @@ -81,19 +81,13 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const trim_t& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = trim_t; - - static Context& _(const T& t, Context& context) - { - context << "TRIM("; - serialize(t._expr, context); - context << ")"; - return context; - } - }; + context << "TRIM("; + serialize(t._expr, context); + context << ")"; + return context; + } template auto trim(T t) -> trim_t> diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 5ce3527b..800977e5 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -391,10 +392,6 @@ namespace sqlpp using is_inconsistent_t = typename std::conditional::value, std::false_type, std::true_type>::type; - template - using serialize_check_of = - detail::get_first_if::_serialize_check...>; - SQLPP_PORTABLE_STATIC_ASSERT(assert_sqlpp_type_t, "expression is not an sqlpp type, consistency cannot be verified"); SQLPP_PORTABLE_STATIC_ASSERT(assert_run_statement_or_prepared_t, "connection cannot run something that is neither statement nor prepared statement"); @@ -416,21 +413,6 @@ namespace sqlpp template using consistency_check_t = typename consistency_check::type; - template - struct serialize_check - { - using type = serialize_check_of; - }; - - template - struct serialize_check::value>::type> - { - using type = consistent_t; // this is already serialized - }; - - template - using serialize_check_t = typename serialize_check::type; - template struct run_check { @@ -459,7 +441,7 @@ namespace sqlpp struct prepare_check::value>::type> { using type = detail:: - get_first_if>; + get_first_if; }; template diff --git a/include/sqlpp11/union_data.h b/include/sqlpp11/union_data.h index 6f426568..bccd689c 100644 --- a/include/sqlpp11/union_data.h +++ b/include/sqlpp11/union_data.h @@ -50,21 +50,15 @@ namespace sqlpp // Interpreters template - struct serializer_t> + Context& serialize(const union_data_t& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = union_data_t; - - static Context& _(const T& t, Context& context) - { - serialize(t._lhs, context); - context << " UNION "; - serialize(Flag{}, context); - context << " "; - serialize(t._rhs, context); - return context; - } - }; + serialize(t._lhs, context); + context << " UNION "; + serialize(Flag{}, context); + context << " "; + serialize(t._rhs, context); + return context; + } } // namespace sqlpp #endif diff --git a/include/sqlpp11/union_flags.h b/include/sqlpp11/union_flags.h index 8649f645..c30e4ba1 100644 --- a/include/sqlpp11/union_flags.h +++ b/include/sqlpp11/union_flags.h @@ -42,16 +42,11 @@ namespace sqlpp }; template - struct serializer_t + Context& serialize(const union_all_t&, Context& context) { - using _serialize_check = consistent_t; - - static Context& _(const union_all_t& /*unused*/, Context& context) - { - context << "ALL"; - return context; - } - }; + context << "ALL"; + return context; + } struct union_distinct_t { @@ -60,15 +55,10 @@ namespace sqlpp }; template - struct serializer_t + Context& serialize(const union_distinct_t&, Context& context) { - using _serialize_check = consistent_t; - - static Context& _(const union_distinct_t& /*unused*/, Context& context) - { - return context; - } - }; + return context; + } } // namespace sqlpp #endif diff --git a/include/sqlpp11/update.h b/include/sqlpp11/update.h index 8bb639b4..860ed54c 100644 --- a/include/sqlpp11/update.h +++ b/include/sqlpp11/update.h @@ -89,18 +89,11 @@ namespace sqlpp }; template - struct serializer_t + Context& serialize(const update_name_t&, Context& context) { - using _serialize_check = consistent_t; - using T = update_name_t; - - static Context& _(const T& /*unused*/, Context& context) - { - context << "UPDATE "; - - return context; - } - }; + context << "UPDATE "; + return context; + } template using blank_update_t = statement_t>; diff --git a/include/sqlpp11/update_list.h b/include/sqlpp11/update_list.h index 746cdd6a..a86f45f9 100644 --- a/include/sqlpp11/update_list.h +++ b/include/sqlpp11/update_list.h @@ -88,10 +88,7 @@ namespace sqlpp static_assert(logic::not_t>::value, "add() argument must not be updated"); static_assert(Policies::template _no_unknown_tables::value, "assignment uses tables unknown to this statement in add()"); - using _serialize_check = sqlpp::serialize_check_t; - _serialize_check{}; - - using ok = logic::all_t<_is_dynamic::value, is_assignment_t::value, _serialize_check::type::value>; + using ok = logic::all_t<_is_dynamic::value, is_assignment_t::value>; _add_impl(assignment, ok()); // dispatch to prevent compile messages after the static_assert } @@ -294,23 +291,17 @@ namespace sqlpp // Interpreters template - struct serializer_t> + Context& serialize(const update_list_data_t& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = update_list_data_t; - - static Context& _(const T& t, Context& context) + context << " SET "; + interpret_tuple(t._assignments, ",", context); + if (sizeof...(Assignments) and not t._dynamic_assignments.empty()) { - context << " SET "; - interpret_tuple(t._assignments, ",", context); - if (sizeof...(Assignments) and not t._dynamic_assignments.empty()) - { - context << ','; - } - interpret_list(t._dynamic_assignments, ',', context); - return context; + context << ','; } - }; + interpret_list(t._dynamic_assignments, ',', context); + return context; + } } // namespace sqlpp #endif diff --git a/include/sqlpp11/using.h b/include/sqlpp11/using.h index 409e2bae..2f8e2047 100644 --- a/include/sqlpp11/using.h +++ b/include/sqlpp11/using.h @@ -80,10 +80,7 @@ namespace sqlpp { static_assert(_is_dynamic::value, "add must not be called for static using()"); static_assert(is_table_t
::value, "invalid table argument in add()"); - using _serialize_check = sqlpp::serialize_check_t; - _serialize_check{}; - - using ok = logic::all_t<_is_dynamic::value, is_table_t
::value, _serialize_check::type::value>; + using ok = logic::all_t<_is_dynamic::value, is_table_t
::value>; _add_impl(table, ok()); // dispatch to prevent compile messages after the static_assert } @@ -240,27 +237,21 @@ namespace sqlpp // Interpreters template - struct serializer_t> + Context& serialize(const using_data_t& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = using_data_t; - - static Context& _(const T& t, Context& context) + if (sizeof...(Tables) == 0 and t._dynamic_tables.empty()) { - if (sizeof...(Tables) == 0 and t._dynamic_tables.empty()) - { - return context; - } - context << " USING "; - interpret_tuple(t._tables, ',', context); - if (sizeof...(Tables) and not t._dynamic_tables.empty()) - { - context << ','; - } - interpret_list(t._dynamic_tables, ',', context); return context; } - }; + context << " USING "; + interpret_tuple(t._tables, ',', context); + if (sizeof...(Tables) and not t._dynamic_tables.empty()) + { + context << ','; + } + interpret_list(t._dynamic_tables, ',', context); + return context; + } } // namespace sqlpp #endif diff --git a/include/sqlpp11/verbatim.h b/include/sqlpp11/verbatim.h index 92dfd655..65397cf7 100644 --- a/include/sqlpp11/verbatim.h +++ b/include/sqlpp11/verbatim.h @@ -57,17 +57,11 @@ namespace sqlpp }; template - struct serializer_t> + Context& serialize(const verbatim_t& t, Context& context) { - using _serialize_check = consistent_t; - using T = verbatim_t; - - static Context& _(const T& t, Context& context) - { - context << t._verbatim; - return context; - } - }; + context << t._verbatim; + return context; + } template auto verbatim(StringType s) -> verbatim_t diff --git a/include/sqlpp11/verbatim_table.h b/include/sqlpp11/verbatim_table.h index 1bbc59d4..46c45905 100644 --- a/include/sqlpp11/verbatim_table.h +++ b/include/sqlpp11/verbatim_table.h @@ -76,17 +76,11 @@ namespace sqlpp }; template - struct serializer_t + Context& serialize(const verbatim_table_t& t, Context& context) { - using _serialize_check = consistent_t; - using T = verbatim_table_t; - - static Context& _(const T& t, Context& context) - { - context << t._representation; - return context; - } - }; + context << t._representation; + return context; + } inline verbatim_table_t verbatim_table(std::string name) { diff --git a/include/sqlpp11/where.h b/include/sqlpp11/where.h index 3d279f78..32cdb8c7 100644 --- a/include/sqlpp11/where.h +++ b/include/sqlpp11/where.h @@ -93,10 +93,7 @@ namespace sqlpp "expression uses tables unknown to this statement in where::add()"); static_assert(not contains_aggregate_function_t::value, "where expression must not contain aggregate functions"); - using _serialize_check = sqlpp::serialize_check_t; - _serialize_check{}; - - using ok = logic::all_t<_is_dynamic::value, is_expression_t::value, _serialize_check::type::value>; + using ok = logic::all_t<_is_dynamic::value, is_expression_t::value>; _add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert } diff --git a/include/sqlpp11/with.h b/include/sqlpp11/with.h index 7f03ea01..7c364439 100644 --- a/include/sqlpp11/with.h +++ b/include/sqlpp11/with.h @@ -191,24 +191,19 @@ namespace sqlpp // Interpreters template - struct serializer_t> + Context& serialize(const with_data_t& t, Context& context) { - using _serialize_check = serialize_check_of; using T = with_data_t; - - static Context& _(const T& t, Context& context) + // FIXME: If there is a recursive CTE, add a "RECURSIVE" here + context << " WITH "; + if (T::_is_recursive::value) { - // FIXME: If there is a recursive CTE, add a "RECURSIVE" here - context << " WITH "; - if (T::_is_recursive::value) - { - context << "RECURSIVE "; - } - interpret_tuple(t._expressions, ',', context); - context << ' '; - return context; + context << "RECURSIVE "; } - }; + interpret_tuple(t._expressions, ',', context); + context << ' '; + return context; + } template auto with(Expressions... cte) -> blank_with_t diff --git a/include/sqlpp11/without_table_check.h b/include/sqlpp11/without_table_check.h index c7703a6f..dd734a5f 100644 --- a/include/sqlpp11/without_table_check.h +++ b/include/sqlpp11/without_table_check.h @@ -33,27 +33,23 @@ namespace sqlpp { template - struct without_table_check_t : Expression + struct without_table_check_t: public Expression { using _required_tables = detail::type_set<>; without_table_check_t(Expression expression) : Expression(expression) { } + + const Expression& expr() const { return *this; } }; template - struct serializer_t> + Context& serialize(const without_table_check_t& t, Context& context) { - using _serialize_check = serialize_check_of; - using T = without_table_check_t; - - static Context& _(const T& t, Context& context) - { - serialize(t, context); - return context; - } - }; + serialize(t.expr(), context); + return context; + } template auto without_table_check(Expression expr) -> without_table_check_t diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b2f8d8be..cdabd006 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -30,21 +30,21 @@ target_compile_options(sqlpp11_testing INTERFACE -Wall -Wextra -pedantic) endif () set(test_names -#BooleanExpression -#CustomQuery -#DateTime -#Interpret -#Insert -#Remove -#Update + BooleanExpression + CustomQuery + DateTime + Interpret + Insert + Remove + Update Select -#SelectType -#Function -#Prepared -#Minimalistic -#Result -#Union -#With + SelectType + Function + Prepared + Minimalistic + Result + Union + With ) find_package(Boost 1.50) @@ -62,7 +62,7 @@ if (SQLPP11_TESTS_CXX_STD) set_property(TARGET sqlpp11_tests PROPERTY CXX_STANDARD ${SQLPP11_TESTS_CXX_STD}) set_property(TARGET sqlpp11_tests PROPERTY CXX_STANDARD_REQUIRED yes) set_property(TARGET sqlpp11_tests PROPERTY CXX_EXTENSIONS no) -endif() +endif() foreach(test IN LISTS test_names) add_test(NAME sqlpp11.tests.${test} diff --git a/tests/Sample.h b/tests/Sample.h index e2a4993c..d0119149 100644 --- a/tests/Sample.h +++ b/tests/Sample.h @@ -142,11 +142,6 @@ namespace test }; }; }; - template - Context& serialize(const TabFoo&, Context& context) - { - return serialize(sqlpp::table_t{}, context); - } namespace TabBar_ { struct Alpha @@ -261,11 +256,6 @@ namespace test }; }; }; - template - Context& serialize(const TabBar&, Context& context) - { - return serialize(sqlpp::table_t{}, context); - } namespace TabDateTime_ { struct ColDayPoint @@ -358,11 +348,5 @@ namespace test }; }; }; - - template - Context& serialize(const TabDateTime&, Context& context) - { - return serialize(sqlpp::table_t{}, context); - } } // namespace test #endif diff --git a/tests/Select.cpp b/tests/Select.cpp index a2aaca60..1e42e7b0 100644 --- a/tests/Select.cpp +++ b/tests/Select.cpp @@ -74,7 +74,6 @@ int Select(int, char*[]) select(count(t.alpha)); std::cerr << serialize(select(sqlpp::value(false).as(sqlpp::alias::a)), printer).str() << std::endl; - /* for (const auto& row : db(select(sqlpp::value(false).as(sqlpp::alias::a)))) { std::cout << row.a << std::endl; @@ -210,7 +209,6 @@ int Select(int, char*[]) std::cout << "Error: transaction isolation level does not match default level" << std::endl; } } - */ return 0; }