From 8d16b6ab2d7106625321f6a1ffde4b159760b6df Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 2 Jun 2014 23:57:21 +0200 Subject: [PATCH] Migrated insert to generic statement --- include/sqlpp11/insert.h | 44 +--- include/sqlpp11/select.h | 158 +----------- include/sqlpp11/statement.h | 193 +++++++++++++++ include/sqlpp11/vendor/insert_value_list.h | 264 +++++++++++++++------ include/sqlpp11/vendor/single_table.h | 140 +++++++++-- tests/CMakeLists.txt | 4 +- tests/InsertTest.cpp | 6 +- 7 files changed, 520 insertions(+), 289 deletions(-) create mode 100644 include/sqlpp11/statement.h diff --git a/include/sqlpp11/insert.h b/include/sqlpp11/insert.h index b1141ae8..587906e2 100644 --- a/include/sqlpp11/insert.h +++ b/include/sqlpp11/insert.h @@ -27,6 +27,7 @@ #ifndef SQLPP_INSERT_H #define SQLPP_INSERT_H +#include #include #include #include @@ -34,13 +35,10 @@ #include #include #include -#include - -#include -#include namespace sqlpp { +#if 0 template struct insert_t; @@ -121,39 +119,6 @@ namespace sqlpp insert_t& operator=(insert_t&&) = default; ~insert_t() = default; - // run and prepare - static constexpr size_t _get_static_no_of_parameters() - { - return _parameter_list_t::size::value; - } - - size_t _get_no_of_parameters() const - { - return _parameter_list_t::size::value; - } - - void _check_consistency() const - { - // FIXME: Read up on what is allowed/prohibited in INSERT - } - - template - std::size_t _run(Database& db) const - { - _check_consistency(); - - static_assert(_get_static_no_of_parameters() == 0, "cannot run insert directly with parameters, use prepare instead"); - return db.insert(*this); - } - - template - auto _prepare(Database& db) const - -> prepared_insert_t - { - _check_consistency(); - - return {{}, db.prepare_insert(*this)}; - } }; namespace vendor @@ -173,13 +138,14 @@ namespace sqlpp } }; } +#endif template - using blank_insert_t = insert_t; - constexpr auto insert() + auto insert() -> blank_insert_t { return { blank_insert_t() }; diff --git a/include/sqlpp11/select.h b/include/sqlpp11/select.h index d9c56574..a49b0201 100644 --- a/include/sqlpp11/select.h +++ b/include/sqlpp11/select.h @@ -27,9 +27,7 @@ #ifndef SQLPP_SELECT_H #define SQLPP_SELECT_H -#include -#include -#include +#include #include #include @@ -43,165 +41,13 @@ #include #include #include -#include #include -#include -#include -#include namespace sqlpp { - template - struct select_t; - -#warning STEPS: -#warning deal with different return types in the connector (select could be a single value, update could be a range of rows) - namespace detail - { - template - struct select_policies_t - { -#warning need to check policies' signature, e.g. a _data_t in _member_t template - using _database_t = Db; - using _statement_t = select_t; - - struct _methods_t: public Policies::template _methods_t... - {}; - - template - struct _policies_update_t - { - static_assert(detail::is_element_of>::value, "policies update for non-policy class detected"); - using type = select_t...>; - }; - - template - using _new_statement_t = typename _policies_update_t::type; - - using _all_required_tables = detail::make_joined_set_t...>; - using _all_provided_tables = detail::make_joined_set_t...>; - using _all_extra_tables = detail::make_joined_set_t...>; - - using _known_tables = detail::make_joined_set_t<_all_provided_tables, _all_extra_tables>; - - template - using _no_unknown_tables = detail::is_subset_of, _known_tables>; - - // The tables not covered by the from. - using _required_tables = detail::make_difference_set_t< - _all_required_tables, - _all_provided_tables // Hint: extra_tables are not used here because they are just a helper for dynamic .add_*() - >; - - using _result_type_provider = detail::get_last_if; - - struct _result_methods_t: public _result_type_provider::template _result_methods_t - {}; - - - // A select can be used as a pseudo table if - // - at least one column is selected - // - the select is complete (leaks no tables) - using _can_be_used_as_table = typename std::conditional< - is_select_column_list_t<_result_type_provider>::value and _required_tables::size::value == 0, - std::true_type, - std::false_type - >::type; - - using _value_type = typename std::conditional< - detail::none_t::value...>::value, - value_type_of<_result_type_provider>, - no_value_t // if a required statement part is missing (e.g. columns in a select), then the statement cannot be used as a value - >::type; - - using _is_expression = typename std::conditional< - std::is_same<_value_type, no_value_t>::value, - std::false_type, - std::true_type>::type; - - using _traits = make_traits<_value_type>; - - struct _recursive_traits - { - using _parameters = std::tuple<>; // FIXME - using _required_tables = _required_tables; - using _provided_tables = detail::type_set<>; - using _extra_tables = detail::type_set<>; - }; - - static void _check_consistency() - { -#warning check for missing terms here, and for missing tables - static_assert(not required_tables_of::size::value, "one sub expression requires tables which are otherwise not known in the statement"); - } - - }; - } - - // SELECT - template - struct select_t: - public Policies::template _member_t>..., - public detail::select_policies_t::_value_type::template expression_operators>, - public detail::select_policies_t::_result_methods_t, - public detail::select_policies_t::_methods_t - { - using _policies_t = typename detail::select_policies_t; - - using _traits = make_traits, ::sqlpp::tag::select, tag::expression_if, tag::named_expression_if>; - using _recursive_traits = typename _policies_t::_recursive_traits; - - using _result_type_provider = typename _policies_t::_result_type_provider; - - using _requires_braces = std::true_type; - - using _name_t = typename _result_type_provider::_name_t; - - // Constructors - select_t() - {} - - template - select_t(Statement statement, Term term): - Policies::template _member_t<_policies_t>{ - typename Policies::template _impl_t<_policies_t>{ - detail::pick_arg>(statement, term) - }}... - //Policies::template _member_t<_policies_t>{{detail::pick_arg>(statement, term)}}... - {} - - select_t(const select_t& r) = default; - select_t(select_t&& r) = default; - select_t& operator=(const select_t& r) = default; - select_t& operator=(select_t&& r) = default; - ~select_t() = default; - }; - - namespace vendor - { - template - struct serializer_t> - { - using T = select_t; - using P = ::sqlpp::detail::select_policies_t; - - static Context& _(const T& t, Context& context) - { - context << "SELECT "; - - using swallow = int[]; - (void) swallow{(serialize(static_cast&>(t)()._data, context), 0)...}; - - return context; - } - }; - } - template - using blank_select_t = select_t +#include +#include +#include +#include + +#include +#include + +namespace sqlpp +{ + template + struct statement_t; + +#warning STEPS: +#warning deal with different return types in the connector (select could be a single value, update could be a range of rows) + namespace detail + { + template + struct statement_policies_t + { +#warning need to check policies' signature, e.g. a _data_t in _member_t template + using _database_t = Db; + using _statement_t = statement_t; + + struct _methods_t: public Policies::template _methods_t... + {}; + + template + struct _policies_update_t + { + static_assert(detail::is_element_of>::value, "policies update for non-policy class detected"); + using type = statement_t...>; + }; + + template + using _new_statement_t = typename _policies_update_t::type; + + using _all_required_tables = detail::make_joined_set_t...>; + using _all_provided_tables = detail::make_joined_set_t...>; + using _all_extra_tables = detail::make_joined_set_t...>; + + using _known_tables = detail::make_joined_set_t<_all_provided_tables, _all_extra_tables>; + + template + using _no_unknown_tables = detail::is_subset_of, _known_tables>; + + // The tables not covered by the from. + using _required_tables = detail::make_difference_set_t< + _all_required_tables, + _all_provided_tables // Hint: extra_tables are not used here because they are just a helper for dynamic .add_*() + >; + + using _result_type_provider = detail::get_last_if; + + struct _result_methods_t: public _result_type_provider::template _result_methods_t + {}; + + + // A select can be used as a pseudo table if + // - at least one column is selected + // - the select is complete (leaks no tables) + using _can_be_used_as_table = typename std::conditional< + is_select_column_list_t<_result_type_provider>::value and _required_tables::size::value == 0, + std::true_type, + std::false_type + >::type; + + using _value_type = typename std::conditional< + detail::none_t::value...>::value, + value_type_of<_result_type_provider>, + no_value_t // if a required statement part is missing (e.g. columns in a select), then the statement cannot be used as a value + >::type; + + using _is_expression = typename std::conditional< + std::is_same<_value_type, no_value_t>::value, + std::false_type, + std::true_type>::type; + + using _traits = make_traits<_value_type>; + + struct _recursive_traits + { + using _parameters = std::tuple<>; // FIXME + using _required_tables = _required_tables; + using _provided_tables = detail::type_set<>; + using _extra_tables = detail::type_set<>; + }; + + static void _check_consistency() + { +#warning check for missing terms here, and for missing tables + static_assert(not required_tables_of::size::value, "one sub expression requires tables which are otherwise not known in the statement"); + } + + }; + } + + // SELECT + template + struct statement_t: + public Policies::template _member_t>..., + public detail::statement_policies_t::_value_type::template expression_operators>, + public detail::statement_policies_t::_result_methods_t, + public detail::statement_policies_t::_methods_t + { + using _policies_t = typename detail::statement_policies_t; + + using _traits = make_traits, ::sqlpp::tag::select, tag::expression_if, tag::named_expression_if>; + using _recursive_traits = typename _policies_t::_recursive_traits; + + using _result_type_provider = typename _policies_t::_result_type_provider; + + using _requires_braces = std::true_type; + + using _name_t = typename _result_type_provider::_name_t; + + // Constructors + statement_t() + {} + + template + statement_t(Statement statement, Term term): + Policies::template _member_t<_policies_t>{ + typename Policies::template _impl_t<_policies_t>{ + detail::pick_arg>(statement, term) + }}... + //Policies::template _member_t<_policies_t>{{detail::pick_arg>(statement, term)}}... + {} + + statement_t(const statement_t& r) = default; + statement_t(statement_t&& r) = default; + statement_t& operator=(const statement_t& r) = default; + statement_t& operator=(statement_t&& r) = default; + ~statement_t() = default; + }; + + namespace vendor + { + template + struct serializer_t> + { + using T = statement_t; + using P = ::sqlpp::detail::statement_policies_t; + + static Context& _(const T& t, Context& context) + { +#warning: Need to have a class that provides the "SELECT" or "INSERT", etc + context << "SELECT "; + + using swallow = int[]; + (void) swallow{(serialize(static_cast&>(t)()._data, context), 0)...}; + + return context; + } + }; + } +} + +#endif + + diff --git a/include/sqlpp11/vendor/insert_value_list.h b/include/sqlpp11/vendor/insert_value_list.h index 9cebe8d1..bd9a1be8 100644 --- a/include/sqlpp11/vendor/insert_value_list.h +++ b/include/sqlpp11/vendor/insert_value_list.h @@ -39,17 +39,69 @@ namespace sqlpp { namespace vendor { + struct insert_default_values_data_t + {}; + // COLUMN AND VALUE LIST struct insert_default_values_t { using _traits = make_traits; using _recursive_traits = make_recursive_traits<>; + // Data + using _data_t = insert_default_values_data_t; + + // Member implementation with data and methods + template + struct _impl_t + { + _data_t _data; + }; + + // Member template for adding the named member to a statement + template + struct _member_t + { + using _data_t = insert_default_values_data_t; + + _impl_t default_values; + _impl_t& operator()() { return default_values; } + const _impl_t& operator()() const { return default_values; } + + template + static auto _get_member(T t) -> decltype(t.default_values) + { + return t.default_values; + } + }; + template struct _methods_t {}; }; + template + struct insert_list_data_t + { + insert_list_data_t(Assignments... assignments): + _assignments(assignments...), + _columns({assignments._lhs}...), + _values(assignments._rhs...) + {} + + insert_list_data_t(const insert_list_data_t&) = default; + insert_list_data_t(insert_list_data_t&&) = default; + insert_list_data_t& operator=(const insert_list_data_t&) = default; + insert_list_data_t& operator=(insert_list_data_t&&) = default; + ~insert_list_data_t() = default; + + std::tuple...> _columns; + std::tuple _values; + std::tuple _assignments; // FIXME: Need to replace _columns and _values by _assignments (connector-container requires assignments) + typename vendor::interpretable_list_t _dynamic_columns; + typename vendor::interpretable_list_t _dynamic_values; + }; + template struct insert_list_t { @@ -81,36 +133,26 @@ namespace sqlpp static_assert(::sqlpp::detail::is_subset_of<_value_required_tables, _column_required_tables>::value, "set() contains values from foreign tables"); */ - insert_list_t& _insert_value_list() { return *this; } + // Data + using _data_t = insert_list_data_t; - insert_list_t(Assignments... assignment): - _assignments(assignment...), - _columns({assignment._lhs}...), - _values(assignment._rhs...) - {} - - insert_list_t(const insert_list_t&) = default; - insert_list_t(insert_list_t&&) = default; - insert_list_t& operator=(const insert_list_t&) = default; - insert_list_t& operator=(insert_list_t&&) = default; - ~insert_list_t() = default; - - template - struct _methods_t + // Member implementation with data and methods + template + struct _impl_t { template - void add_set_ntc(Assignment assignment) + void add_ntc(Assignment assignment) { - add_set(assignment); + add(assignment); } template - void add_set(Assignment assignment) + void add(Assignment assignment) { - static_assert(_is_dynamic::value, "add_set must not be called for static from()"); - static_assert(is_assignment_t::value, "add_set() arguments require to be assigments"); - static_assert(not must_not_insert_t::value, "add_set() argument must not be used in insert"); - static_assert(not TableCheckRequired::value or Policies::template _no_unknown_tables::value, "add_set() contains a column from a foreign table"); + static_assert(_is_dynamic::value, "add must not be called for static from()"); + static_assert(is_assignment_t::value, "add() arguments require to be assigments"); + static_assert(not must_not_insert_t::value, "add() argument must not be used in insert"); + static_assert(not TableCheckRequired::value or Policies::template _no_unknown_tables::value, "add() contains a column from a foreign table"); using ok = ::sqlpp::detail::all_t< _is_dynamic::value, @@ -118,28 +160,67 @@ namespace sqlpp not must_not_insert_t::value, (not TableCheckRequired::value or Policies::template _no_unknown_tables::value)>; - _add_set_impl(assignment, ok()); // dispatch to prevent compile messages after the static_assert + _add_impl(assignment, ok()); // dispatch to prevent compile messages after the static_assert } private: template - void _add_set_impl(Assignment assignment, const std::true_type&) + void _add_impl(Assignment assignment, const std::true_type&) { - static_cast(this)->_insert_value_list()._dynamic_columns.emplace_back(simple_column_t{assignment._lhs}); - static_cast(this)->_insert_value_list()._dynamic_values.emplace_back(assignment._rhs); + _data._dynamic_columns.emplace_back(simple_column_t{assignment._lhs}); + _data._dynamic_values.emplace_back(assignment._rhs); } template - void _add_set_impl(Assignment assignment, const std::false_type&); + void _add_impl(Assignment assignment, const std::false_type&); + public: + _data_t _data; + }; + + // Member template for adding the named member to a statement + template + struct _member_t + { + using _data_t = insert_list_data_t; + + _impl_t insert_list; + _impl_t& operator()() { return insert_list; } + const _impl_t& operator()() const { return insert_list; } + + template + static auto _get_member(T t) -> decltype(t.insert_list) + { + return t.insert_list; + } + }; + + // Additional methods for the statement + template + struct _methods_t + { }; - std::tuple...> _columns; - std::tuple _values; - std::tuple _assignments; // FIXME: Need to replace _columns and _values by _assignments (connector-container requires assignments) - typename vendor::interpretable_list_t _dynamic_columns; - typename vendor::interpretable_list_t _dynamic_values; + }; + + template + struct column_list_data_t + { + column_list_data_t(Columns... columns): + _columns(simple_column_t{columns}...) + {} + + column_list_data_t(const column_list_data_t&) = default; + column_list_data_t(column_list_data_t&&) = default; + column_list_data_t& operator=(const column_list_data_t&) = default; + column_list_data_t& operator=(column_list_data_t&&) = default; + ~column_list_data_t() = default; + +#warning need to define just one version of value_tuple_t + using _value_tuple_t = std::tuple...>; + std::tuple...> _columns; + std::vector<_value_tuple_t> _insert_values; }; template @@ -160,23 +241,15 @@ namespace sqlpp static_assert(required_tables_of::size::value == 1, "columns from multiple tables in columns()"); - column_list_t& _insert_value_list() { return *this; } + // Data + using _data_t = column_list_data_t; - column_list_t(Columns... columns): - _columns(simple_column_t{columns}...) - {} - - column_list_t(const column_list_t&) = default; - column_list_t(column_list_t&&) = default; - column_list_t& operator=(const column_list_t&) = default; - column_list_t& operator=(column_list_t&&) = default; - ~column_list_t() = default; - - template - struct _methods_t + // Member implementation with data and methods + template + struct _impl_t { template - void add_values(Assignments... assignments) + void add(Assignments... assignments) { static_assert(::sqlpp::detail::all_t::value...>::value, "add_values() arguments have to be assignments"); using _arg_value_tuple = std::tuple...>; @@ -187,35 +260,87 @@ namespace sqlpp ::sqlpp::detail::all_t::value...>::value, _args_correct::value>; - _add_values_impl(ok(), assignments...); // dispatch to prevent compile messages after the static_assert + _add_impl(ok(), assignments...); // dispatch to prevent compile messages after the static_assert } private: template - void _add_values_impl(const std::true_type&, Assignments... assignments) + void _add_impl(const std::true_type&, Assignments... assignments) { - return static_cast(this)->_insert_value_list()._insert_values.emplace_back(vendor::insert_value_t{assignments}...); + return _data._insert_values.emplace_back(vendor::insert_value_t{assignments}...); } template - void _add_values_impl(const std::false_type&, Assignments... assignments); + void _add_impl(const std::false_type&, Assignments... assignments); + public: + _data_t _data; }; + // Member template for adding the named member to a statement + template + struct _member_t + { + 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; } + + template + static auto _get_member(T t) -> decltype(t.column_list) + { + return t.column_list; + } + }; + + // Additional methods for the statement + template + struct _methods_t + { + }; + +/* bool empty() const { return _insert_values.empty(); } - - std::tuple...> _columns; - std::vector<_value_tuple_t> _insert_values; + */ }; + // NO HAVING YET struct no_insert_value_list_t { using _traits = make_traits; using _recursive_traits = make_recursive_traits<>; + // Data + using _data_t = no_data_t; + + // Member implementation with data and methods + template + struct _impl_t + { + _data_t _data; + }; + + // Member template for adding the named member to a statement + template + struct _member_t + { + using _data_t = no_data_t; + + _impl_t no_insert_values; + _impl_t& operator()() { return no_insert_values; } + const _impl_t& operator()() const { return no_insert_values; } + + template + static auto _get_member(T t) -> decltype(t.no_insert_values) + { + return t.no_insert_values; + } + }; + template struct _methods_t { @@ -226,21 +351,21 @@ namespace sqlpp auto default_values() -> _new_statement_t { - return { *static_cast(this), insert_default_values_t{} }; + return { *static_cast(this), insert_default_values_data_t{} }; } template auto columns(Args... args) -> _new_statement_t> { - return { *static_cast(this), column_list_t{args...} }; + return { *static_cast(this), column_list_data_t{args...} }; } template auto set(Args... args) -> _new_statement_t> { - return { *static_cast(this), insert_list_t{args...} }; + return { *static_cast(this), insert_list_data_t{args...} }; } template @@ -248,16 +373,16 @@ namespace sqlpp -> _new_statement_t> { static_assert(not std::is_same<_database_t, void>::value, "dynamic_set must not be called in a static statement"); - return { *static_cast(this), vendor::insert_list_t<_database_t, Args...>{args...} }; + return { *static_cast(this), vendor::insert_list_data_t<_database_t, Args...>{args...} }; } }; }; // Interpreters template - struct serializer_t + struct serializer_t { - using T = insert_default_values_t; + using T = insert_default_values_data_t; static Context& _(const T& t, Context& context) { @@ -267,9 +392,9 @@ namespace sqlpp }; template - struct serializer_t> + struct serializer_t> { - using T = column_list_t; + using T = column_list_data_t; static Context& _(const T& t, Context& context) { @@ -294,15 +419,15 @@ namespace sqlpp }; template - struct serializer_t> + struct serializer_t> { - using T = insert_list_t; + 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_t(), context); + serialize(insert_default_values_data_t(), context); } else { @@ -322,17 +447,6 @@ namespace sqlpp } }; - template - struct serializer_t - { - using T = no_insert_value_list_t; - - static Context& _(const T& t, Context& context) - { - return context; - } - }; - } } diff --git a/include/sqlpp11/vendor/single_table.h b/include/sqlpp11/vendor/single_table.h index cb4bbfbf..7d83c838 100644 --- a/include/sqlpp11/vendor/single_table.h +++ b/include/sqlpp11/vendor/single_table.h @@ -36,39 +36,151 @@ namespace sqlpp { namespace vendor { + // A SINGLE TABLE DATA + template + struct single_table_data_t + { + single_table_data_t(Table table): + _table(table) + {} + + single_table_data_t(const single_table_data_t&) = default; + single_table_data_t(single_table_data_t&&) = default; + single_table_data_t& operator=(const single_table_data_t&) = default; + single_table_data_t& operator=(single_table_data_t&&) = default; + ~single_table_data_t() = default; + + Table _table; + }; + // A SINGLE TABLE template struct single_table_t { - using _traits = make_traits; + using _traits = make_traits; using _recursive_traits = make_recursive_traits; static_assert(is_table_t
::value, "argument has to be a table"); static_assert(required_tables_of
::size::value == 0, "table depends on another table"); - single_table_t(Table table): - _table(table) - {} + using _data_t = single_table_data_t; - single_table_t(const single_table_t&) = default; - single_table_t(single_table_t&&) = default; - single_table_t& operator=(const single_table_t&) = default; - single_table_t& operator=(single_table_t&&) = default; - ~single_table_t() = default; + struct _name_t {}; + // Member implementation with data and methods + template + struct _impl_t + { + _data_t _data; + }; + + // Member template for adding the named member to a statement + template + struct _member_t + { + using _data_t = single_table_data_t; + + _impl_t into; + _impl_t& operator()() { return into; } + const _impl_t& operator()() const { return into; } + + template + static auto _get_member(T t) -> decltype(t.into) + { + return t.into; + } + }; + + // Additional methods for the statement template struct _methods_t { }; - Table _table; + template + struct _result_methods_t + { + using _statement_t = typename Policies::_statement_t; + + const _statement_t& _get_statement() const + { + return static_cast(*this); + } + + static constexpr size_t _get_static_no_of_parameters() + { +#warning need to fix this + return 0; + //return _parameter_list_t::size::value; + } + + size_t _get_no_of_parameters() const + { +#warning need to fix this + return 0; + //return _parameter_list_t::size::value; + } + + void _check_consistency() const + { + // FIXME: Read up on what is allowed/prohibited in INSERT + } + + template + auto _run(Db& db) const -> decltype(db.insert(_get_statement())) + { + _check_consistency(); + + static_assert(_get_static_no_of_parameters() == 0, "cannot run insert directly with parameters, use prepare instead"); + return db.insert(*this); + } + + /* + template + auto _prepare(Db& db) const + -> prepared_insert_t + { + _check_consistency(); + + return {{}, db.prepare_insert(*this)}; + } + */ + }; }; + // NO INTO YET struct no_single_table_t { using _traits = make_traits; using _recursive_traits = make_recursive_traits<>; + // Data + using _data_t = no_data_t; + + // Member implementation with data and methods + template + struct _impl_t + { + _data_t _data; + }; + + // Member template for adding the named member to a statement + template + struct _member_t + { + using _data_t = no_data_t; + + _impl_t no_into; + _impl_t& operator()() { return no_into; } + const _impl_t& operator()() const { return no_into; } + + template + static auto _get_member(T t) -> decltype(t.no_into) + { + return t.no_into; + } + }; + template struct _methods_t { @@ -80,7 +192,7 @@ namespace sqlpp auto into(Args... args) -> _new_statement_t> { - return { *static_cast(this), single_table_t{args...} }; + return { *static_cast(this), single_table_data_t{args...} }; } #warning: remove can operate on several tables at once, so it should not use single_table anyway @@ -88,16 +200,16 @@ namespace sqlpp auto from(Args... args) -> _new_statement_t> { - return { *static_cast(this), single_table_t{args...} }; + return { *static_cast(this), single_table_data_t{args...} }; } }; }; // Interpreters template - struct serializer_t> + struct serializer_t> { - using T = single_table_t; + using T = single_table_data_t; static Context& _(const T& t, Context& context) { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ad2d430a..9de5e4e2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,11 +7,11 @@ macro (build_and_run arg) endmacro () #build_and_run(InterpretTest) -#build_and_run(InsertTest) +build_and_run(InsertTest) #build_and_run(RemoveTest) #build_and_run(UpdateTest) #build_and_run(SelectTest) -build_and_run(SelectTypeTest) +#build_and_run(SelectTypeTest) #build_and_run(FunctionTest) #build_and_run(PreparedTest) diff --git a/tests/InsertTest.cpp b/tests/InsertTest.cpp index 67e2efe7..683ed401 100644 --- a/tests/InsertTest.cpp +++ b/tests/InsertTest.cpp @@ -67,10 +67,10 @@ 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.add_values(t.beta = "cheesecake", t.delta = 1); - multi_insert.add_values(t.beta = sqlpp::default_value, t.delta = sqlpp::default_value); + 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); auto i = dynamic_insert_into(db, t).dynamic_set(); - i.add_set(t.beta = "kirschauflauf"); + i.insert_list.add(t.beta = "kirschauflauf"); serialize(i, printer).str(); db(multi_insert);