From 809d42e4a17f79279a7082b4a87afd8fb6c8590f Mon Sep 17 00:00:00 2001 From: rbock Date: Tue, 25 Nov 2014 17:43:55 +0100 Subject: [PATCH] Introduced check for serializability --- include/sqlpp11/alias.h | 1 + include/sqlpp11/all_of.h | 14 +++++++- include/sqlpp11/any.h | 1 + include/sqlpp11/assignment.h | 1 + include/sqlpp11/avg.h | 1 + include/sqlpp11/boolean_expression.h | 1 + include/sqlpp11/column.h | 1 + include/sqlpp11/concat.h | 1 + include/sqlpp11/count.h | 1 + include/sqlpp11/custom_query.h | 3 +- include/sqlpp11/default_value.h | 1 + include/sqlpp11/exists.h | 1 + include/sqlpp11/expression.h | 5 +++ include/sqlpp11/extra_tables.h | 1 + include/sqlpp11/from.h | 2 ++ include/sqlpp11/functions.h | 1 + include/sqlpp11/group_by.h | 1 + include/sqlpp11/having.h | 1 + include/sqlpp11/hidden.h | 1 + include/sqlpp11/in.h | 1 + include/sqlpp11/insert.h | 1 + include/sqlpp11/insert_value.h | 1 + include/sqlpp11/insert_value_list.h | 3 ++ include/sqlpp11/interpretable.h | 1 + include/sqlpp11/into.h | 1 + include/sqlpp11/is_null.h | 1 + include/sqlpp11/join.h | 1 + include/sqlpp11/like.h | 1 + include/sqlpp11/limit.h | 2 ++ include/sqlpp11/max.h | 1 + include/sqlpp11/min.h | 1 + include/sqlpp11/multi_column.h | 2 ++ include/sqlpp11/named_interpretable.h | 1 + include/sqlpp11/no_data.h | 1 + include/sqlpp11/noop.h | 1 + include/sqlpp11/null.h | 1 + include/sqlpp11/offset.h | 2 ++ include/sqlpp11/on.h | 1 + include/sqlpp11/order_by.h | 1 + include/sqlpp11/parameter.h | 1 + include/sqlpp11/prepared_execute.h | 4 +++ include/sqlpp11/prepared_insert.h | 4 +++ include/sqlpp11/prepared_remove.h | 4 +++ include/sqlpp11/prepared_select.h | 4 +++ include/sqlpp11/prepared_update.h | 4 +++ include/sqlpp11/remove.h | 1 + include/sqlpp11/result_field.h | 1 + include/sqlpp11/rhs_wrap.h | 1 + include/sqlpp11/select.h | 3 +- include/sqlpp11/select_column_list.h | 1 + include/sqlpp11/select_flag_list.h | 1 + include/sqlpp11/select_flags.h | 6 ++++ include/sqlpp11/select_pseudo_table.h | 1 + include/sqlpp11/serialize.h | 10 ------ include/sqlpp11/serializer.h | 16 ++++++++- include/sqlpp11/simple_column.h | 1 + include/sqlpp11/single_table.h | 1 + include/sqlpp11/some.h | 1 + include/sqlpp11/sort_order.h | 1 + include/sqlpp11/statement.h | 10 +++--- include/sqlpp11/sum.h | 1 + include/sqlpp11/table.h | 1 + include/sqlpp11/table_alias.h | 1 + include/sqlpp11/text.h | 1 + include/sqlpp11/tvin.h | 15 +++++++- include/sqlpp11/type_traits.h | 50 +++++++++++++++++++++++++++ include/sqlpp11/update.h | 1 + include/sqlpp11/update_list.h | 1 + include/sqlpp11/using.h | 1 + include/sqlpp11/verbatim.h | 1 + include/sqlpp11/verbatim_table.h | 1 + include/sqlpp11/where.h | 2 ++ include/sqlpp11/wrap_operand.h | 4 +++ tests/MockDb.h | 6 ++-- 74 files changed, 205 insertions(+), 21 deletions(-) diff --git a/include/sqlpp11/alias.h b/include/sqlpp11/alias.h index 61cccb04..22c49dcf 100644 --- a/include/sqlpp11/alias.h +++ b/include/sqlpp11/alias.h @@ -49,6 +49,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = expression_alias_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/all_of.h b/include/sqlpp11/all_of.h index 021da0a8..24c8b5b6 100644 --- a/include/sqlpp11/all_of.h +++ b/include/sqlpp11/all_of.h @@ -51,14 +51,26 @@ namespace sqlpp return {}; } + struct assert_no_stand_alone_all_of_t + { + using type = std::false_type; + + template + static void _() + { + static_assert(wrong_t::value, "all_of(table) seems to be used outside of select"); + } + }; + template struct serializer_t> { + using _serialize_check = assert_no_stand_alone_all_of_t; using T = all_of_t; static Context& _(const T& t, const Context&) { - static_assert(wrong_t::value, "all_of(table) does not seem to be used in select"); + _serialize_check::_(); } }; diff --git a/include/sqlpp11/any.h b/include/sqlpp11/any.h index 79d6aada..2cc6d8a8 100644 --- a/include/sqlpp11/any.h +++ b/include/sqlpp11/any.h @@ -66,6 +66,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = any_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/expression.h b/include/sqlpp11/expression.h index c467c603..74e6f876 100644 --- a/include/sqlpp11/expression.h +++ b/include/sqlpp11/expression.h @@ -66,6 +66,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = equal_to_t; static Context& _(const T& t, Context& context) @@ -114,6 +115,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = not_equal_to_t; static Context& _(const T& t, Context& context) @@ -158,6 +160,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = logical_not_t; static Context& _(const T& t, Context& context) @@ -205,6 +208,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = binary_expression_t; static Context& _(const T& t, Context& context) @@ -242,6 +246,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = unary_expression_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/extra_tables.h b/include/sqlpp11/extra_tables.h index 473479b5..3c52eff8 100644 --- a/include/sqlpp11/extra_tables.h +++ b/include/sqlpp11/extra_tables.h @@ -157,6 +157,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = extra_tables_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/from.h b/include/sqlpp11/from.h index 84d107c9..c1e4fc34 100644 --- a/include/sqlpp11/from.h +++ b/include/sqlpp11/from.h @@ -78,6 +78,7 @@ namespace sqlpp using _known_tables = detail::make_joined_set_t...>; // Hint: Joins contain more than one table using _known_table_names = detail::transform_set_t; static_assert(not detail::is_element_of::value, "Must not use the same table name twice in from()"); +#warning: need to add a check if the argument is serializable! using ok = detail::all_t<_is_dynamic::value, is_table_t
::value>; @@ -205,6 +206,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = from_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/functions.h b/include/sqlpp11/functions.h index 75eacd90..9172cb81 100644 --- a/include/sqlpp11/functions.h +++ b/include/sqlpp11/functions.h @@ -100,6 +100,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of>; using T = value_list_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/group_by.h b/include/sqlpp11/group_by.h index e9bd0e9d..6c6fdd09 100644 --- a/include/sqlpp11/group_by.h +++ b/include/sqlpp11/group_by.h @@ -195,6 +195,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = group_by_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/having.h b/include/sqlpp11/having.h index b43f73e9..c0cdb80f 100644 --- a/include/sqlpp11/having.h +++ b/include/sqlpp11/having.h @@ -193,6 +193,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = having_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/hidden.h b/include/sqlpp11/hidden.h index e9f98cfa..3ceb4f53 100644 --- a/include/sqlpp11/hidden.h +++ b/include/sqlpp11/hidden.h @@ -47,6 +47,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = consistent_t; using T = hidden_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/in.h b/include/sqlpp11/in.h index 3d8a98a0..6726f7b5 100644 --- a/include/sqlpp11/in.h +++ b/include/sqlpp11/in.h @@ -73,6 +73,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = in_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/insert.h b/include/sqlpp11/insert.h index 52f1e749..9e8b81a4 100644 --- a/include/sqlpp11/insert.h +++ b/include/sqlpp11/insert.h @@ -90,6 +90,7 @@ namespace sqlpp template struct serializer_t { + using _serialize_check = consistent_t; using T = insert_name_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/insert_value.h b/include/sqlpp11/insert_value.h index 061bbd82..4845b217 100644 --- a/include/sqlpp11/insert_value.h +++ b/include/sqlpp11/insert_value.h @@ -103,6 +103,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = insert_value_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/insert_value_list.h b/include/sqlpp11/insert_value_list.h index b20efded..b893f641 100644 --- a/include/sqlpp11/insert_value_list.h +++ b/include/sqlpp11/insert_value_list.h @@ -425,6 +425,7 @@ namespace sqlpp template struct serializer_t { + using _serialize_check = consistent_t; using T = insert_default_values_data_t; static Context& _(const T& t, Context& context) @@ -437,6 +438,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = column_list_data_t; static Context& _(const T& t, Context& context) @@ -464,6 +466,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = insert_list_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/interpretable.h b/include/sqlpp11/interpretable.h index d89075be..2e22ca9d 100644 --- a/include/sqlpp11/interpretable.h +++ b/include/sqlpp11/interpretable.h @@ -114,6 +114,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = consistent_t; using T = interpretable_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/into.h b/include/sqlpp11/into.h index 71bb48cf..b4b86633 100644 --- a/include/sqlpp11/into.h +++ b/include/sqlpp11/into.h @@ -167,6 +167,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = into_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/is_null.h b/include/sqlpp11/is_null.h index ecc06bd5..bca37cf0 100644 --- a/include/sqlpp11/is_null.h +++ b/include/sqlpp11/is_null.h @@ -69,6 +69,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = is_null_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/join.h b/include/sqlpp11/join.h index e7b444a7..f1097468 100644 --- a/include/sqlpp11/join.h +++ b/include/sqlpp11/join.h @@ -145,6 +145,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = join_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/like.h b/include/sqlpp11/like.h index 2a73baa3..b5bb9101 100644 --- a/include/sqlpp11/like.h +++ b/include/sqlpp11/like.h @@ -71,6 +71,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = like_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/limit.h b/include/sqlpp11/limit.h index 49266fb8..5ada9791 100644 --- a/include/sqlpp11/limit.h +++ b/include/sqlpp11/limit.h @@ -231,6 +231,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = consistent_t; using T = dynamic_limit_data_t; static Context& _(const T& t, Context& context) @@ -247,6 +248,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = limit_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/max.h b/include/sqlpp11/max.h index 440d1f31..251d6023 100644 --- a/include/sqlpp11/max.h +++ b/include/sqlpp11/max.h @@ -67,6 +67,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = max_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/min.h b/include/sqlpp11/min.h index e5387d37..04bb30cf 100644 --- a/include/sqlpp11/min.h +++ b/include/sqlpp11/min.h @@ -67,6 +67,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = min_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/multi_column.h b/include/sqlpp11/multi_column.h index 44288b83..dce7dce2 100644 --- a/include/sqlpp11/multi_column.h +++ b/include/sqlpp11/multi_column.h @@ -103,6 +103,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = multi_column_t; static void _(const T& t, Context& context) @@ -114,6 +115,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = multi_column_alias_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/named_interpretable.h b/include/sqlpp11/named_interpretable.h index 5ba0f044..3ec6c1ea 100644 --- a/include/sqlpp11/named_interpretable.h +++ b/include/sqlpp11/named_interpretable.h @@ -123,6 +123,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = consistent_t; using T = named_interpretable_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/no_data.h b/include/sqlpp11/no_data.h index e94a9289..2c0952b4 100644 --- a/include/sqlpp11/no_data.h +++ b/include/sqlpp11/no_data.h @@ -37,6 +37,7 @@ namespace sqlpp template struct serializer_t { + using _serialize_check = consistent_t; using T = no_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/noop.h b/include/sqlpp11/noop.h index d2341f1c..62f3b7db 100644 --- a/include/sqlpp11/noop.h +++ b/include/sqlpp11/noop.h @@ -84,6 +84,7 @@ namespace sqlpp template struct serializer_t { + using _serialize_check = consistent_t; using T = noop; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/null.h b/include/sqlpp11/null.h index 93e0706b..0432c387 100644 --- a/include/sqlpp11/null.h +++ b/include/sqlpp11/null.h @@ -40,6 +40,7 @@ namespace sqlpp template struct serializer_t { + using _serialize_check = consistent_t; using Operand = null_t; static Context& _(const Operand& t, Context& context) diff --git a/include/sqlpp11/offset.h b/include/sqlpp11/offset.h index bc8d6769..4d0f7c1a 100644 --- a/include/sqlpp11/offset.h +++ b/include/sqlpp11/offset.h @@ -242,6 +242,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = offset_data_t; static Context& _(const T& t, Context& context) @@ -255,6 +256,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = consistent_t; using T = dynamic_offset_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/on.h b/include/sqlpp11/on.h index 2a88eafb..8762d3c0 100644 --- a/include/sqlpp11/on.h +++ b/include/sqlpp11/on.h @@ -58,6 +58,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = on_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/order_by.h b/include/sqlpp11/order_by.h index c27cf92b..12dc3a8a 100644 --- a/include/sqlpp11/order_by.h +++ b/include/sqlpp11/order_by.h @@ -195,6 +195,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = order_by_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/parameter.h b/include/sqlpp11/parameter.h index 687096b3..b5daaabc 100644 --- a/include/sqlpp11/parameter.h +++ b/include/sqlpp11/parameter.h @@ -63,6 +63,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = consistent_t; using T = parameter_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/prepared_execute.h b/include/sqlpp11/prepared_execute.h index e9c27c9d..c328bbc1 100644 --- a/include/sqlpp11/prepared_execute.h +++ b/include/sqlpp11/prepared_execute.h @@ -29,12 +29,16 @@ #include #include +#include namespace sqlpp { template struct prepared_execute_t { + using _traits = make_traits; + using _recursive_traits = make_recursive_traits<>; + using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; diff --git a/include/sqlpp11/prepared_insert.h b/include/sqlpp11/prepared_insert.h index 51c759fe..e81a56c0 100644 --- a/include/sqlpp11/prepared_insert.h +++ b/include/sqlpp11/prepared_insert.h @@ -29,12 +29,16 @@ #include #include +#include namespace sqlpp { template struct prepared_insert_t { + using _traits = make_traits; + using _recursive_traits = make_recursive_traits<>; + using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; diff --git a/include/sqlpp11/prepared_remove.h b/include/sqlpp11/prepared_remove.h index 3203ee1b..d4a4dfad 100644 --- a/include/sqlpp11/prepared_remove.h +++ b/include/sqlpp11/prepared_remove.h @@ -29,12 +29,16 @@ #include #include +#include namespace sqlpp { template struct prepared_remove_t { + using _traits = make_traits; + using _recursive_traits = make_recursive_traits<>; + using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; diff --git a/include/sqlpp11/prepared_select.h b/include/sqlpp11/prepared_select.h index 40553931..70665558 100644 --- a/include/sqlpp11/prepared_select.h +++ b/include/sqlpp11/prepared_select.h @@ -29,12 +29,16 @@ #include #include +#include namespace sqlpp { template struct prepared_select_t { + using _traits = make_traits; + using _recursive_traits = make_recursive_traits<>; + using _result_row_t = typename Statement::template _result_row_t; using _parameter_list_t = make_parameter_list_t; using _dynamic_names_t = typename Statement::_dynamic_names_t; diff --git a/include/sqlpp11/prepared_update.h b/include/sqlpp11/prepared_update.h index b7f94b86..4bd54c85 100644 --- a/include/sqlpp11/prepared_update.h +++ b/include/sqlpp11/prepared_update.h @@ -29,12 +29,16 @@ #include #include +#include namespace sqlpp { template struct prepared_update_t { + using _traits = make_traits; + using _recursive_traits = make_recursive_traits<>; + using _parameter_list_t = make_parameter_list_t; using _prepared_statement_t = typename Db::_prepared_statement_t; diff --git a/include/sqlpp11/remove.h b/include/sqlpp11/remove.h index a74cc710..8d5f43be 100644 --- a/include/sqlpp11/remove.h +++ b/include/sqlpp11/remove.h @@ -91,6 +91,7 @@ namespace sqlpp template struct serializer_t { + using _serialize_check = consistent_t; using T = remove_name_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/result_field.h b/include/sqlpp11/result_field.h index 476ca3ea..9dbdb27a 100644 --- a/include/sqlpp11/result_field.h +++ b/include/sqlpp11/result_field.h @@ -41,6 +41,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = consistent_t; using T = result_field_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/rhs_wrap.h b/include/sqlpp11/rhs_wrap.h index c664d580..610ec634 100644 --- a/include/sqlpp11/rhs_wrap.h +++ b/include/sqlpp11/rhs_wrap.h @@ -147,6 +147,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = rhs_wrap_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/select.h b/include/sqlpp11/select.h index 3a2556a5..1da653e0 100644 --- a/include/sqlpp11/select.h +++ b/include/sqlpp11/select.h @@ -49,12 +49,13 @@ namespace sqlpp { struct select_name_t {}; - struct select_t: public statement_name_t + struct select_t: public statement_name_t {}; template struct serializer_t { + using _serialize_check = consistent_t; using T = select_name_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/select_column_list.h b/include/sqlpp11/select_column_list.h index af247c7f..4688b3cb 100644 --- a/include/sqlpp11/select_column_list.h +++ b/include/sqlpp11/select_column_list.h @@ -411,6 +411,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = select_column_list_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/select_flag_list.h b/include/sqlpp11/select_flag_list.h index afeaa9d4..faa41cdf 100644 --- a/include/sqlpp11/select_flag_list.h +++ b/include/sqlpp11/select_flag_list.h @@ -195,6 +195,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = select_flag_list_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/select_flags.h b/include/sqlpp11/select_flags.h index 002bd67a..580d66ab 100644 --- a/include/sqlpp11/select_flags.h +++ b/include/sqlpp11/select_flags.h @@ -45,6 +45,8 @@ namespace sqlpp template struct serializer_t { + using _serialize_check = consistent_t; + static Context& _(const all_t&, Context& context) { context << "ALL"; @@ -62,6 +64,8 @@ namespace sqlpp template struct serializer_t { + using _serialize_check = consistent_t; + static Context& _(const distinct_t&, Context& context) { context << "DISTINCT"; @@ -79,6 +83,8 @@ namespace sqlpp template struct serializer_t { + using _serialize_check = consistent_t; + static Context& _(const straight_join_t&, Context& context) { context << "STRAIGHT_JOIN"; diff --git a/include/sqlpp11/select_pseudo_table.h b/include/sqlpp11/select_pseudo_table.h index 75f8dbf0..28429e5f 100644 --- a/include/sqlpp11/select_pseudo_table.h +++ b/include/sqlpp11/select_pseudo_table.h @@ -75,6 +75,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = select_pseudo_table_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/serialize.h b/include/sqlpp11/serialize.h index e7331320..69e79fe5 100644 --- a/include/sqlpp11/serialize.h +++ b/include/sqlpp11/serialize.h @@ -37,16 +37,6 @@ namespace sqlpp { return serializer_t::_(t, context); } - - /* - template - auto serialize(const T& t, Context& context) - -> decltype(serializer_t::_(t, context)) - { - return serializer_t::_(t, context); - } - */ - } #endif diff --git a/include/sqlpp11/serializer.h b/include/sqlpp11/serializer.h index 04629bda..46261e0e 100644 --- a/include/sqlpp11/serializer.h +++ b/include/sqlpp11/serializer.h @@ -31,12 +31,26 @@ namespace sqlpp { + template + struct assert_serializer_specialization_t + { + using type = std::false_type; + + template + static void _() + { + static_assert(wrong_t::value, "missing serializer specialization"); + } + }; + template struct serializer_t { + using _serialize_check = assert_serializer_specialization_t; + static void _(const T& t, Context& context) { - static_assert(wrong_t::value, "missing serializer specialization"); + _serialize_check::_(); } }; diff --git a/include/sqlpp11/simple_column.h b/include/sqlpp11/simple_column.h index dd1769c6..7bd0c02e 100644 --- a/include/sqlpp11/simple_column.h +++ b/include/sqlpp11/simple_column.h @@ -44,6 +44,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = simple_column_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/single_table.h b/include/sqlpp11/single_table.h index f30a06c8..13b8bb20 100644 --- a/include/sqlpp11/single_table.h +++ b/include/sqlpp11/single_table.h @@ -155,6 +155,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = single_table_data_t; static Context& _(const T& t, Context& context) diff --git a/include/sqlpp11/some.h b/include/sqlpp11/some.h index 00dfb755..d457680d 100644 --- a/include/sqlpp11/some.h +++ b/include/sqlpp11/some.h @@ -66,6 +66,7 @@ namespace sqlpp template struct serializer_t> { + using _serialize_check = serialize_check_of; using T = some_t