From 067740d24ebcceb0dfc5b85144fb778cf96f5bb4 Mon Sep 17 00:00:00 2001 From: rbock Date: Wed, 4 Jun 2014 18:35:25 +0200 Subject: [PATCH] InterpretTest compiles again --- include/sqlpp11/functions.h | 4 ++-- include/sqlpp11/integral.h | 1 + include/sqlpp11/join.h | 2 +- include/sqlpp11/parameter.h | 4 ++-- include/sqlpp11/table_alias.h | 10 ++++---- include/sqlpp11/tvin.h | 2 ++ include/sqlpp11/type_traits.h | 1 + include/sqlpp11/vendor/expression.h | 2 +- include/sqlpp11/vendor/insert_value_list.h | 10 ++++---- include/sqlpp11/vendor/limit.h | 4 ++-- include/sqlpp11/vendor/select_pseudo_table.h | 4 ++-- include/sqlpp11/vendor/wrap_operand.h | 8 +++---- tests/CMakeLists.txt | 4 ++-- tests/InsertTest.cpp | 4 ++-- tests/InterpretTest.cpp | 24 ++++++++++---------- 15 files changed, 43 insertions(+), 41 deletions(-) diff --git a/include/sqlpp11/functions.h b/include/sqlpp11/functions.h index 16742105..2d8ce0f6 100644 --- a/include/sqlpp11/functions.h +++ b/include/sqlpp11/functions.h @@ -50,7 +50,7 @@ namespace sqlpp { using _provided_tables = detail::type_set<>; using _required_tables = ::sqlpp::detail::type_set<>; - static_assert(not is_expression_t::value, "value() is to be called with non-sql-type like int, or string"); + static_assert(is_wrapped_value_t>::value, "value() is to be called with non-sql-type like int, or string"); return { t }; } @@ -149,7 +149,7 @@ namespace sqlpp template auto value_list(Container c) -> value_list_t { - static_assert(not is_expression_t::value, "value_list() is to be called with a container of non-sql-type like std::vector, or std::list(string)"); + static_assert(is_wrapped_value_t>::value, "value_list() is to be called with a container of non-sql-type like std::vector, or std::list(string)"); return { c }; } diff --git a/include/sqlpp11/integral.h b/include/sqlpp11/integral.h index 34366d85..b5e2ad85 100644 --- a/include/sqlpp11/integral.h +++ b/include/sqlpp11/integral.h @@ -42,6 +42,7 @@ namespace sqlpp // integral value type struct integral { + using _traits = make_traits; using _tag = ::sqlpp::tag::integral; using _cpp_value_type = int64_t; diff --git a/include/sqlpp11/join.h b/include/sqlpp11/join.h index d4f96abf..926de5c2 100644 --- a/include/sqlpp11/join.h +++ b/include/sqlpp11/join.h @@ -85,7 +85,7 @@ namespace sqlpp static_assert(not is_join_t::value, "rhs argument for join must not be a join"); static_assert(vendor::is_noop::value or is_on_t::value, "invalid on expression in join().on()"); - static_assert(::sqlpp::detail::is_disjunct_from::value, "joined tables must not be identical"); + static_assert(::sqlpp::detail::is_disjunct_from, provided_tables_of>::value, "joined tables must not be identical"); static_assert(_recursive_traits::_required_tables::size::value == 0, "joined tables must not depend on other tables"); diff --git a/include/sqlpp11/parameter.h b/include/sqlpp11/parameter.h index b3769639..565f236a 100644 --- a/include/sqlpp11/parameter.h +++ b/include/sqlpp11/parameter.h @@ -74,7 +74,7 @@ namespace sqlpp template auto parameter(const NamedExpr&) - -> parameter_t + -> parameter_t, NamedExpr> { static_assert(is_named_expression_t::value, "not a named expression"); return {}; @@ -82,7 +82,7 @@ namespace sqlpp template auto parameter(const ValueType&, const AliasProvider&) - -> parameter_t + -> parameter_t, AliasProvider> { static_assert(is_expression_t::value, "first argument is not a value type"); static_assert(is_alias_provider_t::value, "second argument is not an alias provider"); diff --git a/include/sqlpp11/table_alias.h b/include/sqlpp11/table_alias.h index 754ec175..e357973c 100644 --- a/include/sqlpp11/table_alias.h +++ b/include/sqlpp11/table_alias.h @@ -35,10 +35,8 @@ namespace sqlpp { - struct table_alias_base_t {}; - template - struct table_alias_t: public table_alias_base_t, public ColumnSpec::_name_t::template _member_t>... + struct table_alias_t: public ColumnSpec::_name_t::template _member_t>... { //FIXME: Need to add join functionality using _traits = make_traits, tag::table, tag::alias, tag::named_expression_if>>; @@ -65,10 +63,10 @@ namespace sqlpp namespace vendor { - template - struct serializer_t::value, void>::type> + template + struct serializer_t> { - using T = X; + using T = table_alias_t; static Context& _(const T& t, Context& context) { diff --git a/include/sqlpp11/tvin.h b/include/sqlpp11/tvin.h index 1a517714..255f9d3e 100644 --- a/include/sqlpp11/tvin.h +++ b/include/sqlpp11/tvin.h @@ -42,6 +42,8 @@ namespace sqlpp using _traits = make_traits, tag::expression>; using _recursive_traits = make_recursive_traits; + using _operand_t = Operand; + tvin_t(Operand operand): _value(operand) {} diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index a195f1c0..f276dea3 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -88,6 +88,7 @@ namespace sqlpp detail::is_element_of::value, detail::is_element_of::value>; SQLPP_IS_VALUE_TRAIT_GENERATOR(text); + SQLPP_IS_VALUE_TRAIT_GENERATOR(wrapped_value); SQLPP_IS_VALUE_TRAIT_GENERATOR(expression); SQLPP_IS_VALUE_TRAIT_GENERATOR(named_expression); namespace tag diff --git a/include/sqlpp11/vendor/expression.h b/include/sqlpp11/vendor/expression.h index 17ef6e9e..e91b2d68 100644 --- a/include/sqlpp11/vendor/expression.h +++ b/include/sqlpp11/vendor/expression.h @@ -203,7 +203,7 @@ namespace sqlpp }; template - struct unary_expression_t: public O::_value_type::template expression_operators>, + struct unary_expression_t: public value_type_of::template expression_operators>, public alias_operators> { using _traits = make_traits, sqlpp::tag::expression>; diff --git a/include/sqlpp11/vendor/insert_value_list.h b/include/sqlpp11/vendor/insert_value_list.h index bd9a1be8..f4cb6794 100644 --- a/include/sqlpp11/vendor/insert_value_list.h +++ b/include/sqlpp11/vendor/insert_value_list.h @@ -282,14 +282,14 @@ namespace sqlpp { using _data_t = column_list_data_t; - _impl_t column_list; - _impl_t& operator()() { return column_list; } - const _impl_t& operator()() const { return column_list; } + _impl_t values; + _impl_t& operator()() { return values; } + const _impl_t& operator()() const { return values; } template - static auto _get_member(T t) -> decltype(t.column_list) + static auto _get_member(T t) -> decltype(t.values) { - return t.column_list; + return t.values; } }; diff --git a/include/sqlpp11/vendor/limit.h b/include/sqlpp11/vendor/limit.h index cd5884c4..588b31ee 100644 --- a/include/sqlpp11/vendor/limit.h +++ b/include/sqlpp11/vendor/limit.h @@ -243,9 +243,9 @@ namespace sqlpp }; template - struct serializer_t> + struct serializer_t> { - using T = limit_t; + using T = limit_data_t; static Context& _(const T& t, Context& context) { diff --git a/include/sqlpp11/vendor/select_pseudo_table.h b/include/sqlpp11/vendor/select_pseudo_table.h index eae7ce5a..86e9e4b9 100644 --- a/include/sqlpp11/vendor/select_pseudo_table.h +++ b/include/sqlpp11/vendor/select_pseudo_table.h @@ -55,8 +55,8 @@ namespace sqlpp Select, NamedExpr...>, select_column_spec_t...> { - using _value_type = no_value_t; - using _is_pseudo_table = std::true_type; + using _traits = make_traits; + using _recursive_traits = make_recursive_traits<>; select_pseudo_table_t(Select select): _select(select) diff --git a/include/sqlpp11/vendor/wrap_operand.h b/include/sqlpp11/vendor/wrap_operand.h index 9012aa98..2a832e07 100644 --- a/include/sqlpp11/vendor/wrap_operand.h +++ b/include/sqlpp11/vendor/wrap_operand.h @@ -45,7 +45,7 @@ namespace sqlpp { struct boolean_operand { - using _traits = make_traits<::sqlpp::detail::boolean, ::sqlpp::tag::expression>; + using _traits = make_traits<::sqlpp::detail::boolean, ::sqlpp::tag::expression, ::sqlpp::tag::wrapped_value>; using _recursive_traits = make_recursive_traits<>; using _value_t = bool; @@ -83,7 +83,7 @@ namespace sqlpp struct integral_operand { - using _traits = make_traits<::sqlpp::detail::integral, ::sqlpp::tag::expression>; + using _traits = make_traits<::sqlpp::detail::integral, ::sqlpp::tag::expression, ::sqlpp::tag::wrapped_value>; using _recursive_traits = make_recursive_traits<>; using _value_t = int64_t; @@ -122,7 +122,7 @@ namespace sqlpp struct floating_point_operand { - using _traits = make_traits<::sqlpp::detail::floating_point, ::sqlpp::tag::expression>; + using _traits = make_traits<::sqlpp::detail::floating_point, ::sqlpp::tag::expression, ::sqlpp::tag::wrapped_value>; using _recursive_traits = make_recursive_traits<>; using _value_t = double; @@ -160,7 +160,7 @@ namespace sqlpp struct text_operand { - using _traits = make_traits<::sqlpp::detail::text, ::sqlpp::tag::expression>; + using _traits = make_traits<::sqlpp::detail::text, ::sqlpp::tag::expression, ::sqlpp::tag::wrapped_value>; using _recursive_traits = make_recursive_traits<>; using _value_t = std::string; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 280fe484..8ebcb6f0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,10 +6,10 @@ macro (build_and_run arg) add_test(${arg} ${arg}) endmacro () -#build_and_run(InterpretTest) +build_and_run(InterpretTest) #build_and_run(InsertTest) #build_and_run(RemoveTest) -build_and_run(UpdateTest) +#build_and_run(UpdateTest) #build_and_run(SelectTest) #build_and_run(SelectTypeTest) #build_and_run(FunctionTest) diff --git a/tests/InsertTest.cpp b/tests/InsertTest.cpp index 683ed401..1bee7ba9 100644 --- a/tests/InsertTest.cpp +++ b/tests/InsertTest.cpp @@ -67,8 +67,8 @@ int main() serialize(insert_into(t).set(t.beta = "kirschauflauf"), printer).str(); serialize(insert_into(t).columns(t.beta), printer).str(); auto multi_insert = insert_into(t).columns(t.beta, t.delta); - multi_insert.column_list.add(t.beta = "cheesecake", t.delta = 1); - multi_insert.column_list.add(t.beta = sqlpp::default_value, t.delta = sqlpp::default_value); + multi_insert.values.add(t.beta = "cheesecake", t.delta = 1); + multi_insert.values.add(t.beta = sqlpp::default_value, t.delta = sqlpp::default_value); auto i = dynamic_insert_into(db, t).dynamic_set(); i.insert_list.add(t.beta = "kirschauflauf"); serialize(i, printer).str(); diff --git a/tests/InterpretTest.cpp b/tests/InterpretTest.cpp index 2fd5c3a3..08c33f94 100644 --- a/tests/InterpretTest.cpp +++ b/tests/InterpretTest.cpp @@ -46,12 +46,12 @@ int main() serialize(insert_into(t).columns(t.beta, t.gamma), printer).str(); { auto i = insert_into(t).columns(t.gamma, t.beta); - i.add_values(t.gamma = true, t.beta = "cheesecake"); + i.values.add(t.gamma = true, t.beta = "cheesecake"); serialize(i, printer).str(); - i.add_values(t.gamma = false, t.beta = sqlpp::tvin("coffee")); - i.add_values(t.gamma = false, t.beta = sqlpp::tvin(std::string())); + i.values.add(t.gamma = false, t.beta = sqlpp::tvin("coffee")); + i.values.add(t.gamma = false, t.beta = sqlpp::tvin(std::string())); serialize(i, printer).str(); - i.add_values(t.gamma = sqlpp::default_value, t.beta = sqlpp::null); + i.values.add(t.gamma = sqlpp::default_value, t.beta = sqlpp::null); serialize(i, printer).str(); } @@ -134,22 +134,22 @@ int main() // dynamic select { auto s = dynamic_select(db).dynamic_flags().dynamic_columns().from(t); - s.add_column(t.beta); - s.add_column(t.gamma); + s.selected_columns.add(t.beta); + s.selected_columns.add(t.gamma); serialize(s, printer).str(); } { auto s = dynamic_select(db).dynamic_flags().dynamic_columns().from(t); - s.add_flag(sqlpp::distinct); - s.add_column(t.beta); - s.add_column(t.gamma); + s.select_flags.add(sqlpp::distinct); + s.selected_columns.add(t.beta); + s.selected_columns.add(t.gamma); serialize(s, printer).str(); } { auto s = dynamic_select(db).dynamic_flags(sqlpp::distinct).dynamic_columns(t.alpha).extra_tables(t); // Would fail to run() - s.add_flag(sqlpp::all); - s.add_column(t.beta); - s.add_column(t.gamma); + s.select_flags.add(sqlpp::all); + s.selected_columns.add(t.beta); + s.selected_columns.add(t.gamma); serialize(s, printer).str(); }