From 7afd34c349c9ec1af3a45e468e12a16acee8bf75 Mon Sep 17 00:00:00 2001 From: rbock Date: Tue, 4 Feb 2014 07:32:37 +0100 Subject: [PATCH] Added a few types/templates to help with expression tree evaluation --- include/sqlpp11/column.h | 1 + include/sqlpp11/insert.h | 2 ++ include/sqlpp11/vendor/expression.h | 10 ++++++---- include/sqlpp11/vendor/insert_list.h | 6 ++++++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/include/sqlpp11/column.h b/include/sqlpp11/column.h index f1908e4d..1e5de615 100644 --- a/include/sqlpp11/column.h +++ b/include/sqlpp11/column.h @@ -44,6 +44,7 @@ namespace sqlpp struct column_t: public ColumnSpec::_value_type::template operators> { using _is_column = std::true_type; + using _spec_t = ColumnSpec; using _table = Table; using _column_type = typename ColumnSpec::_column_type; struct _value_type: ColumnSpec::_value_type diff --git a/include/sqlpp11/insert.h b/include/sqlpp11/insert.h index b8d9fdf5..918b3892 100644 --- a/include/sqlpp11/insert.h +++ b/include/sqlpp11/insert.h @@ -30,9 +30,11 @@ #include #include #include +#include #include #include #include +#include #include namespace sqlpp diff --git a/include/sqlpp11/vendor/expression.h b/include/sqlpp11/vendor/expression.h index df1c3f56..20de7a16 100644 --- a/include/sqlpp11/vendor/expression.h +++ b/include/sqlpp11/vendor/expression.h @@ -164,10 +164,12 @@ namespace sqlpp template struct binary_expression_t: public O::_value_type::template operators> { + using _lhs_t = Lhs; + using _rhs_t = Rhs; using _value_type = typename O::_value_type; - using _parameter_tuple_t = std::tuple; + using _parameter_tuple_t = std::tuple<_lhs_t, _rhs_t>; - binary_expression_t(Lhs lhs, Rhs rhs): + binary_expression_t(_lhs_t lhs, _rhs_t rhs): _lhs(lhs), _rhs(rhs) {} @@ -178,8 +180,8 @@ namespace sqlpp binary_expression_t& operator=(binary_expression_t&&) = default; ~binary_expression_t() = default; - Lhs _lhs; - Rhs _rhs; + _lhs_t _lhs; + _rhs_t _rhs; }; template diff --git a/include/sqlpp11/vendor/insert_list.h b/include/sqlpp11/vendor/insert_list.h index f76a62b2..2d30390f 100644 --- a/include/sqlpp11/vendor/insert_list.h +++ b/include/sqlpp11/vendor/insert_list.h @@ -61,6 +61,10 @@ namespace sqlpp using _is_insert_list = std::true_type; using _is_dynamic = typename std::conditional::value, std::false_type, std::true_type>::type; using _parameter_tuple_t = std::tuple; + template class Target> + using copy_assignments_t = Target; // FIXME: Nice idea to copy variadic template arguments? + template class Target, template class Wrap> + using copy_wrapped_assignments_t = Target...>; // check for at least one order expression static_assert(_is_dynamic::value or sizeof...(Assignments), "at least one select expression required in set()"); @@ -75,6 +79,7 @@ namespace sqlpp static_assert(not sqlpp::detail::or_t::value, "at least one assignment is prohibited by its column definition in set()"); insert_list_t(Assignments... assignment): + _assignments(assignment...), _columns({assignment._lhs}...), _values(assignment._rhs...) {} @@ -97,6 +102,7 @@ namespace sqlpp 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; };